Line data Source code
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 :
10 : #include "TensorMechanicsActionBase.h"
11 : #include "CommonTensorMechanicsAction.h"
12 : #include "ActionWarehouse.h"
13 : #include "AddAuxVariableAction.h"
14 : #include "ComputeFiniteStrain.h"
15 : #include "MooseApp.h"
16 : #include "InputParameterWarehouse.h"
17 :
18 : // map tensor name shortcuts to tensor material property names
19 : std::map<std::string, std::string> TensorMechanicsActionBase::_rank_two_cartesian_component_table =
20 : {{"strain", "total_strain"},
21 : {"mechanical_strain", "mechanical_strain"},
22 : {"stress", "stress"},
23 : {"cauchy_stress", "cauchy_stress"},
24 : {"deformation_gradient", "deformation_gradient"},
25 : {"pk1_stress", "pk1_stress"},
26 : {"pk2_stress", "pk2_stress"},
27 : {"small_stress", "small_stress"},
28 : {"elastic_strain", "elastic_strain"},
29 : {"plastic_strain", "plastic_strain"},
30 : {"creep_strain", "creep_strain"},
31 : {"creep_stress", "creep_stress"}};
32 : const std::vector<char> TensorMechanicsActionBase::_component_table = {'x', 'y', 'z'};
33 :
34 : // map aux variable name prefixes to RankTwoInvariant option and list of permitted tensor name
35 : // shortcuts
36 : const std::map<std::string, std::pair<std::string, std::vector<std::string>>>
37 : TensorMechanicsActionBase::_rank_two_invariant_table = {
38 : {"vonmises", {"VonMisesStress", {"stress", "cauchy_stress", "pk1_stress", "pk2_stress"}}},
39 : {"effective", {"EffectiveStrain", {"plastic_strain", "creep_strain"}}},
40 : {"hydrostatic",
41 : {"Hydrostatic", {"stress", "cauchy_stress", "pk1_stress", "pk2_stress", "small_stress"}}},
42 : {"l2norm",
43 : {"L2norm",
44 : {"mechanical_strain",
45 : "stress",
46 : "cauchy_stress",
47 : "pk1_stress",
48 : "strain",
49 : "elastic_strain",
50 : "plastic_strain",
51 : "creep_strain"}}},
52 : {"volumetric", {"VolumetricStrain", {"mechanical_strain", "strain"}}},
53 : {"firstinv",
54 : {"FirstInvariant",
55 : {"stress", "cauchy_stress", "pk1_stress", "pk2_stress", "small_stress", "strain"}}},
56 : {"secondinv",
57 : {"SecondInvariant",
58 : {"stress", "cauchy_stress", "pk1_stress", "pk2_stress", "small_stress", "strain"}}},
59 : {"thirdinv",
60 : {"ThirdInvariant",
61 : {"stress", "cauchy_stress", "pk1_stress", "pk2_stress", "small_stress", "strain"}}},
62 : {"triaxiality",
63 : {"TriaxialityStress",
64 : {
65 : "stress",
66 : "cauchy_stress",
67 : "pk1_stress",
68 : "pk2_stress",
69 : "small_stress",
70 : }}},
71 : {"maxshear",
72 : {"MaxShear",
73 : {
74 : "stress",
75 : "cauchy_stress",
76 : "pk1_stress",
77 : "pk2_stress",
78 : "small_stress",
79 : }}},
80 : {"intensity",
81 : {"StressIntensity",
82 : {
83 : "stress",
84 : "cauchy_stress",
85 : "pk1_stress",
86 : "pk2_stress",
87 : "small_stress",
88 : }}},
89 : {"max_principal",
90 : {"MaxPrincipal",
91 : {"mechanical_strain",
92 : "stress",
93 : "cauchy_stress",
94 : "pk1_stress",
95 : "pk2_stress",
96 : "small_stress",
97 : "strain"}}},
98 : {"mid_principal",
99 : {"MidPrincipal",
100 : {"mechanical_strain",
101 : "stress",
102 : "cauchy_stress",
103 : "pk1_stress",
104 : "pk2_stress",
105 : "small_stress",
106 : "strain"}}},
107 : {"min_principal",
108 : {"MinPrincipal",
109 : {"mechanical_strain",
110 : "stress",
111 : "cauchy_stress",
112 : "pk1_stress",
113 : "pk2_stress",
114 : "small_stress",
115 : "strain"}}}};
116 :
117 : const std::map<std::string, std::pair<std::string, std::vector<std::string>>>
118 : TensorMechanicsActionBase::_rank_two_directional_component_table = {
119 : {"directional", {"Direction", {"stress", "strain"}}}};
120 :
121 : const std::map<std::string, std::pair<std::string, std::vector<std::string>>>
122 : TensorMechanicsActionBase::_rank_two_cylindrical_component_table = {
123 : {"axial",
124 : {"AxialStress", {"stress", "strain", "plastic_strain", "creep_strain", "elastic_strain"}}},
125 : {"hoop",
126 : {"HoopStress", {"stress", "strain", "plastic_strain", "creep_strain", "elastic_strain"}}},
127 : {"radial", {"RadialStress", {"stress", "strain"}}}};
128 :
129 : const std::map<std::string, std::pair<std::string, std::vector<std::string>>>
130 : TensorMechanicsActionBase::_rank_two_spherical_component_table = {
131 : {"spherical_hoop",
132 : {"HoopStress", {"stress", "strain", "plastic_strain", "creep_strain", "elastic_strain"}}},
133 : {"spherical_radial", {"RadialStress", {"stress", "strain"}}}};
134 :
135 : InputParameters
136 5489 : TensorMechanicsActionBase::validParams()
137 : {
138 5489 : InputParameters params = Action::validParams();
139 :
140 10978 : params.addRequiredParam<std::vector<VariableName>>(
141 : "displacements", "The nonlinear displacement variables for the problem");
142 10978 : params.addParam<std::vector<VariableName>>("temperature", "The temperature");
143 :
144 10978 : MooseEnum strainType("SMALL FINITE", "SMALL");
145 10978 : params.addParam<MooseEnum>("strain", strainType, "Strain formulation");
146 10978 : params.addParam<bool>("incremental",
147 : "Use incremental or total strain (if not explicitly specified this "
148 : "defaults to incremental for finite strain and total for small strain)");
149 :
150 10978 : params.addParam<std::string>("base_name", "Material property base name");
151 10978 : params.addParam<bool>(
152 10978 : "volumetric_locking_correction", false, "Flag to correct volumetric locking");
153 10978 : params.addParam<bool>(
154 10978 : "use_finite_deform_jacobian", false, "Jacobian for corrotational finite strain");
155 10978 : params.addParam<bool>("add_variables", false, "Add the displacement variables");
156 10978 : params.addParam<std::vector<MaterialPropertyName>>(
157 : "eigenstrain_names", {}, "List of eigenstrains to be applied in this strain calculation");
158 10978 : params.addParam<bool>("use_automatic_differentiation",
159 10978 : false,
160 : "Flag to use automatic differentiation (AD) objects when possible");
161 : // Global Strain
162 10978 : params.addParam<MaterialPropertyName>(
163 : "global_strain",
164 : "Name of the global strain material to be applied in this strain calculation. "
165 : "The global strain tensor is constant over the whole domain and allows visualization "
166 : "of the deformed shape with the periodic BC");
167 :
168 : // Advanced
169 10978 : params.addParam<std::vector<AuxVariableName>>("save_in", {}, "The displacement residuals");
170 10978 : params.addParam<std::vector<AuxVariableName>>(
171 : "diag_save_in", {}, "The displacement diagonal preconditioner terms");
172 10978 : params.addParam<MooseEnum>("decomposition_method",
173 10978 : ComputeFiniteStrain::decompositionType(),
174 : "Methods to calculate the finite strain and rotation increments");
175 10978 : params.addParamNamesToGroup("save_in diag_save_in", "Advanced");
176 :
177 : // Planar Formulation
178 : MooseEnum planarFormulationType("NONE WEAK_PLANE_STRESS PLANE_STRAIN GENERALIZED_PLANE_STRAIN",
179 10978 : "NONE");
180 10978 : params.addParam<MooseEnum>(
181 : "planar_formulation", planarFormulationType, "Out-of-plane stress/strain formulation");
182 10978 : params.addParam<VariableName>("scalar_out_of_plane_strain",
183 : "Scalar variable for the out-of-plane strain (in y "
184 : "direction for 1D Axisymmetric or in z direction for 2D "
185 : "Cartesian problems)");
186 10978 : params.addParam<VariableName>("out_of_plane_strain",
187 : "Variable for the out-of-plane strain for plane stress models");
188 10978 : MooseEnum outOfPlaneDirection("x y z", "z");
189 10978 : params.addParam<MooseEnum>(
190 : "out_of_plane_direction", outOfPlaneDirection, "The direction of the out-of-plane strain.");
191 10978 : params.addDeprecatedParam<FunctionName>(
192 : "out_of_plane_pressure",
193 : "Function used to prescribe pressure (applied toward the body) in the out-of-plane direction "
194 : "(y for 1D Axisymmetric or z for 2D Cartesian problems)",
195 : "This has been replaced by 'out_of_plane_pressure_function'");
196 10978 : params.addParam<FunctionName>(
197 : "out_of_plane_pressure_function",
198 : "Function used to prescribe pressure (applied toward the body) in the out-of-plane direction "
199 : "(y for 1D Axisymmetric or z for 2D Cartesian problems)");
200 10978 : params.addParam<Real>(
201 : "pressure_factor",
202 : "Scale factor applied to prescribed out-of-plane pressure (both material and function)");
203 10978 : params.addParam<MaterialPropertyName>("out_of_plane_pressure_material",
204 : "0",
205 : "Material used to prescribe pressure (applied toward the "
206 : "body) in the out-of-plane direction");
207 10978 : params.addParamNamesToGroup("planar_formulation scalar_out_of_plane_strain out_of_plane_pressure "
208 : "out_of_plane_pressure_material out_of_plane_pressure_function "
209 : "pressure_factor out_of_plane_direction out_of_plane_strain",
210 : "Out-of-plane stress/strain");
211 :
212 : // Output
213 10978 : params.addParam<MultiMooseEnum>("generate_output",
214 10978 : TensorMechanicsActionBase::outputPropertiesType(),
215 : "Add scalar quantity output for stress and/or strain");
216 :
217 10978 : params.addParam<MultiMooseEnum>(
218 : "material_output_order",
219 10978 : TensorMechanicsActionBase::materialOutputOrders(),
220 : "Specifies the order of the FE shape function to use for this variable.");
221 :
222 10978 : params.addParam<MultiMooseEnum>(
223 : "material_output_family",
224 10978 : TensorMechanicsActionBase::materialOutputFamilies(),
225 : "Specifies the family of FE shape functions to use for this variable.");
226 10978 : params.addParamNamesToGroup("generate_output material_output_order material_output_family",
227 : "Output");
228 10978 : params.addParam<bool>("verbose", false, "Display extra information.");
229 :
230 10978 : params.addParam<bool>("new_system",
231 10978 : false,
232 : "If true use the new "
233 : "LagrangianStressDiverence kernels.");
234 :
235 10978 : MooseEnum formulationType("TOTAL UPDATED", "TOTAL");
236 10978 : params.addParam<MooseEnum>("formulation",
237 : formulationType,
238 : "Select between the total Lagrangian (TOTAL) "
239 : "and updated Lagrangian (UPDATED) formulations "
240 : "for the new kernel system.");
241 :
242 5489 : return params;
243 5489 : }
244 :
245 3228 : TensorMechanicsActionBase::TensorMechanicsActionBase(const InputParameters & parameters)
246 6456 : : Action(parameters), _use_ad(getParam<bool>("use_automatic_differentiation"))
247 : {
248 3228 : const auto & params = _app.getInputParameterWarehouse().getInputParameters();
249 3228 : InputParameters & pars(*(params.find(uniqueActionName())->second.get()));
250 :
251 : // check if a container block with common parameters is found
252 3228 : auto action = _awh.getActions<CommonTensorMechanicsAction>();
253 3228 : if (action.size() == 1)
254 2309 : pars.applyParameters(action[0]->parameters());
255 :
256 : // append additional_generate_output
257 6456 : if (isParamValid("additional_generate_output"))
258 : {
259 24 : MultiMooseEnum generate_output = getParam<MultiMooseEnum>("generate_output");
260 : MultiMooseEnum additional_generate_output =
261 24 : getParam<MultiMooseEnum>("additional_generate_output");
262 :
263 24 : MultiMooseEnum material_output_order = getParam<MultiMooseEnum>("material_output_order");
264 : MultiMooseEnum additional_material_output_order =
265 24 : getParam<MultiMooseEnum>("additional_material_output_order");
266 :
267 24 : MultiMooseEnum material_output_family = getParam<MultiMooseEnum>("material_output_family");
268 : MultiMooseEnum additional_material_output_family =
269 36 : getParam<MultiMooseEnum>("additional_material_output_family");
270 :
271 24 : for (auto & output : additional_generate_output)
272 24 : generate_output.push_back(output);
273 12 : for (auto & order : additional_material_output_order)
274 0 : material_output_order.push_back(order);
275 12 : for (auto & family : additional_material_output_family)
276 0 : material_output_family.push_back(family);
277 :
278 12 : pars.set<MultiMooseEnum>("generate_output") = generate_output;
279 12 : pars.set<MultiMooseEnum>("material_output_order") = material_output_order;
280 12 : pars.set<MultiMooseEnum>("material_output_family") = material_output_family;
281 12 : }
282 3228 : }
283 :
284 : MultiMooseEnum
285 8717 : TensorMechanicsActionBase::materialOutputOrders()
286 : {
287 8717 : auto orders = AddAuxVariableAction::getAuxVariableOrders().getRawNames();
288 :
289 17434 : return MultiMooseEnum(orders);
290 : }
291 :
292 : MultiMooseEnum
293 8717 : TensorMechanicsActionBase::materialOutputFamilies()
294 : {
295 17434 : return MultiMooseEnum("MONOMIAL LAGRANGE");
296 : }
297 :
298 : MultiMooseEnum
299 8717 : TensorMechanicsActionBase::outputPropertiesType()
300 : {
301 8717 : std::string options = "";
302 113321 : for (auto & r2tc : _rank_two_cartesian_component_table)
303 418416 : for (unsigned int a = 0; a < 3; ++a)
304 1255248 : for (unsigned int b = 0; b < 3; ++b)
305 2815591 : options += (options == "" ? "" : " ") + r2tc.first + '_' + _component_table[a] +
306 941436 : _component_table[b];
307 :
308 130755 : for (auto & r2i : _rank_two_invariant_table)
309 775813 : for (auto & t : r2i.second.second)
310 1961325 : options += " " + r2i.first + "_" + t;
311 :
312 17434 : for (auto & r2sdc : _rank_two_directional_component_table)
313 26151 : for (auto & r : r2sdc.second.second)
314 52302 : options += " " + r2sdc.first + "_" + r;
315 :
316 34868 : for (auto & r2cc : _rank_two_cylindrical_component_table)
317 130755 : for (auto & r : r2cc.second.second)
318 313812 : options += " " + r2cc.first + "_" + r;
319 :
320 26151 : for (auto & r2sc : _rank_two_spherical_component_table)
321 78453 : for (auto & r : r2sc.second.second)
322 183057 : options += " " + r2sc.first + "_" + r;
323 :
324 17434 : return MultiMooseEnum(options, "", true);
325 : }
326 :
327 : void
328 0 : TensorMechanicsActionBase::addCartesianComponentOutput(const std::string & enum_name,
329 : const std::string & prop_name)
330 : {
331 0 : if (prop_name.empty())
332 : // the enum name is the actual tensor material property name
333 0 : _rank_two_cartesian_component_table.emplace(enum_name, enum_name);
334 : else
335 : // supply a different name for the enum options (this is done for
336 : // 'strain' -> 'mechanical_strain' in the TMA)
337 0 : _rank_two_cartesian_component_table.emplace(enum_name, prop_name);
338 0 : }
|