www.mooseframework.org
MaterialVectorAuxKernelAction.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>(
18  "grain_num", "Value that specifies the number of grains to create aux kernels for.");
19  params.addRequiredParam<std::vector<std::string>>(
20  "variable_base", "Vector specifies the base name of the variables.");
21  params.addRequiredParam<std::vector<MaterialPropertyName>>("property",
22  "The material property names.");
23  params.addParam<bool>(
24  "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels.");
25  return params;
26 }
27 
29  : Action(params),
30  _grain_num(getParam<unsigned int>("grain_num")),
31  _var_name_base(getParam<std::vector<std::string>>("variable_base")),
32  _num_var(_var_name_base.size()),
33  _prop(getParam<std::vector<MaterialPropertyName>>("property")),
34  _num_prop(_prop.size())
35 {
36 }
37 
38 void
40 {
41  if (_num_prop != _num_var)
42  mooseError("variable_base and property must be vectors of the same size");
43 
44  for (unsigned int gr = 0; gr < _grain_num; ++gr)
45  for (unsigned int val = 0; val < _num_var; ++val)
46  {
47  std::string var_name = _var_name_base[val] + Moose::stringify(gr);
48 
49  InputParameters params = _factory.getValidParams("MaterialStdVectorAux");
50  params.set<AuxVariableName>("variable") = var_name;
51  params.set<MaterialPropertyName>("property") = _prop[val];
52  params.set<unsigned int>("index") = gr;
53  params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
54 
55  std::string aux_kernel_name = var_name;
56  _problem->addAuxKernel("MaterialStdVectorAux", aux_kernel_name, params);
57  }
58 }
const unsigned int _grain_num
number of grains to create
MaterialVectorAuxKernelAction(const InputParameters &params)
const std::vector< MaterialPropertyName > & _prop
list of material properties to be used
const unsigned int _num_prop
number of properties
const unsigned int _num_var
number of auxvariables
const std::vector< std::string > & _var_name_base
base name for the auxvariables
InputParameters validParams< MaterialVectorAuxKernelAction >()