https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MaterialVectorAuxKernelAction.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", MaterialVectorAuxKernelAction, "add_aux_kernel");
16
19{
22 "Outputs all components of the standard vector-valued properties specified");
23 params.addRequiredParam<unsigned int>(
24 "grain_num", "Value that specifies the number of grains to create aux kernels for.");
25 params.addRequiredParam<std::vector<std::string>>(
26 "variable_base", "Vector specifies the base name of the variables.");
27 params.addRequiredParam<std::vector<MaterialPropertyName>>("property",
28 "The material property names.");
29 params.addParam<bool>(
30 "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels.");
31 return params;
32}
33
35 : Action(params),
36 _grain_num(getParam<unsigned int>("grain_num")),
37 _var_name_base(getParam<std::vector<std::string>>("variable_base")),
38 _num_var(_var_name_base.size()),
39 _prop(getParam<std::vector<MaterialPropertyName>>("property")),
40 _num_prop(_prop.size())
41{
42}
43
44void
46{
47 if (_num_prop != _num_var)
48 paramError("property", "variable_base and property must be vectors of the same size");
49
50 for (unsigned int gr = 0; gr < _grain_num; ++gr)
51 for (unsigned int val = 0; val < _num_var; ++val)
52 {
53 std::string var_name = _var_name_base[val] + Moose::stringify(gr);
54
55 InputParameters params = _factory.getValidParams("MaterialStdVectorAux");
56 params.set<AuxVariableName>("variable") = var_name;
57 params.set<MaterialPropertyName>("property") = _prop[val];
58 params.set<unsigned int>("index") = gr;
59 params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
60
61 std::string aux_kernel_name = var_name;
62 _problem->addAuxKernel("MaterialStdVectorAux", aux_kernel_name, params);
63 }
64}
registerMooseAction("PhaseFieldApp", MaterialVectorAuxKernelAction, "add_aux_kernel")
void ErrorVector unsigned int
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)
const unsigned int _grain_num
number of grains to create
const unsigned int _num_prop
number of properties
const std::vector< std::string > & _var_name_base
base name for the auxvariables
MaterialVectorAuxKernelAction(const InputParameters &params)
const unsigned int _num_var
number of auxvariables
const std::vector< MaterialPropertyName > & _prop
list of material properties to be used
void paramError(const std::string &param, Args... args) const
Factory & _factory
std::string stringify(const T &t)