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