https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MatVecRealGradAuxKernelAction.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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 "Conversion.h"
13#include "FEProblem.h"
14
15registerMooseAction("PhaseFieldApp", MatVecRealGradAuxKernelAction, "add_aux_kernel");
16
19{
21 params.addClassDescription("Outputs all components of the gradient of the real standard "
22 "vector-valued properties specified");
23 params.addRequiredParam<unsigned int>("op_num",
24 "Value that specifies the number of grains to create");
25 params.addRequiredParam<std::vector<std::string>>(
26 "var_name_base", "Vector specifies the base name of the variables");
27 params.addRequiredParam<std::vector<MaterialPropertyName>>("property",
28 "the scalar material property names");
29 params.addParam<bool>(
30 "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels");
31 params.addRequiredParam<unsigned int>("dim", "the dimensions of the mesh");
32 params.addParam<AuxVariableName>("divergence_variable",
33 "Name of divergence variable to generate kernels for");
34 params.addParam<MaterialPropertyName>("divergence_property",
35 "Scalar material property name for divergence variable");
36 return params;
37}
38
40 : Action(params),
41 _div_var(getParam<AuxVariableName>("divergence_variable")),
42 _prop(getParam<std::vector<MaterialPropertyName>>("property")),
43 _div_prop(getParam<MaterialPropertyName>("divergence_property"))
44{
45 mooseDeprecated("Use 'MaterialVectorAuxKernel' or 'MaterialVectorGradAuxKernel' action instead "
46 "depending on data_type of MaterialProperty<std::vector<data_type> >");
47}
48
49void
51{
52 const std::vector<std::string> var_name_base =
53 getParam<std::vector<std::string>>("var_name_base");
54
55 const unsigned int op_num = getParam<unsigned int>("op_num");
56 const unsigned int dim = getParam<unsigned int>("dim");
57 const unsigned int size_v = var_name_base.size();
58 const unsigned int size_p = _prop.size();
59
60 if (size_p != size_v)
61 paramError("property", "var_name_base and property must be vectors of the same dimension");
62
63 for (unsigned int op = 0; op < op_num; ++op)
64 {
65 for (unsigned int val = 0; val < size_v; ++val)
66 for (unsigned int x = 0; x < dim; ++x)
67 {
68 std::string var_name = var_name_base[val] + Moose::stringify(x) + Moose::stringify(op);
69 {
70 InputParameters params = _factory.getValidParams("MaterialStdVectorRealGradientAux");
71 params.set<AuxVariableName>("variable") = var_name;
72 params.set<MaterialPropertyName>("property") = _prop[val];
73 params.set<unsigned int>("component") = x;
74 params.set<unsigned int>("index") = op;
75 params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
76 _problem->addAuxKernel("MaterialStdVectorRealGradientAux", "grad_" + var_name, params);
77 }
78 }
79
80 if (isParamValid("divergence_variable"))
81 {
82 if (isParamValid("divergence_property"))
83 {
84 InputParameters params = _factory.getValidParams("MaterialStdVectorAux");
85 params.set<AuxVariableName>("variable") = _div_var;
86 params.set<MaterialPropertyName>("property") = _div_prop;
87 params.set<unsigned int>("index") = op;
88 params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
89 _problem->addAuxKernel("MaterialStdVectorAux", "div_" + Moose::stringify(op), params);
90 }
91 else
92 mooseError("Must specify a divergence_property name along with divergence_variable name");
93 }
94 }
95}
const std::vector< double > x
registerMooseAction("PhaseFieldApp", MatVecRealGradAuxKernelAction, "add_aux_kernel")
unsigned int dim
static InputParameters validParams()
std::shared_ptr< FEProblemBase > & _problem
InputParameters getValidParams(const std::string &name) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
MatVecRealGradAuxKernelAction(const InputParameters &params)
const std::vector< MaterialPropertyName > _prop
void mooseDeprecated(Args &&... args) const
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
Factory & _factory
std::string stringify(const T &t)