https://mooseframework.inl.gov
ADComputeFiniteStrain.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 
10 #include "ADComputeFiniteStrain.h"
11 #include "RankTwoTensor.h"
12 #include "RankFourTensor.h"
13 #include "SymmetricRankTwoTensor.h"
15 
16 #include "libmesh/quadrature.h"
17 #include "libmesh/utility.h"
18 
19 registerMooseObject("SolidMechanicsApp", ADComputeFiniteStrain);
20 registerMooseObject("SolidMechanicsApp", ADSymmetricFiniteStrain);
21 
22 template <typename R2, typename R4>
25 {
26  return MooseEnum("TaylorExpansion EigenSolution", "TaylorExpansion");
27 }
28 
29 template <typename R2, typename R4>
32 {
34  params.addClassDescription(
35  "Compute a strain increment and rotation increment for finite strains.");
36  params.addParam<MooseEnum>("decomposition_method",
38  "Methods to calculate the strain and rotation increments");
39  return params;
40 }
41 
42 template <typename R2, typename R4>
44  : ADComputeIncrementalStrainBaseTempl<R2>(parameters),
45  _Fhat(this->_fe_problem.getMaxQps()),
46  _decomposition_method(
47  this->template getParam<MooseEnum>("decomposition_method").template getEnum<DecompMethod>())
48 {
49 }
50 
51 template <typename R2, typename R4>
52 void
54 {
55  ADRankTwoTensor ave_Fhat;
56  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
57  {
58  // Deformation gradient
60  (*_grad_disp[0])[_qp], (*_grad_disp[1])[_qp], (*_grad_disp[2])[_qp]);
61 
62  // Old Deformation gradient
64  (*_grad_disp_old[0])[_qp], (*_grad_disp_old[1])[_qp], (*_grad_disp_old[2])[_qp]);
65 
66  // A = gradU - gradUold
67  A -= Fbar;
68 
69  // Fbar = ( I + gradUold)
70  Fbar.addIa(1.0);
71 
72  // Incremental deformation gradient _Fhat = I + A Fbar^-1
73  _Fhat[_qp] = A * Fbar.inverse();
74  _Fhat[_qp].addIa(1.0);
75 
76  // Calculate average _Fhat for volumetric locking correction
77  if (_volumetric_locking_correction)
78  ave_Fhat += _Fhat[_qp] * _JxW[_qp] * _coord[_qp];
79  }
80 
81  if (_volumetric_locking_correction)
82  ave_Fhat /= _current_elem_volume;
83 
84  const auto ave_Fhat_det = ave_Fhat.det();
85  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
86  {
87  // Finalize volumetric locking correction
88  if (_volumetric_locking_correction)
89  _Fhat[_qp] *= std::cbrt(ave_Fhat_det / _Fhat[_qp].det());
90 
91  computeQpStrain();
92  }
93 }
94 
95 template <typename R2, typename R4>
96 void
98 {
99  ADR2 total_strain_increment;
100 
101  // two ways to calculate these increments: TaylorExpansion(default) or EigenSolution
102  computeQpIncrements(total_strain_increment, _rotation_increment[_qp]);
103 
104  _strain_increment[_qp] = total_strain_increment;
105 
106  // Remove the eigenstrain increment
107  this->subtractEigenstrainIncrementFromStrain(_strain_increment[_qp]);
108 
109  if (_dt > 0)
110  _strain_rate[_qp] = _strain_increment[_qp] / _dt;
111  else
112  _strain_rate[_qp].zero();
113 
114  // Update strain in intermediate configuration
115  _mechanical_strain[_qp] = _mechanical_strain_old[_qp] + _strain_increment[_qp];
116  _total_strain[_qp] = _total_strain_old[_qp] + total_strain_increment;
117 
118  // Rotate strain to current configuration
119  _mechanical_strain[_qp].rotate(_rotation_increment[_qp]);
120  _total_strain[_qp].rotate(_rotation_increment[_qp]);
121 
122  if (_global_strain)
123  _total_strain[_qp] += (*_global_strain)[_qp];
124 }
125 
126 template <typename R2, typename R4>
127 void
129  ADRankTwoTensor & rotation_increment)
130 {
131  switch (_decomposition_method)
132  {
133  case DecompMethod::TaylorExpansion:
134  {
135  // inverse of _Fhat
136  const ADRankTwoTensor invFhat = _Fhat[_qp].inverse();
137 
138  // A = I - _Fhat^-1
140  A -= invFhat;
141 
142  // Cinv - I = A A^T - (A + A^T);
143  ADR2 Cinv_I = ADR2::timesTranspose(A) - ADR2::plusTranspose(A);
144 
145  // strain rate D from Taylor expansion, Chat = (-1/2(Chat^-1 - I) + 1/4*(Chat^-1 - I)^2 + ...
146  total_strain_increment = -Cinv_I * 0.5 + Cinv_I.square() * 0.25;
147 
148  const ADReal a[3] = {invFhat(1, 2) - invFhat(2, 1),
149  invFhat(2, 0) - invFhat(0, 2),
150  invFhat(0, 1) - invFhat(1, 0)};
151 
152  const auto q = (a[0] * a[0] + a[1] * a[1] + a[2] * a[2]) / 4.0;
153  const auto trFhatinv_1 = invFhat.trace() - 1.0;
154  const auto p = trFhatinv_1 * trFhatinv_1 / 4.0;
155 
156  // cos theta_a
157  const ADReal C1_squared =
158  p + 3.0 * Utility::pow<2>(p) * (1.0 - (p + q)) / Utility::pow<2>(p + q) -
159  2.0 * Utility::pow<3>(p) * (1.0 - (p + q)) / Utility::pow<3>(p + q);
160  if (C1_squared <= 0.0)
161  mooseException(
162  "Cannot take square root of a number less than or equal to zero in the calculation of "
163  "C1 for the Rashid approximation for the rotation tensor. This zero or negative number "
164  "may occur when elements become heavily distorted.");
165 
166  const ADReal C1 = std::sqrt(C1_squared);
167 
168  ADReal C2;
169  if (q > 0.01)
170  // (1-cos theta_a)/4q
171  C2 = (1.0 - C1) / (4.0 * q);
172  else
173  // alternate form for small q
174  C2 = 0.125 + q * 0.03125 * (Utility::pow<2>(p) - 12.0 * (p - 1.0)) / Utility::pow<2>(p) +
175  Utility::pow<2>(q) * (p - 2.0) * (Utility::pow<2>(p) - 10.0 * p + 32.0) /
176  Utility::pow<3>(p) +
177  Utility::pow<3>(q) *
178  (1104.0 - 992.0 * p + 376.0 * Utility::pow<2>(p) - 72.0 * Utility::pow<3>(p) +
179  5.0 * Utility::pow<4>(p)) /
180  (512.0 * Utility::pow<4>(p));
181 
182  const ADReal C3_test =
183  (p * q * (3.0 - q) + Utility::pow<3>(p) + Utility::pow<2>(q)) / Utility::pow<3>(p + q);
184  if (C3_test <= 0.0)
185  mooseException(
186  "Cannot take square root of a number less than or equal to zero in the calculation of "
187  "C3_test for the Rashid approximation for the rotation tensor. This zero or negative "
188  "number may occur when elements become heavily distorted.");
189  const ADReal C3 = 0.5 * std::sqrt(C3_test); // sin theta_a/(2 sqrt(q))
190 
191  // Calculate incremental rotation. Note that this value is the transpose of that from Rashid,
192  // 93, so we transpose it before storing
193  ADRankTwoTensor R_incr;
194  R_incr.addIa(C1);
195  for (unsigned int i = 0; i < 3; ++i)
196  for (unsigned int j = 0; j < 3; ++j)
197  R_incr(i, j) += C2 * a[i] * a[j];
198 
199  R_incr(0, 1) += C3 * a[2];
200  R_incr(0, 2) -= C3 * a[1];
201  R_incr(1, 0) -= C3 * a[2];
202  R_incr(1, 2) += C3 * a[0];
203  R_incr(2, 0) += C3 * a[1];
204  R_incr(2, 1) -= C3 * a[0];
205 
206  rotation_increment = R_incr.transpose();
207  break;
208  }
209 
210  case DecompMethod::EigenSolution:
211  {
212  // Add a small perturbation to F for the case when F=I, which occurs with no deformation,
213  // which commonly occurs in initialization. The perturbation to F does not affect the computed
214  // stress, but prevents a singularity in the AD-computed material Jacobian.
215  if (this->_fe_problem.currentlyComputingJacobian() &&
216  _Fhat[_qp] == ADRankTwoTensor::Identity())
217  _Fhat[_qp] +=
218  ADRankTwoTensor(0.0, 5.0e-13, 5.0e-13, 5.0e-13, 0.0, 5.0e-13, 5.0e-13, 5.0e-13, 0.0);
219 
220  FADR2 Chat = ADR2::transposeTimes(_Fhat[_qp]);
221  FADR2 Uhat = MathUtils::sqrt(Chat);
222  rotation_increment = _Fhat[_qp] * Uhat.inverse().template get<ADRankTwoTensor>();
223  total_strain_increment = MathUtils::log(Uhat).template get<ADR2>();
224  break;
225  }
226 
227  default:
228  mooseError("ADComputeFiniteStrain Error: Pass valid decomposition type: TaylorExpansion or "
229  "EigenSolution.");
230  }
231 }
232 
RankTwoTensorTempl< T > inverse() const
Moose::GenericType< R2, true > ADR2
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void mooseError(Args &&... args)
ADComputeIncrementalStrainBase is the base class for strain tensors using incremental formulations...
static RankTwoTensorTempl Identity()
static RankTwoTensorTempl initializeFromRows(const libMesh::TypeVector< ADReal > &row0, const libMesh::TypeVector< ADReal > &row1, const libMesh::TypeVector< ADReal > &row2)
ADComputeFiniteStrainTempl(const InputParameters &parameters)
void addIa(const T &a)
ADComputeFiniteStrain defines a strain increment and rotation increment, for finite strains...
static MooseEnum decompositionType()
RankTwoTensorTempl< T > transpose() const
static InputParameters validParams()
virtual void computeQpIncrements(ADR2 &e, ADRankTwoTensor &r)
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
registerMooseObject("SolidMechanicsApp", ADComputeFiniteStrain)
FactorizedRankTwoTensorTempl< T > inverse() const