https://mooseframework.inl.gov
PolycrystalElasticDrivingForceAction.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 "FEProblem.h"
13 #include "Conversion.h"
14 
15 registerMooseAction("PhaseFieldApp", PolycrystalElasticDrivingForceAction, "add_kernel");
16 
19 {
21  params.addClassDescription("Action that adds the elastic driving force for each order parameter");
22  params.addRequiredParam<unsigned int>("op_num", "specifies the number of grains to create");
23  params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables");
24  params.addParam<bool>(
25  "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels");
26  params.addParam<std::string>("base_name",
27  "Optional parameter that allows the user to define "
28  "multiple mechanics material systems on the same "
29  "block, i.e. for multiple phases");
30  return params;
31 }
32 
34  const InputParameters & params)
35  : Action(params),
36  _op_num(getParam<unsigned int>("op_num")),
37  _var_name_base(getParam<std::string>("var_name_base")),
38  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
39  _elasticity_tensor_name(_base_name + "elasticity_tensor")
40 {
41 }
42 
43 void
45 {
46 #ifdef DEBUG
47  Moose::err << "Inside the PolycrystalElasticDrivingForceAction Object\n";
48  Moose::err << "var name base:" << _var_name_base << std::flush;
49 #endif
50 
51  for (unsigned int op = 0; op < _op_num; ++op)
52  {
53  // Create variable name
54  std::string var_name = _var_name_base + Moose::stringify(op);
55 
56  // Create Stiffness derivative name
57  MaterialPropertyName D_stiff_name =
59 
60  // Set name of kernel being created
61  std::string kernel_type = "ACGrGrElasticDrivingForce";
62 
63  // Set the actual parameters for the kernel
64  InputParameters poly_params = _factory.getValidParams(kernel_type);
65  poly_params.set<NonlinearVariableName>("variable") = var_name;
66  poly_params.set<MaterialPropertyName>("D_tensor_name") = D_stiff_name;
67  poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
68 
69  std::string kernel_name = "AC_ElasticDrivingForce_" + var_name;
70 
71  // Create kernel
72  _problem->addKernel(kernel_type, kernel_name, poly_params);
73  }
74 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const unsigned int _op_num
Number of order parameters used in the model.
T & set(const std::string &name, bool quiet_mode=false)
InputParameters getValidParams(const std::string &name) const
const MaterialPropertyName derivativePropertyNameFirst(const MaterialPropertyName &base, const SymbolName &c1) const
std::string _var_name_base
Base name for the order parameters.
void addRequiredParam(const std::string &name, const std::string &doc_string)
Factory & _factory
Action that adds the elastic driving force for each order parameter.
static InputParameters validParams()
std::string stringify(const T &t)
void addClassDescription(const std::string &doc_string)
std::shared_ptr< FEProblemBase > & _problem
PolycrystalElasticDrivingForceAction(const InputParameters &params)
registerMooseAction("PhaseFieldApp", PolycrystalElasticDrivingForceAction, "add_kernel")
void ErrorVector unsigned int