https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
ConservedAction Class Reference

#include <ConservedAction.h>

Inheritance diagram for ConservedAction:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 ConservedAction (const InputParameters &params)
 
virtual void act () override
 
void timedAct ()
 
virtual void addRelationshipManagers (Moose::RelationshipManagerType when_type)
 
MooseObjectName uniqueActionName () const
 
const std::string & specificTaskName () const
 
const std::set< std::string > & getAllTasks () const
 
void appendTask (const std::string &task)
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
virtual const std::string & name () const
 
std::string typeAndName () const
 
std::string errorPrefix (const std::string &error_type) const
 
void callMooseError (std::string msg, const bool with_prefix) const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
const InputParametersparameters () const
 
MooseObjectName uniqueName () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &nm) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void mooseError (Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
PerfGraphperfGraph ()
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 

Public Attributes

const ConsoleStream _console
 

Static Public Attributes

static constexpr auto SYSTEM
 
static constexpr auto NAME
 

Protected Types

enum  SolveType { SolveType::DIRECT, SolveType::REVERSE_SPLIT, SolveType::FORWARD_SPLIT }
 Type of solve. More...
 

Protected Member Functions

bool addRelationshipManagers (Moose::RelationshipManagerType when_type, const InputParameters &moose_object_pars)
 
void associateWithParameter (const std::string &param_name, InputParameters &params) const
 
void associateWithParameter (const InputParameters &from_params, const std::string &param_name, InputParameters &params) const
 
const T & getMeshProperty (const std::string &data_name, const std::string &prefix)
 
const T & getMeshProperty (const std::string &data_name)
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name) const
 
bool hasMeshProperty (const std::string &data_name) const
 
std::string meshPropertyName (const std::string &data_name) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 
std::string timedSectionName (const std::string &section_name) const
 

Static Protected Member Functions

static std::string meshPropertyName (const std::string &data_name, const std::string &prefix)
 

Protected Attributes

std::string _chempot_name
 Name of chemical potential variable for split solves. More...
 
const SolveType _solve_type
 Type of solve to use used in the action. More...
 
const NonlinearVariableName _var_name
 Name of the variable being created. More...
 
libMesh::FEType _fe_type
 FEType for the variable being created. More...
 
const Real _scaling
 Scaling parameter. More...
 
std::string _registered_identifier
 
std::string _specific_task_name
 
std::set< std::string > _all_tasks
 
ActionWarehouse_awh
 
const std::string & _current_task
 
std::shared_ptr< MooseMesh > & _mesh
 
std::shared_ptr< MooseMesh > & _displaced_mesh
 
std::shared_ptr< FEProblemBase > & _problem
 
PerfID _act_timer
 
MooseApp_app
 
const std::string _type
 
const std::string _name
 
const InputParameters_pars
 
Factory_factory
 
ActionFactory_action_factory
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
const Parallel::Communicator & _communicator
 

Detailed Description

Definition at line 16 of file ConservedAction.h.

Member Enumeration Documentation

◆ SolveType

enum ConservedAction::SolveType
strongprotected

Type of solve.

Enumerator
DIRECT 
REVERSE_SPLIT 
FORWARD_SPLIT 

Definition at line 27 of file ConservedAction.h.

28  {
29  DIRECT,
30  REVERSE_SPLIT,
31  FORWARD_SPLIT
32  };

Constructor & Destructor Documentation

◆ ConservedAction()

ConservedAction::ConservedAction ( const InputParameters params)

Definition at line 65 of file ConservedAction.C.

66  : Action(params),
67  _solve_type(getParam<MooseEnum>("solve_type").getEnum<SolveType>()),
68  _var_name(name()),
69  _scaling(getParam<Real>("scaling"))
70 {
71  switch (_solve_type)
72  {
73  case SolveType::DIRECT:
74  _fe_type = FEType(Utility::string_to_enum<Order>("THIRD"),
75  Utility::string_to_enum<FEFamily>("HERMITE"));
76  if (!parameters().isParamSetByAddParam("order") &&
77  !parameters().isParamSetByAddParam("family"))
78  mooseWarning("Order and family autoset to third and hermite in ConservedAction");
79  break;
82  _fe_type = FEType(Utility::string_to_enum<Order>(getParam<MooseEnum>("order")),
83  Utility::string_to_enum<FEFamily>(getParam<MooseEnum>("family")));
84  // Set name of chemical potential variable
85  _chempot_name = "chem_pot_" + _var_name;
86  break;
87  default:
88  paramError("solve_type", "Incorrect solve_type in ConservedAction");
89  }
90 }
Action(const InputParameters &parameters)
virtual const std::string & name() const
void mooseWarning(Args &&... args) const
const Real _scaling
Scaling parameter.
std::string _chempot_name
Name of chemical potential variable for split solves.
const NonlinearVariableName _var_name
Name of the variable being created.
void paramError(const std::string &param, Args... args) const
const SolveType _solve_type
Type of solve to use used in the action.
libMesh::FEType _fe_type
FEType for the variable being created.
const InputParameters & parameters() const

Member Function Documentation

◆ act()

void ConservedAction::act ( )
overridevirtual

Implements Action.

Definition at line 93 of file ConservedAction.C.

94 {
95  //
96  // Add variable(s)
97  //
98  if (_current_task == "add_variable")
99  {
101  auto var_params = _factory.getValidParams(type);
102  var_params.set<MooseEnum>("family") = Moose::stringify(_fe_type.family);
103  var_params.set<MooseEnum>("order") = _fe_type.order.get_order();
104  var_params.set<std::vector<Real>>("scaling") = {_scaling};
105  var_params.applySpecificParameters(parameters(), {"block"});
106 
107  // Create conserved variable _var_name
108  _problem->addVariable(type, _var_name, var_params);
109 
110  // Create chemical potential variable for split form
111  switch (_solve_type)
112  {
113  case SolveType::DIRECT:
114  break;
117  _problem->addVariable(type, _chempot_name, var_params);
118  }
119  }
120 
121  //
122  // Add Kernels
123  //
124  else if (_current_task == "add_kernel")
125  {
126  switch (_solve_type)
127  {
128  case SolveType::DIRECT:
129  // Add time derivative kernel
130  {
131  std::string kernel_type = "TimeDerivative";
132 
133  std::string kernel_name = _var_name + "_" + kernel_type;
134  InputParameters params = _factory.getValidParams(kernel_type);
135  params.set<NonlinearVariableName>("variable") = _var_name;
136  params.applyParameters(parameters());
137 
138  _problem->addKernel(kernel_type, kernel_name, params);
139  }
140 
141  // Add CahnHilliard kernel
142  {
143  std::string kernel_type = "CahnHilliard";
144 
145  std::string kernel_name = _var_name + "_" + kernel_type;
146  InputParameters params = _factory.getValidParams(kernel_type);
147  params.set<NonlinearVariableName>("variable") = _var_name;
148  params.set<MaterialPropertyName>("mob_name") = getParam<MaterialPropertyName>("mobility");
149  params.set<MaterialPropertyName>("f_name") =
150  getParam<MaterialPropertyName>("free_energy");
151  params.applyParameters(parameters());
152 
153  _problem->addKernel(kernel_type, kernel_name, params);
154  }
155 
156  // Add ACInterface kernel
157  {
158  std::string kernel_type = "CHInterface";
159 
160  std::string kernel_name = _var_name + "_" + kernel_type;
161  InputParameters params = _factory.getValidParams(kernel_type);
162  params.set<NonlinearVariableName>("variable") = _var_name;
163  params.set<MaterialPropertyName>("mob_name") = getParam<MaterialPropertyName>("mobility");
164  params.set<MaterialPropertyName>("kappa_name") = getParam<MaterialPropertyName>("kappa");
165  params.applyParameters(parameters());
166 
167  _problem->addKernel(kernel_type, kernel_name, params);
168  }
169  break;
170 
172  // Add time derivative kernel
173  {
174  std::string kernel_type = "CoupledTimeDerivative";
175 
176  std::string kernel_name = _var_name + "_" + kernel_type;
177  InputParameters params = _factory.getValidParams(kernel_type);
178  params.set<NonlinearVariableName>("variable") = _chempot_name;
179  params.set<std::vector<VariableName>>("v") = {_var_name};
180  params.applyParameters(parameters());
181 
182  _problem->addKernel(kernel_type, kernel_name, params);
183  }
184 
185  // Add SplitCHWRes kernel
186  {
187  std::string kernel_type = "SplitCHWRes";
188 
189  std::string kernel_name = _var_name + "_" + kernel_type;
190  InputParameters params = _factory.getValidParams(kernel_type);
191  params.set<NonlinearVariableName>("variable") = _chempot_name;
192  params.set<MaterialPropertyName>("mob_name") = getParam<MaterialPropertyName>("mobility");
193  params.applyParameters(parameters());
194 
195  _problem->addKernel(kernel_type, kernel_name, params);
196  }
197 
198  // Add SplitCHParsed kernel
199  {
200  std::string kernel_type = "SplitCHParsed";
201 
202  std::string kernel_name = _var_name + "_" + kernel_type;
203  InputParameters params = _factory.getValidParams(kernel_type);
204  params.set<NonlinearVariableName>("variable") = _var_name;
205  params.set<std::vector<VariableName>>("w") = {_chempot_name};
206  params.set<MaterialPropertyName>("f_name") =
207  getParam<MaterialPropertyName>("free_energy");
208  params.set<MaterialPropertyName>("kappa_name") = getParam<MaterialPropertyName>("kappa");
209  params.applyParameters(parameters());
210 
211  _problem->addKernel(kernel_type, kernel_name, params);
212  }
213  break;
214 
216  // Add time derivative kernel
217  {
218  std::string kernel_type = "TimeDerivative";
219 
220  std::string kernel_name = _var_name + "_" + kernel_type;
221  InputParameters params = _factory.getValidParams(kernel_type);
222  params.set<NonlinearVariableName>("variable") = _var_name;
223  params.applyParameters(parameters());
224 
225  _problem->addKernel(kernel_type, kernel_name, params);
226  }
227 
228  // Add MatDiffusion kernel for c residual
229  {
230  std::string kernel_type = "MatDiffusion";
231 
232  std::string kernel_name = _var_name + "_" + kernel_type;
233  InputParameters params = _factory.getValidParams(kernel_type);
234  params.set<NonlinearVariableName>("variable") = _var_name;
235  params.set<std::vector<VariableName>>("v") = {_chempot_name};
236  params.set<MaterialPropertyName>("diffusivity") =
237  getParam<MaterialPropertyName>("mobility");
238  params.applyParameters(parameters());
239 
240  _problem->addKernel(kernel_type, kernel_name, params);
241  }
242  // Add MatDiffusion kernel for chemical potential residual
243  {
244  std::string kernel_type = "MatDiffusion";
245 
246  std::string kernel_name = _chempot_name + "_" + kernel_type;
247  InputParameters params = _factory.getValidParams(kernel_type);
248  params.set<NonlinearVariableName>("variable") = _chempot_name;
249  params.set<std::vector<VariableName>>("v") = {_var_name};
250  params.set<MaterialPropertyName>("diffusivity") = getParam<MaterialPropertyName>("kappa");
251  params.applyParameters(parameters());
252 
253  _problem->addKernel(kernel_type, kernel_name, params);
254  }
255 
256  // Add CoupledMaterialDerivative kernel
257  {
258  std::string kernel_type = "CoupledMaterialDerivative";
259 
260  std::string kernel_name = _chempot_name + "_" + kernel_type;
261  InputParameters params = _factory.getValidParams(kernel_type);
262  params.set<NonlinearVariableName>("variable") = _chempot_name;
263  params.set<std::vector<VariableName>>("v") = {_var_name};
264  params.set<MaterialPropertyName>("f_name") =
265  getParam<MaterialPropertyName>("free_energy");
266  params.applyParameters(parameters());
267 
268  _problem->addKernel(kernel_type, kernel_name, params);
269  }
270 
271  // Add CoefReaction kernel
272  {
273  std::string kernel_type = "CoefReaction";
274 
275  std::string kernel_name = _chempot_name + "_" + kernel_type;
276  InputParameters params = _factory.getValidParams(kernel_type);
277  params.set<NonlinearVariableName>("variable") = _chempot_name;
278  params.set<Real>("coefficient") = -1.0;
279  params.applyParameters(parameters());
280 
281  _problem->addKernel(kernel_type, kernel_name, params);
282  }
283  }
284  }
285 }
T & set(const std::string &name, bool quiet_mode=false)
void applyParameters(const InputParameters &common, const std::vector< std::string > &exclude={}, const bool allow_private=false)
OrderWrapper order
Factory & _factory
const Real _scaling
Scaling parameter.
std::string _chempot_name
Name of chemical potential variable for split solves.
const NonlinearVariableName _var_name
Name of the variable being created.
const std::string & type() const
const std::string & _current_task
static std::string variableType(const libMesh::FEType &fe_type, const bool is_fv=false, const bool is_array=false)
std::string stringify(const T &t)
const SolveType _solve_type
Type of solve to use used in the action.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
libMesh::FEType _fe_type
FEType for the variable being created.
std::shared_ptr< FEProblemBase > & _problem
const InputParameters & parameters() const

◆ validParams()

InputParameters ConservedAction::validParams ( )
static

Definition at line 28 of file ConservedAction.C.

29 {
31  params.addClassDescription(
32  "Set up the variable(s) and the kernels needed for a conserved phase field variable."
33  " Note that for a direct solve, the element family and order are overwritten with hermite "
34  "and third.");
35  MooseEnum solves("DIRECT REVERSE_SPLIT FORWARD_SPLIT");
36  params.addRequiredParam<MooseEnum>("solve_type", solves, "Split or direct solve?");
37  // Get MooseEnums for the possible order/family options for this variable
40  params.addParam<MooseEnum>("family",
41  families,
42  "Specifies the family of FE "
43  "shape functions to use for this variable");
44  params.addParam<MooseEnum>("order",
45  orders,
46  "Specifies the order of the FE "
47  "shape function to use for this variable");
48  params.addParam<Real>("scaling", 1.0, "Specifies a scaling factor to apply to this variable");
49  params.addParam<bool>("implicit", true, "Whether kernels are implicit or not");
50  params.addParam<bool>(
51  "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels");
52  params.addParamNamesToGroup("scaling implicit use_displaced_mesh", "Advanced");
53  params.addRequiredParam<MaterialPropertyName>("mobility", "The mobility used with the kernel");
54  params.addCoupledVar("args", "Vector of nonlinear variable arguments this kernel depends on");
55  params.deprecateCoupledVar("args", "coupled_variables", "02/27/2024");
56 
57  params.addRequiredParam<MaterialPropertyName>(
58  "free_energy", "Base name of the free energy function F defined in a free energy material");
59  params.addRequiredParam<MaterialPropertyName>("kappa", "The kappa used with the kernel");
60  params.addParam<std::vector<SubdomainName>>(
61  "block", {}, "Block restriction for the variables and kernels");
62  return params;
63 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
static MooseEnum getNonlinearVariableFamilies()
static InputParameters validParams()
static MooseEnum getNonlinearVariableOrders()
void deprecateCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
void addCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)

Member Data Documentation

◆ _chempot_name

std::string ConservedAction::_chempot_name
protected

Name of chemical potential variable for split solves.

Definition at line 34 of file ConservedAction.h.

Referenced by act(), and ConservedAction().

◆ _fe_type

libMesh::FEType ConservedAction::_fe_type
protected

FEType for the variable being created.

Definition at line 40 of file ConservedAction.h.

Referenced by act(), and ConservedAction().

◆ _scaling

const Real ConservedAction::_scaling
protected

Scaling parameter.

Definition at line 42 of file ConservedAction.h.

Referenced by act().

◆ _solve_type

const SolveType ConservedAction::_solve_type
protected

Type of solve to use used in the action.

Definition at line 36 of file ConservedAction.h.

Referenced by act(), and ConservedAction().

◆ _var_name

const NonlinearVariableName ConservedAction::_var_name
protected

Name of the variable being created.

Definition at line 38 of file ConservedAction.h.

Referenced by act(), and ConservedAction().


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