Line data Source code
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"
14 : #include "SymmetricRankFourTensor.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>
23 : MooseEnum
24 2976 : ADComputeFiniteStrainTempl<R2, R4>::decompositionType()
25 : {
26 5952 : return MooseEnum("TaylorExpansion EigenSolution", "TaylorExpansion");
27 : }
28 :
29 : template <typename R2, typename R4>
30 : InputParameters
31 2976 : ADComputeFiniteStrainTempl<R2, R4>::validParams()
32 : {
33 : InputParameters params = ADComputeIncrementalStrainBase::validParams();
34 2976 : params.addClassDescription(
35 : "Compute a strain increment and rotation increment for finite strains.");
36 5952 : params.addParam<MooseEnum>("decomposition_method",
37 : ADComputeFiniteStrainTempl<R2, R4>::decompositionType(),
38 : "Methods to calculate the strain and rotation increments");
39 2976 : return params;
40 0 : }
41 :
42 : template <typename R2, typename R4>
43 2232 : ADComputeFiniteStrainTempl<R2, R4>::ADComputeFiniteStrainTempl(const InputParameters & parameters)
44 : : ADComputeIncrementalStrainBaseTempl<R2>(parameters),
45 2232 : _Fhat(this->_fe_problem.getMaxQps()),
46 2232 : _decomposition_method(
47 4464 : this->template getParam<MooseEnum>("decomposition_method").template getEnum<DecompMethod>())
48 : {
49 2232 : }
50 :
51 : template <typename R2, typename R4>
52 : void
53 1473924 : ADComputeFiniteStrainTempl<R2, R4>::computeProperties()
54 : {
55 1473924 : ADRankTwoTensor ave_Fhat;
56 12363820 : for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
57 : {
58 : // Deformation gradient
59 10889896 : auto A = ADRankTwoTensor::initializeFromRows(
60 10889896 : (*_grad_disp[0])[_qp], (*_grad_disp[1])[_qp], (*_grad_disp[2])[_qp]);
61 :
62 : // Old Deformation gradient
63 10889896 : auto Fbar = ADRankTwoTensor::initializeFromRows(
64 10889896 : (*_grad_disp_old[0])[_qp], (*_grad_disp_old[1])[_qp], (*_grad_disp_old[2])[_qp]);
65 :
66 : // A = gradU - gradUold
67 10889896 : A -= Fbar;
68 :
69 : // Fbar = ( I + gradUold)
70 10889896 : Fbar.addIa(1.0);
71 :
72 : // Incremental deformation gradient _Fhat = I + A Fbar^-1
73 10889896 : _Fhat[_qp] = A * Fbar.inverse();
74 10889896 : _Fhat[_qp].addIa(1.0);
75 :
76 : // Calculate average _Fhat for volumetric locking correction
77 10889896 : if (_volumetric_locking_correction)
78 6083872 : ave_Fhat += _Fhat[_qp] * _JxW[_qp] * _coord[_qp];
79 : }
80 :
81 1473924 : if (_volumetric_locking_correction)
82 760484 : ave_Fhat /= _current_elem_volume;
83 :
84 1473924 : const auto ave_Fhat_det = ave_Fhat.det();
85 12363814 : for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
86 : {
87 : // Finalize volumetric locking correction
88 10889892 : if (_volumetric_locking_correction)
89 12167744 : _Fhat[_qp] *= std::cbrt(ave_Fhat_det / _Fhat[_qp].det());
90 :
91 10889892 : computeQpStrain();
92 : }
93 1473922 : }
94 :
95 : template <typename R2, typename R4>
96 : void
97 13202576 : ADComputeFiniteStrainTempl<R2, R4>::computeQpStrain()
98 : {
99 13202576 : ADR2 total_strain_increment;
100 :
101 : // two ways to calculate these increments: TaylorExpansion(default) or EigenSolution
102 13202576 : computeQpIncrements(total_strain_increment, _rotation_increment[_qp]);
103 :
104 13202574 : _strain_increment[_qp] = total_strain_increment;
105 :
106 : // Remove the eigenstrain increment
107 13202574 : this->subtractEigenstrainIncrementFromStrain(_strain_increment[_qp]);
108 :
109 13202574 : if (_dt > 0)
110 13111286 : _strain_rate[_qp] = _strain_increment[_qp] / _dt;
111 : else
112 91288 : _strain_rate[_qp].zero();
113 :
114 : // Update strain in intermediate configuration
115 13202574 : _mechanical_strain[_qp] = _mechanical_strain_old[_qp] + _strain_increment[_qp];
116 13202574 : _total_strain[_qp] = _total_strain_old[_qp] + total_strain_increment;
117 :
118 : // Rotate strain to current configuration
119 13202574 : _mechanical_strain[_qp].rotate(_rotation_increment[_qp]);
120 13202574 : _total_strain[_qp].rotate(_rotation_increment[_qp]);
121 :
122 13202574 : if (_global_strain)
123 0 : _total_strain[_qp] += (*_global_strain)[_qp];
124 13202574 : }
125 :
126 : template <typename R2, typename R4>
127 : void
128 13202576 : ADComputeFiniteStrainTempl<R2, R4>::computeQpIncrements(ADR2 & total_strain_increment,
129 : ADRankTwoTensor & rotation_increment)
130 : {
131 13202576 : switch (_decomposition_method)
132 : {
133 13198832 : case DecompMethod::TaylorExpansion:
134 : {
135 : // inverse of _Fhat
136 13198832 : const ADRankTwoTensor invFhat = _Fhat[_qp].inverse();
137 :
138 : // A = I - _Fhat^-1
139 13198832 : ADRankTwoTensor A(ADRankTwoTensor::initIdentity);
140 13198832 : A -= invFhat;
141 :
142 : // Cinv - I = A A^T - (A + A^T);
143 13198832 : 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 26397664 : 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 13198832 : const auto q = (a[0] * a[0] + a[1] * a[1] + a[2] * a[2]) / 4.0;
153 13198832 : const auto trFhatinv_1 = invFhat.trace() - 1.0;
154 26397664 : const auto p = trFhatinv_1 * trFhatinv_1 / 4.0;
155 :
156 : // cos theta_a
157 13198832 : const ADReal C1_squared =
158 26397664 : p + 3.0 * Utility::pow<2>(p) * (1.0 - (p + q)) / Utility::pow<2>(p + q) -
159 39596496 : 2.0 * Utility::pow<3>(p) * (1.0 - (p + q)) / Utility::pow<3>(p + q);
160 13198832 : if (C1_squared <= 0.0)
161 0 : 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 13198832 : const ADReal C1 = std::sqrt(C1_squared);
167 :
168 : ADReal C2;
169 13198832 : if (q > 0.01)
170 : // (1-cos theta_a)/4q
171 68964 : C2 = (1.0 - C1) / (4.0 * q);
172 : else
173 : // alternate form for small q
174 52703376 : C2 = 0.125 + q * 0.03125 * (Utility::pow<2>(p) - 12.0 * (p - 1.0)) / Utility::pow<2>(p) +
175 13175844 : 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 52703376 : (1104.0 - 992.0 * p + 376.0 * Utility::pow<2>(p) - 72.0 * Utility::pow<3>(p) +
179 13175844 : 5.0 * Utility::pow<4>(p)) /
180 26351688 : (512.0 * Utility::pow<4>(p));
181 :
182 13198834 : const ADReal C3_test =
183 26397664 : (p * q * (3.0 - q) + Utility::pow<3>(p) + Utility::pow<2>(q)) / Utility::pow<3>(p + q);
184 13198832 : if (C3_test <= 0.0)
185 2 : 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 26397660 : 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 13198830 : ADRankTwoTensor R_incr;
194 13198830 : R_incr.addIa(C1);
195 52795320 : for (unsigned int i = 0; i < 3; ++i)
196 158385960 : for (unsigned int j = 0; j < 3; ++j)
197 237578940 : R_incr(i, j) += C2 * a[i] * a[j];
198 :
199 13198830 : R_incr(0, 1) += C3 * a[2];
200 13198830 : R_incr(0, 2) -= C3 * a[1];
201 13198830 : R_incr(1, 0) -= C3 * a[2];
202 13198830 : R_incr(1, 2) += C3 * a[0];
203 13198830 : R_incr(2, 0) += C3 * a[1];
204 13198830 : R_incr(2, 1) -= C3 * a[0];
205 :
206 26397662 : rotation_increment = R_incr.transpose();
207 : break;
208 : }
209 :
210 3744 : 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 3744 : if (this->_fe_problem.currentlyComputingJacobian() &&
216 4512 : _Fhat[_qp] == ADRankTwoTensor::Identity())
217 224 : _Fhat[_qp] +=
218 448 : 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 3744 : FADR2 Chat = ADR2::transposeTimes(_Fhat[_qp]);
221 3744 : FADR2 Uhat = MathUtils::sqrt(Chat);
222 7488 : rotation_increment = _Fhat[_qp] * Uhat.inverse().template get<ADRankTwoTensor>();
223 7488 : total_strain_increment = MathUtils::log(Uhat).template get<ADR2>();
224 : break;
225 : }
226 :
227 0 : default:
228 0 : mooseError("ADComputeFiniteStrain Error: Pass valid decomposition type: TaylorExpansion or "
229 : "EigenSolution.");
230 : }
231 13202574 : }
232 :
233 : template class ADComputeFiniteStrainTempl<RankTwoTensor, RankFourTensor>;
234 : template class ADComputeFiniteStrainTempl<SymmetricRankTwoTensor, SymmetricRankFourTensor>;
|