www.mooseframework.org
Public Member Functions | Protected Types | Protected Attributes | List of all members
ConservedAction Class Reference

#include <ConservedAction.h>

Inheritance diagram for ConservedAction:
[legend]

Public Member Functions

 ConservedAction (const InputParameters &params)
 
virtual void act () override
 

Protected Types

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

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...
 
FEType _fe_type
 FEType for the variable being created. More...
 
const Real _scaling
 Scaling parameter. More...
 

Detailed Description

Definition at line 24 of file ConservedAction.h.

Member Enumeration Documentation

◆ SolveType

enum ConservedAction::SolveType
strongprotected

Type of solve.

Enumerator
DIRECT 
REVERSE_SPLIT 
FORWARD_SPLIT 

Definition at line 33 of file ConservedAction.h.

34  {
35  DIRECT,
36  REVERSE_SPLIT,
37  FORWARD_SPLIT
38  };

Constructor & Destructor Documentation

◆ ConservedAction()

ConservedAction::ConservedAction ( const InputParameters &  params)

Definition at line 62 of file ConservedAction.C.

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

Member Function Documentation

◆ act()

void ConservedAction::act ( )
overridevirtual

Definition at line 90 of file ConservedAction.C.

91 {
92  //
93  // Add variable(s)
94  //
95  if (_current_task == "add_variable")
96  {
97  // Create conserved variable _var_name
98  _problem->addVariable(_var_name, _fe_type, _scaling);
99 
100  // Create chemical potential variable for split form
101  switch (_solve_type)
102  {
103  case SolveType::DIRECT:
104  break;
107  _problem->addVariable(_chempot_name, _fe_type, _scaling);
108  }
109  }
110 
111  //
112  // Add Kernels
113  //
114  else if (_current_task == "add_kernel")
115  {
116  switch (_solve_type)
117  {
118  case SolveType::DIRECT:
119  // Add time derivative kernel
120  {
121  std::string kernel_type = "TimeDerivative";
122 
123  std::string kernel_name = _var_name + "_" + kernel_type;
124  InputParameters params = _factory.getValidParams(kernel_type);
125  params.set<NonlinearVariableName>("variable") = _var_name;
126  params.applyParameters(parameters());
127 
128  _problem->addKernel(kernel_type, kernel_name, params);
129  }
130 
131  // Add CahnHilliard kernel
132  {
133  std::string kernel_type = "CahnHilliard";
134 
135  std::string kernel_name = _var_name + "_" + kernel_type;
136  InputParameters params = _factory.getValidParams(kernel_type);
137  params.set<NonlinearVariableName>("variable") = _var_name;
138  params.set<MaterialPropertyName>("mob_name") = getParam<MaterialPropertyName>("mobility");
139  params.set<MaterialPropertyName>("f_name") =
140  getParam<MaterialPropertyName>("free_energy");
141  params.applyParameters(parameters());
142 
143  _problem->addKernel(kernel_type, kernel_name, params);
144  }
145 
146  // Add ACInterface kernel
147  {
148  std::string kernel_type = "CHInterface";
149 
150  std::string kernel_name = _var_name + "_" + kernel_type;
151  InputParameters params = _factory.getValidParams(kernel_type);
152  params.set<NonlinearVariableName>("variable") = _var_name;
153  params.set<MaterialPropertyName>("mob_name") = getParam<MaterialPropertyName>("mobility");
154  params.set<MaterialPropertyName>("kappa_name") = getParam<MaterialPropertyName>("kappa");
155  params.applyParameters(parameters());
156 
157  _problem->addKernel(kernel_type, kernel_name, params);
158  }
159  break;
160 
162  // Add time derivative kernel
163  {
164  std::string kernel_type = "CoupledTimeDerivative";
165 
166  std::string kernel_name = _var_name + "_" + kernel_type;
167  InputParameters params = _factory.getValidParams(kernel_type);
168  params.set<NonlinearVariableName>("variable") = _chempot_name;
169  params.set<std::vector<VariableName>>("v") = {_var_name};
170  params.applyParameters(parameters());
171 
172  _problem->addKernel(kernel_type, kernel_name, params);
173  }
174 
175  // Add SplitCHWRes kernel
176  {
177  std::string kernel_type = "SplitCHWRes";
178 
179  std::string kernel_name = _var_name + "_" + kernel_type;
180  InputParameters params = _factory.getValidParams(kernel_type);
181  params.set<NonlinearVariableName>("variable") = _chempot_name;
182  params.set<MaterialPropertyName>("mob_name") = getParam<MaterialPropertyName>("mobility");
183  params.applyParameters(parameters());
184 
185  _problem->addKernel(kernel_type, kernel_name, params);
186  }
187 
188  // Add SplitCHParsed kernel
189  {
190  std::string kernel_type = "SplitCHParsed";
191 
192  std::string kernel_name = _var_name + "_" + kernel_type;
193  InputParameters params = _factory.getValidParams(kernel_type);
194  params.set<NonlinearVariableName>("variable") = _var_name;
195  params.set<std::vector<VariableName>>("w") = {_chempot_name};
196  params.set<MaterialPropertyName>("f_name") =
197  getParam<MaterialPropertyName>("free_energy");
198  params.set<MaterialPropertyName>("kappa_name") = getParam<MaterialPropertyName>("kappa");
199  params.applyParameters(parameters());
200 
201  _problem->addKernel(kernel_type, kernel_name, params);
202  }
203  break;
204 
206  // Add time derivative kernel
207  {
208  std::string kernel_type = "TimeDerivative";
209 
210  std::string kernel_name = _var_name + "_" + kernel_type;
211  InputParameters params = _factory.getValidParams(kernel_type);
212  params.set<NonlinearVariableName>("variable") = _var_name;
213  params.applyParameters(parameters());
214 
215  _problem->addKernel(kernel_type, kernel_name, params);
216  }
217 
218  // Add MatDiffusion kernel for c residual
219  {
220  std::string kernel_type = "MatDiffusion";
221 
222  std::string kernel_name = _var_name + "_" + kernel_type;
223  InputParameters params = _factory.getValidParams(kernel_type);
224  params.set<NonlinearVariableName>("variable") = _var_name;
225  params.set<std::vector<VariableName>>("conc") = {_chempot_name};
226  params.set<MaterialPropertyName>("D_name") = getParam<MaterialPropertyName>("mobility");
227  params.applyParameters(parameters());
228 
229  _problem->addKernel(kernel_type, kernel_name, params);
230  }
231  // Add MatDiffusion kernel for chemical potential residual
232  {
233  std::string kernel_type = "MatDiffusion";
234 
235  std::string kernel_name = _chempot_name + "_" + kernel_type;
236  InputParameters params = _factory.getValidParams(kernel_type);
237  params.set<NonlinearVariableName>("variable") = _chempot_name;
238  params.set<std::vector<VariableName>>("conc") = {_var_name};
239  params.set<MaterialPropertyName>("D_name") = getParam<MaterialPropertyName>("kappa");
240  params.applyParameters(parameters());
241 
242  _problem->addKernel(kernel_type, kernel_name, params);
243  }
244 
245  // Add CoupledMaterialDerivative kernel
246  {
247  std::string kernel_type = "CoupledMaterialDerivative";
248 
249  std::string kernel_name = _chempot_name + "_" + kernel_type;
250  InputParameters params = _factory.getValidParams(kernel_type);
251  params.set<NonlinearVariableName>("variable") = _chempot_name;
252  params.set<std::vector<VariableName>>("v") = {_var_name};
253  params.set<MaterialPropertyName>("f_name") =
254  getParam<MaterialPropertyName>("free_energy");
255  params.applyParameters(parameters());
256 
257  _problem->addKernel(kernel_type, kernel_name, params);
258  }
259 
260  // Add CoefReaction kernel
261  {
262  std::string kernel_type = "CoefReaction";
263 
264  std::string kernel_name = _chempot_name + "_" + kernel_type;
265  InputParameters params = _factory.getValidParams(kernel_type);
266  params.set<NonlinearVariableName>("variable") = _chempot_name;
267  params.set<Real>("coefficient") = -1.0;
268  params.applyParameters(parameters());
269 
270  _problem->addKernel(kernel_type, kernel_name, params);
271  }
272  }
273  }
274 }
FEType _fe_type
FEType for the variable being created.
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 SolveType _solve_type
Type of solve to use used in the action.

Member Data Documentation

◆ _chempot_name

std::string ConservedAction::_chempot_name
protected

Name of chemical potential variable for split solves.

Definition at line 40 of file ConservedAction.h.

Referenced by act(), and ConservedAction().

◆ _fe_type

FEType ConservedAction::_fe_type
protected

FEType for the variable being created.

Definition at line 46 of file ConservedAction.h.

Referenced by act(), and ConservedAction().

◆ _scaling

const Real ConservedAction::_scaling
protected

Scaling parameter.

Definition at line 48 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 42 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 44 of file ConservedAction.h.

Referenced by act(), and ConservedAction().


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