www.mooseframework.org
MatVecRealGradAuxKernelAction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 #include "Factory.h"
9 #include "Conversion.h"
10 #include "FEProblem.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<Action>();
17  params.addRequiredParam<unsigned int>("op_num",
18  "Value that specifies the number of grains to create");
19  params.addRequiredParam<std::vector<std::string>>(
20  "var_name_base", "Vector specifies the base name of the variables");
21  params.addRequiredParam<std::vector<MaterialPropertyName>>("property",
22  "the scalar material property names");
23  params.addParam<bool>(
24  "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels");
25  params.addRequiredParam<unsigned int>("dim", "the dimensions of the mesh");
26  params.addParam<AuxVariableName>("divergence_variable",
27  "Name of divergence variable to generate kernels for");
28  params.addParam<MaterialPropertyName>("divergence_property",
29  "Scalar material property name for divergence variable");
30  return params;
31 }
32 
34  : Action(params),
35  _div_var(getParam<AuxVariableName>("divergence_variable")),
36  _prop(getParam<std::vector<MaterialPropertyName>>("property")),
37  _div_prop(getParam<MaterialPropertyName>("divergence_property"))
38 {
39  mooseDeprecated("Use 'MaterialVectorAuxKernel' or 'MaterialVectorGradAuxKernel' action instead "
40  "depending on data_type of MaterialProperty<std::vector<data_type> >");
41 }
42 
43 void
45 {
46  const std::vector<std::string> var_name_base =
47  getParam<std::vector<std::string>>("var_name_base");
48 
49  const unsigned int op_num = getParam<unsigned int>("op_num");
50  const unsigned int dim = getParam<unsigned int>("dim");
51  const unsigned int size_v = var_name_base.size();
52  const unsigned int size_p = _prop.size();
53 
54  if (size_p != size_v)
55  mooseError("var_name_base and property must be vectors of the same dimension");
56 
57  for (unsigned int op = 0; op < op_num; ++op)
58  {
59  for (unsigned int val = 0; val < size_v; ++val)
60  for (unsigned int x = 0; x < dim; ++x)
61  {
62  std::string var_name = var_name_base[val] + Moose::stringify(x) + Moose::stringify(op);
63  {
64  InputParameters params = _factory.getValidParams("MaterialStdVectorRealGradientAux");
65  params.set<AuxVariableName>("variable") = var_name;
66  params.set<MaterialPropertyName>("property") = _prop[val];
67  params.set<unsigned int>("component") = x;
68  params.set<unsigned int>("index") = op;
69  params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
70  _problem->addAuxKernel("MaterialStdVectorRealGradientAux", "grad_" + var_name, params);
71  }
72  }
73 
74  if (isParamValid("divergence_variable"))
75  {
76  if (isParamValid("divergence_property"))
77  {
78  InputParameters params = _factory.getValidParams("MaterialStdVectorAux");
79  params.set<AuxVariableName>("variable") = _div_var;
80  params.set<MaterialPropertyName>("property") = _div_prop;
81  params.set<unsigned int>("index") = op;
82  params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
83  _problem->addAuxKernel("MaterialStdVectorAux", "div_" + Moose::stringify(op), params);
84  }
85  else
86  mooseError("Must specify a divergence_property name along with divergence_variable name");
87  }
88  }
89 }
const std::vector< MaterialPropertyName > _prop
MatVecRealGradAuxKernelAction(const InputParameters &params)
InputParameters validParams< MatVecRealGradAuxKernelAction >()