Line data Source code
1 : /**********************************************************************/
2 : /* DO NOT MODIFY THIS HEADER */
3 : /* Swift, a Fourier spectral solver for MOOSE */
4 : /* */
5 : /* Copyright 2024 Battelle Energy Alliance, LLC */
6 : /* ALL RIGHTS RESERVED */
7 : /**********************************************************************/
8 :
9 : #include "MooseError.h"
10 : #include "HyperElasticIsotropic.h"
11 :
12 : registerMooseObject("SwiftApp", HyperElasticIsotropic);
13 :
14 : InputParameters
15 0 : HyperElasticIsotropic::validParams()
16 : {
17 0 : InputParameters params = TensorOperator<>::validParams();
18 0 : params.addClassDescription("Hyperelastic isotropic constitutive model.");
19 0 : params.addRequiredParam<TensorInputBufferName>("F", "Deformation gradient tensor");
20 0 : params.addRequiredParam<TensorInputBufferName>("mu", "Deformation gradient tensor");
21 0 : params.addRequiredParam<TensorInputBufferName>("K", "Deformation gradient tensor");
22 0 : params.addParam<TensorOutputBufferName>("tangent_operator", "dstressdstrain", "Stiffness tensor");
23 0 : return params;
24 0 : }
25 :
26 0 : HyperElasticIsotropic::HyperElasticIsotropic(const InputParameters & parameters)
27 : : TensorOperator<>(parameters),
28 0 : _ti(torch::eye(_dim, MooseTensor::floatTensorOptions())),
29 0 : _tI(MooseTensor::unsqueeze0(_ti, _dim)),
30 0 : _tI4(MooseTensor::unsqueeze0(torch::einsum("il,jk", {_ti, _ti}), _dim)),
31 0 : _tI4rt(MooseTensor::unsqueeze0(torch::einsum("ik,jl", {_ti, _ti}), _dim)),
32 0 : _tI4s((_tI4 + _tI4rt) / 2.0),
33 0 : _tII(MooseTensor::dyad22(_tI, _tI)),
34 0 : _tF(getInputBuffer("F")),
35 0 : _tmu(getInputBuffer("mu")),
36 0 : _tK(getInputBuffer("K")),
37 0 : _tK4(getOutputBuffer("tangent_operator"))
38 : {
39 0 : }
40 :
41 : void
42 0 : HyperElasticIsotropic::computeBuffer()
43 : {
44 : using namespace MooseTensor;
45 :
46 0 : const auto C4 = _tK.reshape(_domain.getValueShape({1, 1, 1, 1})) * _tII +
47 0 : 2. * _tmu.reshape(_domain.getValueShape({1, 1, 1, 1})) * (_tI4s - 1. / 3. * _tII);
48 0 : const auto S = ddot42(C4, .5 * (dot22(trans2(_tF), _tF) - _tI));
49 :
50 0 : _u = dot22(_tF, S);
51 0 : _tK4 = dot24(S, _tI4) + ddot44(ddot44(_tI4rt, dot42(dot24(_tF, C4), trans2(_tF))), _tI4rt);
52 0 : }
|