www.mooseframework.org
TensorMechanicsActionBase.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 
12 #include "ActionWarehouse.h"
13 #include "ComputeFiniteStrain.h"
14 
15 // map tensor name shortcuts to tensor material property names
16 const std::map<std::string, std::string> TensorMechanicsActionBase::_ranktwoaux_table = {
17  {"strain", "total_strain"},
18  {"stress", "stress"},
19  {"elastic_strain", "elastic_strain"},
20  {"plastic_strain", "plastic_strain"},
21  {"creep_strain", "creep_strain"}};
22 const std::vector<char> TensorMechanicsActionBase::_component_table = {'x', 'y', 'z'};
23 // map aux variable name prefixes to RanTwoScalarAux option and list of permitted tensor name
24 // shortcuts
25 const std::map<std::string, std::pair<std::string, std::vector<std::string>>>
27  {"vonmises", {"VonMisesStress", {"stress"}}},
28  {"hydrostatic", {"Hydrostatic", {"stress"}}},
29  {"max_principal", {"MaxPrincipal", {"stress"}}},
30  {"mid_principal", {"MidPrincipal", {"stress"}}},
31  {"min_principal", {"MinPrincipal", {"stress"}}},
32  {"firstinv", {"FirstInvariant", {"stress", "strain"}}},
33  {"secondinv", {"SecondInvariant", {"stress", "strain"}}},
34  {"thirdinv", {"ThirdInvariant", {"stress", "strain"}}}};
35 
37 
38 InputParameters
40 {
41  InputParameters params = Action::validParams();
42 
43  params.addRequiredParam<std::vector<VariableName>>(
44  "displacements", "The nonlinear displacement variables for the problem");
45  params.addParam<VariableName>("temperature", "The temperature");
46 
47  MooseEnum strainType("SMALL FINITE", "SMALL");
48  params.addParam<MooseEnum>("strain", strainType, "Strain formulation");
49  params.addParam<bool>("incremental", "Use incremental or total strain");
50 
51  params.addParam<std::string>("base_name", "Material property base name");
52  params.addParam<bool>(
53  "volumetric_locking_correction", false, "Flag to correct volumetric locking");
54  params.addParam<bool>(
55  "use_finite_deform_jacobian", false, "Jacobian for corrotational finite strain");
56  params.addParam<bool>(
57  "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels");
58  params.addParam<bool>("add_variables", false, "Add the displacement variables");
59  params.addParam<std::vector<MaterialPropertyName>>(
60  "eigenstrain_names", "List of eigenstrains to be applied in this strain calculation");
61  params.addParam<bool>("use_automatic_differentiation",
62  false,
63  "Flag to use automatic differentiation (AD) objects when possible");
64  // Global Strain
65  params.addParam<MaterialPropertyName>(
66  "global_strain",
67  "Name of the global strain material to be applied in this strain calculation. "
68  "The global strain tensor is constant over the whole domain and allows visualization "
69  "of the deformed shape with the periodic BC");
70 
71  // Advanced
72  params.addParam<std::vector<AuxVariableName>>("save_in", "The displacement residuals");
73  params.addParam<std::vector<AuxVariableName>>("diag_save_in",
74  "The displacement diagonal preconditioner terms");
75  params.addParam<MooseEnum>("decomposition_method",
77  "Methods to calculate the finite strain and rotation increments");
78  params.addParamNamesToGroup("save_in diag_save_in", "Advanced");
79 
80  // Planar Formulation
81  MooseEnum planarFormulationType("NONE WEAK_PLANE_STRESS PLANE_STRAIN GENERALIZED_PLANE_STRAIN",
82  "NONE");
83  params.addParam<MooseEnum>(
84  "planar_formulation", planarFormulationType, "Out-of-plane stress/strain formulation");
85  params.addParam<VariableName>("scalar_out_of_plane_strain",
86  "Scalar variable for the out-of-plane strain (in y "
87  "direction for 1D Axisymmetric or in z direction for 2D "
88  "Cartesian problems)");
89  params.addParam<VariableName>("out_of_plane_strain",
90  "Variable for the out-of-plane strain for plane stress models");
91  MooseEnum outOfPlaneDirection("x y z", "z");
92  params.addParam<MooseEnum>(
93  "out_of_plane_direction", outOfPlaneDirection, "The direction of the out-of-plane strain.");
94  params.addParam<FunctionName>("out_of_plane_pressure",
95  "0",
96  "Function used to prescribe pressure in the out-of-plane direction "
97  "(y for 1D Axisymmetric or z for 2D Cartesian problems)");
98  params.addParam<Real>("pressure_factor", 1.0, "Scale factor applied to prescribed pressure");
99  params.addParamNamesToGroup("planar_formulation scalar_out_of_plane_strain out_of_plane_pressure "
100  "pressure_factor out_of_plane_direction out_of_plane_strain",
101  "Out-of-plane stress/strain");
102 
103  // Output
104  params.addParam<MultiMooseEnum>("generate_output",
106  "Add scalar quantity output for stress and/or strain");
107  params.addParamNamesToGroup("generate_output", "Output");
108 
109  return params;
110 }
111 
112 TensorMechanicsActionBase::TensorMechanicsActionBase(const InputParameters & parameters)
113  : Action(parameters), _use_ad(getParam<bool>("use_automatic_differentiation"))
114 {
115  // check if a container block with common parameters is found
116  auto action = _awh.getActions<CommonTensorMechanicsAction>();
117  if (action.size() == 1)
118  _pars.applyParameters(action[0]->parameters());
119 
120  // append additional_generate_output
121  if (isParamValid("additional_generate_output"))
122  {
123  MultiMooseEnum generate_output = getParam<MultiMooseEnum>("generate_output");
124  MultiMooseEnum additional_generate_output =
125  getParam<MultiMooseEnum>("additional_generate_output");
126  for (auto & output : additional_generate_output)
127  generate_output.push_back(output);
128 
129  _pars.set<MultiMooseEnum>("generate_output") = generate_output;
130  }
131 }
132 
133 MultiMooseEnum
135 {
136  std::string options = "";
137  for (auto & r2a : _ranktwoaux_table)
138  for (unsigned int a = 0; a < 3; ++a)
139  for (unsigned int b = 0; b < 3; ++b)
140  options += (options == "" ? "" : " ") + r2a.first + '_' + _component_table[a] +
141  _component_table[b];
142 
143  for (auto & r2sa : _ranktwoscalaraux_table)
144  for (auto & t : r2sa.second.second)
145  options += " " + r2sa.first + "_" + t;
146 
147  return MultiMooseEnum(options);
148 }
TensorMechanicsActionBase::TensorMechanicsActionBase
TensorMechanicsActionBase(const InputParameters &params)
Definition: TensorMechanicsActionBase.C:112
TensorMechanicsActionBase::_component_table
static const std::vector< char > _component_table
Definition: TensorMechanicsActionBase.h:31
TensorMechanicsActionBase
Definition: TensorMechanicsActionBase.h:19
TensorMechanicsActionBase::validParams
static InputParameters validParams()
Definition: TensorMechanicsActionBase.C:39
TensorMechanicsActionBase::_ranktwoaux_table
static const std::map< std::string, std::string > _ranktwoaux_table
table data for output generation
Definition: TensorMechanicsActionBase.h:30
defineLegacyParams
defineLegacyParams(TensorMechanicsActionBase)
TensorMechanicsActionBase.h
ComputeFiniteStrain.h
validParams
InputParameters validParams()
TensorMechanicsActionBase::_ranktwoscalaraux_table
static const std::map< std::string, std::pair< std::string, std::vector< std::string > > > _ranktwoscalaraux_table
Definition: TensorMechanicsActionBase.h:33
CommonTensorMechanicsAction
Store common tensor mechanics parameters.
Definition: CommonTensorMechanicsAction.h:22
TensorMechanicsActionBase::outputPropertiesType
static MultiMooseEnum outputPropertiesType()
Definition: TensorMechanicsActionBase.C:134
CommonTensorMechanicsAction.h
ComputeFiniteStrain::decompositionType
static MooseEnum decompositionType()
Definition: ComputeFiniteStrain.C:17