www.mooseframework.org
GeneralizedPlaneStrainAction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 
9 #include "Conversion.h"
10 #include "FEProblem.h"
11 #include "MooseMesh.h"
12 #include "NonlinearSystemBase.h"
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<Action>();
19  params.addClassDescription("Set up the GeneralizedPlaneStrain environment");
20  params.addRequiredParam<std::vector<NonlinearVariableName>>("displacements",
21  "The displacement variables");
22  params.addRequiredParam<NonlinearVariableName>("scalar_out_of_plane_strain",
23  "Scalar variable for the out-of-plane strain (in "
24  "y direction for 1D Axisymmetric or in z "
25  "direction for 2D Cartesian problems)");
26  params.addParam<NonlinearVariableName>("temperature", "The temperature variable");
27  params.addParam<FunctionName>("out_of_plane_pressure",
28  "0",
29  "Function used to prescribe pressure "
30  "in the out-of-plane direction (y "
31  "for 1D Axisymmetric or z for 2D "
32  "Cartesian problems)");
33  params.addParam<Real>("factor", 1.0, "Scale factor applied to prescribed pressure");
34  params.addParam<bool>("use_displaced_mesh", false, "Whether to use displaced mesh");
35  params.addParam<std::string>("base_name", "Material property base name");
36  params.addParam<std::vector<SubdomainName>>("block",
37  "The list of ids of the blocks (subdomain) "
38  "that the GeneralizedPlaneStrain kernels "
39  "will be applied to");
40 
41  return params;
42 }
43 
45  : Action(params),
46  _displacements(getParam<std::vector<NonlinearVariableName>>("displacements")),
47  _ndisp(_displacements.size())
48 {
49  if (_ndisp > 2)
50  mooseError("GeneralizedPlaneStrain only works for 1D axisymmetric or 2D generalized plane "
51  "strain cases!");
52 }
53 
54 void
56 {
57  // user object name
58  const std::string uo_name = _name + "_GeneralizedPlaneStrainUserObject";
59 
60  //
61  // Add off diagonal Jacobian kernels
62  //
63  if (_current_task == "add_kernel")
64  {
65  std::string k_type = "GeneralizedPlaneStrainOffDiag";
66  InputParameters params = _factory.getValidParams(k_type);
67 
68  params.applyParameters(parameters(), {"scalar_out_of_plane_strain"});
69  params.set<std::vector<VariableName>>("scalar_out_of_plane_strain") = {
70  getParam<NonlinearVariableName>("scalar_out_of_plane_strain")};
71 
72  // add off-diagonal jacobian kernels for the displacements
73  for (unsigned int i = 0; i < _ndisp; ++i)
74  {
75  std::string k_name = _name + "GeneralizedPlaneStrainOffDiag_disp" + Moose::stringify(i);
76  params.set<NonlinearVariableName>("variable") = _displacements[i];
77 
78  _problem->addKernel(k_type, k_name, params);
79  }
80 
81  // add temperature kernel only if temperature is a nonlinear variable (and not an auxvariable)
82  if (isParamValid("temperature"))
83  {
84  NonlinearVariableName temp = getParam<NonlinearVariableName>("temperature");
85  if (_problem->getNonlinearSystemBase().hasVariable(temp))
86  {
87  params.set<NonlinearVariableName>("temperature") = temp;
88 
89  std::string k_name = _name + "_GeneralizedPlaneStrainOffDiag_temp";
90  params.set<NonlinearVariableName>("variable") = temp;
91 
92  _problem->addKernel(k_type, k_name, params);
93  }
94  }
95  }
96 
97  //
98  // Add user object
99  //
100  else if (_current_task == "add_user_object")
101  {
102  std::string uo_type = "GeneralizedPlaneStrainUserObject";
103  InputParameters params = _factory.getValidParams(uo_type);
104 
105  params.applyParameters(parameters());
106  params.set<MultiMooseEnum>("execute_on") = "linear";
107 
108  _problem->addUserObject(uo_type, uo_name, params);
109  }
110 
111  //
112  // Add scalar kernel
113  //
114  else if (_current_task == "add_scalar_kernel")
115  {
116  std::string sk_type = "GeneralizedPlaneStrain";
117  InputParameters params = _factory.getValidParams(sk_type);
118 
119  params.set<NonlinearVariableName>("variable") =
120  getParam<NonlinearVariableName>("scalar_out_of_plane_strain");
121 
122  // set the UserObjectName from previously added UserObject
123  params.set<UserObjectName>("generalized_plane_strain") = uo_name;
124 
125  _problem->addScalarKernel(sk_type, _name + "_GeneralizedPlaneStrain", params);
126  }
127 }
std::vector< NonlinearVariableName > _displacements
InputParameters validParams< GeneralizedPlaneStrainAction >()
GeneralizedPlaneStrainAction(const InputParameters &params)