www.mooseframework.org
Public Member Functions | Private Attributes | List of all members
DisplacementGradientsAction Class Reference

Automatically generates all variables, Kernels, and Materials to ensure the correct derivatives of the elastic free energy in a non-split Cahn-Hilliard simulation are assembled. More...

#include <DisplacementGradientsAction.h>

Inheritance diagram for DisplacementGradientsAction:
[legend]

Public Member Functions

 DisplacementGradientsAction (const InputParameters &params)
 
virtual void act ()
 

Private Attributes

std::vector< VariableName > _displacements
 
std::vector< VariableName > _displacement_gradients
 

Detailed Description

Automatically generates all variables, Kernels, and Materials to ensure the correct derivatives of the elastic free energy in a non-split Cahn-Hilliard simulation are assembled.

Definition at line 18 of file DisplacementGradientsAction.h.

Constructor & Destructor Documentation

DisplacementGradientsAction::DisplacementGradientsAction ( const InputParameters &  params)

Definition at line 30 of file DisplacementGradientsAction.C.

31  : Action(params),
32  _displacements(getParam<std::vector<VariableName>>("displacements")),
33  _displacement_gradients(getParam<std::vector<VariableName>>("displacement_gradients"))
34 {
35 }
std::vector< VariableName > _displacements
std::vector< VariableName > _displacement_gradients

Member Function Documentation

void DisplacementGradientsAction::act ( )
virtual

Definition at line 38 of file DisplacementGradientsAction.C.

39 {
40  unsigned int ngrad = _displacement_gradients.size();
41 
42  if (_current_task == "add_variable")
43  {
44  // Loop through the gij variables
45  Real scaling = getParam<Real>("scaling");
46  for (unsigned int i = 0; i < ngrad; ++i)
47  {
48  // Create displacement gradient variables
49  _problem->addVariable(_displacement_gradients[i],
50  FEType(Utility::string_to_enum<Order>("FIRST"),
51  Utility::string_to_enum<FEFamily>("LAGRANGE")),
52  scaling);
53  }
54  }
55  else if (_current_task == "add_material")
56  {
57  InputParameters params = _factory.getValidParams("StrainGradDispDerivatives");
58  params.set<std::vector<VariableName>>("displacement_gradients") = _displacement_gradients;
59  params.set<std::vector<SubdomainName>>("block") = {"0"}; // TODO: add parameter for this
60  _problem->addMaterial("StrainGradDispDerivatives", "strain_grad_disp_derivatives", params);
61  }
62  else if (_current_task == "add_kernel")
63  {
64  unsigned int ndisp = _displacements.size();
65  if (ndisp * ndisp != ngrad)
66  mooseError("Number of displacement gradient variables must be the square of the number of "
67  "displacement variables.");
68 
69  // Loop through the displacements
70  unsigned int i = 0;
71  for (unsigned int j = 0; j < ndisp; ++j)
72  for (unsigned int k = 0; k < ndisp; ++k)
73  {
74  InputParameters params = _factory.getValidParams("GradientComponent");
75  params.set<NonlinearVariableName>("variable") = _displacement_gradients[i];
76  params.set<std::vector<VariableName>>("v") = {_displacements[j]};
77  params.set<unsigned int>("component") = k;
78  _problem->addKernel(
79  "GradientComponent", _displacement_gradients[i] + "_grad_kernel", params);
80  ++i;
81  }
82  }
83  else
84  mooseError("Internal error.");
85 }
std::vector< VariableName > _displacements
std::vector< VariableName > _displacement_gradients

Member Data Documentation

std::vector<VariableName> DisplacementGradientsAction::_displacement_gradients
private

Definition at line 27 of file DisplacementGradientsAction.h.

Referenced by act().

std::vector<VariableName> DisplacementGradientsAction::_displacements
private

Definition at line 26 of file DisplacementGradientsAction.h.

Referenced by act().


The documentation for this class was generated from the following files: