www.mooseframework.org
ADComputeStrainBase.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 
10 #include "ADComputeStrainBase.h"
11 #include "RankTwoTensor.h"
12 #include "MooseMesh.h"
13 #include "Assembly.h"
14 
17  ADMaterial,
18  params.addRequiredCoupledVar(
19  "displacements",
20  "The displacements appropriate for the simulation geometry and coordinate system");
21  params.addParam<std::string>("base_name",
22  "Optional parameter that allows the user to define "
23  "multiple mechanics material systems on the same "
24  "block, i.e. for multiple phases");
25  params.addParam<bool>("volumetric_locking_correction",
26  false,
27  "Flag to correct volumetric locking");
28  params.addParam<std::vector<MaterialPropertyName>>(
29  "eigenstrain_names", "List of eigenstrains to be applied in this strain calculation");
30  params.addParam<MaterialPropertyName>("global_strain",
31  "Optional material property holding a global strain "
32  "tensor applied to the mesh as a whole");
33  params.suppressParameter<bool>("use_displaced_mesh"););
34 
35 template <ComputeStage compute_stage>
37  : ADMaterial<compute_stage>(parameters),
38  _ndisp(coupledComponents("displacements")),
39  _disp(3),
40  _grad_disp(3),
41  _base_name(isParamValid("base_name") ? adGetParam<std::string>("base_name") + "_" : ""),
42  _mechanical_strain(adDeclareADProperty<RankTwoTensor>(_base_name + "mechanical_strain")),
43  _total_strain(adDeclareADProperty<RankTwoTensor>(_base_name + "total_strain")),
44  _eigenstrain_names(adGetParam<std::vector<MaterialPropertyName>>("eigenstrain_names")),
45  _eigenstrains(_eigenstrain_names.size()),
46  _global_strain(isParamValid("global_strain")
47  ? &adGetADMaterialProperty<RankTwoTensor>(_base_name + "global_strain")
48  : nullptr),
49  _volumetric_locking_correction(adGetParam<bool>("volumetric_locking_correction") &&
50  !this->isBoundaryMaterial()),
51  _current_elem_volume(_assembly.elemVolume())
52 {
53  for (unsigned int i = 0; i < _eigenstrains.size(); ++i)
54  {
56  _eigenstrains[i] = &adGetADMaterialProperty<RankTwoTensor>(_eigenstrain_names[i]);
57  }
58 
60  paramError("volumetric_locking_correction", "has to be set to false for 1-D problems.");
61 
62  if (adGetParam<bool>("use_displaced_mesh"))
63  paramError("use_displaced_mesh", "The strain calculator needs to run on the undisplaced mesh.");
64 }
65 
66 template <ComputeStage compute_stage>
67 void
69 {
70  displacementIntegrityCheck();
71  // fetch coupled variables and gradients (as stateful properties if necessary)
72  for (unsigned int i = 0; i < _ndisp; ++i)
73  {
74  _disp[i] = &adCoupledValue("displacements", i);
75  _grad_disp[i] = &adCoupledGradient("displacements", i);
76  }
77 
78  // set unused dimensions to zero
79  for (unsigned i = _ndisp; i < 3; ++i)
80  {
81  _disp[i] = &adZeroValue();
82  _grad_disp[i] = &adZeroGradient();
83  }
84 }
85 
86 template <ComputeStage compute_stage>
87 void
89 {
90  // Checking for consistency between mesh size and length of the provided displacements vector
91  if (_ndisp != _mesh.dimension())
92  paramError(
93  "displacements",
94  "The number of variables supplied in 'displacements' must match the mesh dimension.");
95 }
96 
97 template <ComputeStage compute_stage>
98 void
100 {
101  _mechanical_strain[_qp].zero();
102  _total_strain[_qp].zero();
103 }
104 
105 // explicit instantiation is required for AD base classes
adBaseClass(ADComputeStrainBase)
defineADValidParams(ADComputeStrainBase, ADMaterial, params.addRequiredCoupledVar("displacements", "The displacements appropriate for the simulation geometry and coordinate system");params.addParam< std::string >("base_name", "Optional parameter that allows the user to define " "multiple mechanics material systems on the same " "block, i.e. for multiple phases");params.addParam< bool >("volumetric_locking_correction", false, "Flag to correct volumetric locking");params.addParam< std::vector< MaterialPropertyName >>("eigenstrain_names", "List of eigenstrains to be applied in this strain calculation");params.addParam< MaterialPropertyName >("global_strain", "Optional material property holding a global strain " "tensor applied to the mesh as a whole");params.suppressParameter< bool >("use_displaced_mesh");)
std::vector< const ADMaterialProperty(RankTwoTensor) * > _eigenstrains
const bool _volumetric_locking_correction
const unsigned int _ndisp
Coupled displacement variables.
virtual void initQpStatefulProperties() override
std::vector< MaterialPropertyName > _eigenstrain_names
virtual void displacementIntegrityCheck()
ADComputeStrainBase(const InputParameters &parameters)
void initialSetup() override
ADADComputeStrainBase is the base class for strain tensors.