www.mooseframework.org
GeneralizedPlaneStrainAction.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 
12 #include "Conversion.h"
13 #include "FEProblem.h"
14 #include "MooseMesh.h"
15 #include "NonlinearSystemBase.h"
16 
17 registerMooseAction("TensorMechanicsApp", GeneralizedPlaneStrainAction, "add_scalar_kernel");
18 
19 registerMooseAction("TensorMechanicsApp", GeneralizedPlaneStrainAction, "add_kernel");
20 
21 registerMooseAction("TensorMechanicsApp", GeneralizedPlaneStrainAction, "add_user_object");
22 
24 
25 InputParameters
27 {
28  InputParameters params = Action::validParams();
29  params.addClassDescription("Set up the GeneralizedPlaneStrain environment");
30  params.addRequiredParam<std::vector<VariableName>>("displacements", "The displacement variables");
31  params.addRequiredParam<VariableName>("scalar_out_of_plane_strain",
32  "Scalar variable for the out-of-plane strain (in "
33  "y direction for 1D Axisymmetric or in z "
34  "direction for 2D Cartesian problems)");
35  params.addParam<VariableName>("temperature", "The temperature variable");
36  MooseEnum outOfPlaneDirection("x y z", "z");
37  params.addParam<MooseEnum>(
38  "out_of_plane_direction", outOfPlaneDirection, "The direction of the out-of-plane strain.");
39  params.addParam<FunctionName>("out_of_plane_pressure",
40  "0",
41  "Function used to prescribe pressure "
42  "in the out-of-plane direction (y "
43  "for 1D Axisymmetric or z for 2D "
44  "Cartesian problems)");
45  params.addParam<Real>("factor", 1.0, "Scale factor applied to prescribed pressure");
46  params.addParam<bool>("use_displaced_mesh", false, "Whether to use displaced mesh");
47  params.addParam<std::string>("base_name", "Material property base name");
48  params.addParam<std::vector<SubdomainName>>("block",
49  "The list of ids of the blocks (subdomain) "
50  "that the GeneralizedPlaneStrain kernels "
51  "will be applied to");
52  params.addParam<std::vector<TagName>>(
53  "extra_vector_tags",
54  "The tag names for extra vectors that residual data should be saved into");
55 
56  return params;
57 }
58 
60  : Action(params),
61  _displacements(getParam<std::vector<VariableName>>("displacements")),
62  _ndisp(_displacements.size()),
63  _out_of_plane_direction(getParam<MooseEnum>("out_of_plane_direction"))
64 {
65 }
66 
67 void
69 {
70  // user object name
71  const std::string uo_name = _name + "_GeneralizedPlaneStrainUserObject";
72 
73  //
74  // Add off diagonal Jacobian kernels
75  //
76  if (_current_task == "add_kernel")
77  {
78  std::string k_type = "GeneralizedPlaneStrainOffDiag";
79  InputParameters params = _factory.getValidParams(k_type);
80 
81  params.applyParameters(parameters(), {"scalar_out_of_plane_strain"});
82  params.set<std::vector<VariableName>>("scalar_out_of_plane_strain") = {
83  getParam<VariableName>("scalar_out_of_plane_strain")};
84 
85  // add off-diagonal jacobian kernels for the displacements
86  for (unsigned int i = 0; i < _ndisp; ++i)
87  {
88  if (_out_of_plane_direction == i)
89  continue;
90 
91  std::string k_name = _name + "GeneralizedPlaneStrainOffDiag_disp" + Moose::stringify(i);
92  params.set<NonlinearVariableName>("variable") = _displacements[i];
93 
94  _problem->addKernel(k_type, k_name, params);
95  }
96 
97  // add temperature kernel only if temperature is a nonlinear variable (and not an auxvariable)
98  if (isParamValid("temperature"))
99  {
100  VariableName temp = getParam<VariableName>("temperature");
101  if (_problem->getNonlinearSystemBase().hasVariable(temp))
102  {
103  params.set<VariableName>("temperature") = temp;
104 
105  std::string k_name = _name + "_GeneralizedPlaneStrainOffDiag_temp";
106  params.set<NonlinearVariableName>("variable") = temp;
107 
108  _problem->addKernel(k_type, k_name, params);
109  }
110  }
111  }
112 
113  //
114  // Add user object
115  //
116  else if (_current_task == "add_user_object")
117  {
118  std::string uo_type = "GeneralizedPlaneStrainUserObject";
119  InputParameters params = _factory.getValidParams(uo_type);
120 
121  params.applyParameters(parameters());
122  params.set<ExecFlagEnum>("execute_on") = EXEC_LINEAR;
123 
124  _problem->addUserObject(uo_type, uo_name, params);
125  }
126 
127  //
128  // Add scalar kernel
129  //
130  else if (_current_task == "add_scalar_kernel")
131  {
132  std::string sk_type = "GeneralizedPlaneStrain";
133  InputParameters params = _factory.getValidParams(sk_type);
134 
135  params.set<NonlinearVariableName>("variable") =
136  getParam<VariableName>("scalar_out_of_plane_strain");
137 
138  // set the UserObjectName from previously added UserObject
139  params.set<UserObjectName>("generalized_plane_strain") = uo_name;
140 
141  if (isParamValid("extra_vector_tags"))
142  params.set<std::vector<TagName>>("extra_vector_tags") =
143  getParam<std::vector<TagName>>("extra_vector_tags");
144 
145  _problem->addScalarKernel(sk_type, _name + "_GeneralizedPlaneStrain", params);
146  }
147 }
defineLegacyParams
defineLegacyParams(GeneralizedPlaneStrainAction)
GeneralizedPlaneStrainAction::GeneralizedPlaneStrainAction
GeneralizedPlaneStrainAction(const InputParameters &params)
Definition: GeneralizedPlaneStrainAction.C:59
GeneralizedPlaneStrainAction
Definition: GeneralizedPlaneStrainAction.h:19
GeneralizedPlaneStrainAction::_displacements
std::vector< VariableName > _displacements
Definition: GeneralizedPlaneStrainAction.h:29
GeneralizedPlaneStrainAction::validParams
static InputParameters validParams()
Definition: GeneralizedPlaneStrainAction.C:26
validParams
InputParameters validParams()
GeneralizedPlaneStrainAction::act
void act() override
Definition: GeneralizedPlaneStrainAction.C:68
GeneralizedPlaneStrainAction.h
GeneralizedPlaneStrainAction::_ndisp
unsigned int _ndisp
Definition: GeneralizedPlaneStrainAction.h:30
GeneralizedPlaneStrainAction::_out_of_plane_direction
const unsigned int _out_of_plane_direction
Definition: GeneralizedPlaneStrainAction.h:31
registerMooseAction
registerMooseAction("TensorMechanicsApp", GeneralizedPlaneStrainAction, "add_scalar_kernel")