https://mooseframework.inl.gov
ComputeLagrangianStrainBase.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 
11 
12 template <class G>
15 {
17 
18  params.addRequiredCoupledVar("displacements", "Displacement variables");
19  params.addParam<bool>(
20  "large_kinematics", false, "Use large displacement kinematics in the kernel.");
21  params.addParam<bool>("stabilize_strain", false, "Average the volumetric strains");
22  params.addParam<std::vector<MaterialPropertyName>>(
23  "eigenstrain_names", {}, "List of eigenstrains to account for");
24  params.addParam<std::vector<MaterialPropertyName>>(
25  "homogenization_gradient_names",
26  {},
27  "List of homogenization gradients to add to the displacement gradient");
28 
29  params.addParam<std::string>("base_name", "Material property base name");
30 
31  // We rely on this *not* having use_displaced mesh on
32  params.suppressParameter<bool>("use_displaced_mesh");
33 
34  return params;
35 }
36 
37 template <class G>
39  : Material(parameters),
40  _ndisp(coupledComponents("displacements")),
41  _disp(coupledValues("displacements")),
42  _grad_disp(coupledGradients("displacements")),
43  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
44  _large_kinematics(getParam<bool>("large_kinematics")),
45  _stabilize_strain(getParam<bool>("stabilize_strain")),
46  _eigenstrain_names(getParam<std::vector<MaterialPropertyName>>("eigenstrain_names")),
47  _eigenstrains(_eigenstrain_names.size()),
48  _eigenstrains_old(_eigenstrain_names.size()),
49  _total_strain(declareProperty<RankTwoTensor>(_base_name + "total_strain")),
50  _total_strain_old(getMaterialPropertyOld<RankTwoTensor>(_base_name + "total_strain")),
51  _mechanical_strain(declareProperty<RankTwoTensor>(_base_name + "mechanical_strain")),
52  _mechanical_strain_old(getMaterialPropertyOld<RankTwoTensor>(_base_name + "mechanical_strain")),
53  _strain_increment(declareProperty<RankTwoTensor>(_base_name + "strain_increment")),
54  _spatial_velocity_increment(
55  declareProperty<RankTwoTensor>(_base_name + "spatial_velocity_increment")),
56  _vorticity_increment(declareProperty<RankTwoTensor>(_base_name + "vorticity_increment")),
57  _F_ust(declareProperty<RankTwoTensor>(_base_name + "unstabilized_deformation_gradient")),
58  _F_avg(declareProperty<RankTwoTensor>(_base_name + "average_deformation_gradient")),
59  _F(declareProperty<RankTwoTensor>(_base_name + "deformation_gradient")),
60  _F_old(getMaterialPropertyOld<RankTwoTensor>(_base_name + "deformation_gradient")),
61  _F_inv(declareProperty<RankTwoTensor>(_base_name + "inverse_deformation_gradient")),
62  _f_inv(declareProperty<RankTwoTensor>(_base_name + "inverse_incremental_deformation_gradient")),
63  _homogenization_gradient_names(
64  getParam<std::vector<MaterialPropertyName>>("homogenization_gradient_names")),
65  _homogenization_contributions(_homogenization_gradient_names.size()),
66  _rotation_increment(declareProperty<RankTwoTensor>(_base_name + "rotation_increment"))
67 {
68  // Setup eigenstrains
69  for (auto i : make_range(_eigenstrain_names.size()))
70  {
71  _eigenstrains[i] = &getMaterialProperty<RankTwoTensor>(_eigenstrain_names[i]);
72  _eigenstrains_old[i] = &getMaterialPropertyOld<RankTwoTensor>(_eigenstrain_names[i]);
73  }
74 
75  // In the future maybe there is a reason to have more than one, but for now
76  if (_homogenization_gradient_names.size() > 1)
77  mooseError("ComputeLagrangianStrainBase cannot accommodate more than one "
78  "homogenization gradient");
79 
80  // Setup homogenization contributions
81  for (unsigned int i = 0; i < _homogenization_gradient_names.size(); i++)
83  &getMaterialProperty<RankTwoTensor>(_homogenization_gradient_names[i]);
84 }
85 
86 template <class G>
87 void
89 {
90  _total_strain[_qp].zero();
91  _mechanical_strain[_qp].zero();
92  _F[_qp].setToIdentity();
93 }
94 
95 template <class G>
96 void
98 {
99  // Average the volumetric terms, if required
100  computeDeformationGradient();
101 
102  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
103  computeQpProperties();
104 }
105 
106 template <class G>
107 void
109 {
110  // Add in the macroscale gradient contribution
111  for (auto contribution : _homogenization_contributions)
112  _F[_qp] += (*contribution)[_qp];
113 
114  // If the kernel is large deformation then we need the "actual"
115  // kinematic quantities
116  RankTwoTensor dL;
117  if (_large_kinematics)
118  {
119  _F_inv[_qp] = _F[_qp].inverse();
120  _f_inv[_qp] = _F_old[_qp] * _F_inv[_qp];
121  dL = RankTwoTensor::Identity() - _f_inv[_qp];
122  }
123  // For small deformations we just provide the identity
124  else
125  {
126  _F_inv[_qp] = RankTwoTensor::Identity();
127  _f_inv[_qp] = RankTwoTensor::Identity();
128  dL = _F[_qp] - _F_old[_qp];
129  }
130 
131  computeQpIncrementalStrains(dL);
132 }
133 
134 template <class G>
135 void
137 {
138  // Get the deformation increments
139  _strain_increment[_qp] = (dL + dL.transpose()) / 2.0;
140  _vorticity_increment[_qp] = (dL - dL.transpose()) / 2.0;
141 
142  // Increment the total strain
143  _total_strain[_qp] = _total_strain_old[_qp] + _strain_increment[_qp];
144 
145  // Get rid of the eigenstrains
146  // Note we currently do not alter the deformation gradient -- this will be
147  // needed in the future for a "complete" system
148  subtractQpEigenstrainIncrement(_strain_increment[_qp]);
149 
150  // Increment the mechanical strain
151  _mechanical_strain[_qp] = _mechanical_strain_old[_qp] + _strain_increment[_qp];
152 
153  // Yes, this does make sense to do it here
154  _spatial_velocity_increment[_qp] = _vorticity_increment[_qp] + _strain_increment[_qp];
155 
156  // Faked rotation increment for ComputeStressBase materials
157  _rotation_increment[_qp] = RankTwoTensor::Identity();
158 }
159 
160 template <class G>
161 void
163 {
164  for (auto i : make_range(_eigenstrain_names.size()))
165  strain -= (*_eigenstrains[i])[_qp] - (*_eigenstrains_old[i])[_qp];
166 }
167 
168 template <class G>
169 void
171 {
172  _F_ust[_qp].setToIdentity();
173  for (auto component : make_range(_ndisp))
174  G::addGradOp(_F_ust[_qp],
175  component,
176  (*_grad_disp[component])[_qp],
177  (*_disp[component])[_qp],
178  _q_point[_qp]);
179 }
180 
181 template <class G>
182 void
184 {
185  // First calculate the unstabilized deformation gradient at each qp
186  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
187  {
188  computeQpUnstabilizedDeformationGradient();
189  _F[_qp] = _F_ust[_qp];
190  }
191 
192  // If stabilization is on do the volumetric correction
193  if (_stabilize_strain)
194  {
195  const auto F_avg = StabilizationUtils::elementAverage(
196  [this](unsigned int qp) { return _F_ust[qp]; }, _JxW, _coord);
197  // All quadrature points have the same F_avg
198  _F_avg.set().setAllValues(F_avg);
199  // Make the appropriate modification, depending on small or large
200  // deformations
201  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
202  {
203  if (_large_kinematics)
204  _F[_qp] *= std::pow(F_avg.det() / _F[_qp].det(), 1.0 / 3.0);
205  else
206  _F[_qp] += (F_avg.trace() - _F[_qp].trace()) * RankTwoTensor::Identity() / 3.0;
207  }
208  }
209 }
210 
RankTwoTensorTempl< Real > inverse() const
virtual void computeQpUnstabilizedDeformationGradient()
Calculate the unstabilized deformation gradient at the quadrature point.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static const std::string component
Definition: NS.h:153
static RankTwoTensorTempl Identity()
void suppressParameter(const std::string &name)
std::vector< const MaterialProperty< RankTwoTensor > * > _homogenization_contributions
Actual homogenization contributions.
virtual void computeDeformationGradient()
Calculate the unstabilized and optionally the stabilized deformation gradients.
std::vector< MaterialPropertyName > _homogenization_gradient_names
Names of any extra homogenization gradients.
virtual void computeProperties() override
std::vector< const MaterialProperty< RankTwoTensor > * > _eigenstrains_old
static InputParameters validParams()
std::vector< const MaterialProperty< RankTwoTensor > * > _eigenstrains
std::vector< MaterialPropertyName > _eigenstrain_names
virtual void initQpStatefulProperties() override
virtual void subtractQpEigenstrainIncrement(RankTwoTensor &strain)
Subtract the eigenstrain increment to subtract from the total strain.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
RankTwoTensorTempl< Real > transpose() const
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
Calculate strains to use the MOOSE materials with the Lagrangian kernels.
auto elementAverage(const Functor &f, const MooseArray< Real > &JxW, const MooseArray< Real > &coord)
virtual void computeQpIncrementalStrains(const RankTwoTensor &dL)
Calculate the strains based on the spatial velocity gradient.
MooseUnits pow(const MooseUnits &, int)
ComputeLagrangianStrainBase(const InputParameters &parameters)
virtual void computeQpProperties() override