www.mooseframework.org
ComputeStrainBase.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 /****************************************************************/
7 
8 #include "ComputeStrainBase.h"
9 #include "MooseMesh.h"
10 #include "Assembly.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<Material>();
17  params.addRequiredCoupledVar(
18  "displacements",
19  "The displacements appropriate for the simulation geometry and coordinate system");
20  params.addParam<std::string>("base_name",
21  "Optional parameter that allows the user to define "
22  "multiple mechanics material systems on the same "
23  "block, i.e. for multiple phases");
24  params.addParam<bool>(
25  "volumetric_locking_correction", false, "Flag to correct volumetric locking");
26  params.addParam<std::vector<MaterialPropertyName>>(
27  "eigenstrain_names", "List of eigenstrains to be applied in this strain calculation");
28  params.suppressParameter<bool>("use_displaced_mesh");
29  return params;
30 }
31 
32 ComputeStrainBase::ComputeStrainBase(const InputParameters & parameters)
33  : DerivativeMaterialInterface<Material>(parameters),
34  _ndisp(coupledComponents("displacements")),
35  _disp(3),
36  _grad_disp(3),
37  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
38  _mechanical_strain(declareProperty<RankTwoTensor>(_base_name + "mechanical_strain")),
39  _total_strain(declareProperty<RankTwoTensor>(_base_name + "total_strain")),
40  _eigenstrain_names(getParam<std::vector<MaterialPropertyName>>("eigenstrain_names")),
41  _eigenstrains(_eigenstrain_names.size()),
42  _volumetric_locking_correction(getParam<bool>("volumetric_locking_correction")),
43  _current_elem_volume(_assembly.elemVolume())
44 {
45  for (unsigned int i = 0; i < _eigenstrains.size(); ++i)
46  {
48  _eigenstrains[i] = &getMaterialProperty<RankTwoTensor>(_eigenstrain_names[i]);
49  }
50 
51  // Checking for consistency between mesh size and length of the provided displacements vector
52  if (_ndisp != _mesh.dimension())
53  mooseError(
54  "The number of variables supplied in 'displacements' must match the mesh dimension.");
55 
56  // fetch coupled variables and gradients (as stateful properties if necessary)
57  for (unsigned int i = 0; i < _ndisp; ++i)
58  {
59  _disp[i] = &coupledValue("displacements", i);
60  _grad_disp[i] = &coupledGradient("displacements", i);
61  }
62 
63  // set unused dimensions to zero
64  for (unsigned i = _ndisp; i < 3; ++i)
65  {
66  _disp[i] = &_zero;
67  _grad_disp[i] = &_grad_zero;
68  }
69 
70  if (_ndisp == 1 && _volumetric_locking_correction)
71  mooseError("Volumetric locking correction have to be set to false for 1-D problems.");
72 
73  if (getParam<bool>("use_displaced_mesh"))
74  mooseError("The strain calculator needs to run on the undisplaced mesh.");
75 }
76 
77 void
79 {
80  _mechanical_strain[_qp].zero();
81  _total_strain[_qp].zero();
82 }
virtual void initQpStatefulProperties() override
ComputeStrainBase(const InputParameters &parameters)
std::string _base_name
std::vector< const VariableValue * > _disp
MaterialProperty< RankTwoTensor > & _mechanical_strain
unsigned int _ndisp
Coupled displacement variables.
std::vector< MaterialPropertyName > _eigenstrain_names
MaterialProperty< RankTwoTensor > & _total_strain
std::vector< const MaterialProperty< RankTwoTensor > * > _eigenstrains
InputParameters validParams< ComputeStrainBase >()
std::vector< const VariableGradient * > _grad_disp