https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MaterialVectorGradAuxKernelAction.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 "Parser.h"
13#include "Conversion.h"
14#include "FEProblem.h"
15#include "MooseMesh.h"
16
17registerMooseAction("PhaseFieldApp", MaterialVectorGradAuxKernelAction, "add_aux_kernel");
18
21{
23 params.addClassDescription("Outputs all components of the gradient of the real standard "
24 "vector-valued properties specified");
25 return params;
26}
27
32
33void
35{
36 if (_num_prop != _num_var)
37 paramError("property", "variable_base and property must be vectors of the same size");
38
39 // mesh dimension required for gradient variables
40 unsigned int dim = _mesh->dimension();
41 // For Specifying the components of the gradient terms
42 const std::vector<char> suffix = {'x', 'y', 'z'};
43
44 for (unsigned int gr = 0; gr < _grain_num; ++gr)
45 for (unsigned int val = 0; val < _num_var; ++val)
46 for (unsigned int x = 0; x < dim; ++x)
47 {
48 std::string var_name = _var_name_base[val] + Moose::stringify(gr) + "_" + suffix[x];
49
50 InputParameters params = _factory.getValidParams("MaterialStdVectorRealGradientAux");
51 params.set<AuxVariableName>("variable") = var_name;
52 params.set<MaterialPropertyName>("property") = _prop[val];
53 params.set<unsigned int>("component") = x;
54 params.set<unsigned int>("index") = gr;
55 params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
56
57 std::string aux_kernel_name = var_name;
58 _problem->addAuxKernel("MaterialStdVectorRealGradientAux", aux_kernel_name, params);
59 }
60}
const std::vector< double > x
registerMooseAction("PhaseFieldApp", MaterialVectorGradAuxKernelAction, "add_aux_kernel")
unsigned int dim
std::shared_ptr< MooseMesh > & _mesh
std::shared_ptr< FEProblemBase > & _problem
InputParameters getValidParams(const std::string &name) const
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
const unsigned int _num_var
number of auxvariables
const std::vector< MaterialPropertyName > & _prop
list of material properties to be used
MaterialVectorGradAuxKernelAction(const InputParameters &params)
void paramError(const std::string &param, Args... args) const
Factory & _factory
std::string stringify(const T &t)