www.mooseframework.org
MaterialVectorGradAuxKernelAction.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 #include "Factory.h"
12 #include "Parser.h"
13 #include "Conversion.h"
14 #include "FEProblem.h"
15 #include "MooseMesh.h"
16 
17 registerMooseAction("PhaseFieldApp", MaterialVectorGradAuxKernelAction, "add_aux_kernel");
18 
21 {
23  return params;
24 }
25 
28 {
29 }
30 
31 void
33 {
34  if (_num_prop != _num_var)
35  paramError("property", "variable_base and property must be vectors of the same size");
36 
37  // mesh dimension required for gradient variables
38  unsigned int dim = _mesh->dimension();
39  // For Specifying the components of the gradient terms
40  const std::vector<char> suffix = {'x', 'y', 'z'};
41 
42  for (unsigned int gr = 0; gr < _grain_num; ++gr)
43  for (unsigned int val = 0; val < _num_var; ++val)
44  for (unsigned int x = 0; x < dim; ++x)
45  {
46  std::string var_name = _var_name_base[val] + Moose::stringify(gr) + "_" + suffix[x];
47 
48  InputParameters params = _factory.getValidParams("MaterialStdVectorRealGradientAux");
49  params.set<AuxVariableName>("variable") = var_name;
50  params.set<MaterialPropertyName>("property") = _prop[val];
51  params.set<unsigned int>("component") = x;
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("MaterialStdVectorRealGradientAux", aux_kernel_name, params);
57  }
58 }
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
const unsigned int _num_var
number of auxvariables
unsigned int dim
T & set(const std::string &name, bool quiet_mode=false)
InputParameters getValidParams(const std::string &name) const
MaterialVectorGradAuxKernelAction(const InputParameters &params)
const std::vector< std::string > & _var_name_base
base name for the auxvariables
Factory & _factory
const std::vector< double > x
void paramError(const std::string &param, Args... args) const
std::string stringify(const T &t)
std::shared_ptr< MooseMesh > & _mesh
registerMooseAction("PhaseFieldApp", MaterialVectorGradAuxKernelAction, "add_aux_kernel")
std::shared_ptr< FEProblemBase > & _problem