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 21 of file DisplacementGradientsAction.h.

Constructor & Destructor Documentation

◆ DisplacementGradientsAction()

DisplacementGradientsAction::DisplacementGradientsAction ( const InputParameters &  params)

Definition at line 39 of file DisplacementGradientsAction.C.

40  : Action(params),
41  _displacements(getParam<std::vector<VariableName>>("displacements")),
42  _displacement_gradients(getParam<std::vector<VariableName>>("displacement_gradients"))
43 {
44 }
std::vector< VariableName > _displacements
std::vector< VariableName > _displacement_gradients

Member Function Documentation

◆ act()

void DisplacementGradientsAction::act ( )
virtual

Definition at line 47 of file DisplacementGradientsAction.C.

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

Member Data Documentation

◆ _displacement_gradients

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

Definition at line 30 of file DisplacementGradientsAction.h.

Referenced by act().

◆ _displacements

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

Definition at line 29 of file DisplacementGradientsAction.h.

Referenced by act().


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