www.mooseframework.org
MaterialVectorGradAuxKernelAction.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 "Parser.h"
10 #include "Conversion.h"
11 #include "FEProblem.h"
12 #include "MooseMesh.h"
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<MaterialVectorAuxKernelAction>();
19  return params;
20 }
21 
24 {
25 }
26 
27 void
29 {
30  if (_num_prop != _num_var)
31  mooseError("variable_base and property must be vectors of the same size");
32 
33  // mesh dimension required for gradient variables
34  unsigned int dim = _mesh->dimension();
35  // For Specifying the components of the gradient terms
36  const std::vector<char> suffix = {'x', 'y', 'z'};
37 
38  for (unsigned int gr = 0; gr < _grain_num; ++gr)
39  for (unsigned int val = 0; val < _num_var; ++val)
40  for (unsigned int x = 0; x < dim; ++x)
41  {
42  std::string var_name = _var_name_base[val] + Moose::stringify(gr) + "_" + suffix[x];
43 
44  InputParameters params = _factory.getValidParams("MaterialStdVectorRealGradientAux");
45  params.set<AuxVariableName>("variable") = var_name;
46  params.set<MaterialPropertyName>("property") = _prop[val];
47  params.set<unsigned int>("component") = x;
48  params.set<unsigned int>("index") = gr;
49  params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
50 
51  std::string aux_kernel_name = var_name;
52  _problem->addAuxKernel("MaterialStdVectorRealGradientAux", aux_kernel_name, params);
53  }
54 }
const unsigned int _grain_num
number of grains to create
const std::vector< MaterialPropertyName > & _prop
list of material properties to be used
const unsigned int _num_prop
number of properties
InputParameters validParams< MaterialVectorAuxKernelAction >()
const unsigned int _num_var
number of auxvariables
MaterialVectorGradAuxKernelAction(const InputParameters &params)
const std::vector< std::string > & _var_name_base
base name for the auxvariables
InputParameters validParams< MaterialVectorGradAuxKernelAction >()