LCOV - code coverage report
Current view: top level - src/materials/lagrangian - ComputeNeoHookeanStress.C (source / functions) Hit Total Coverage
Test: idaholab/moose tensor_mechanics: d6b47a Lines: 22 23 95.7 %
Date: 2024-02-27 11:53:14 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "ComputeNeoHookeanStress.h"
      11             : 
      12             : registerMooseObject("TensorMechanicsApp", ComputeNeoHookeanStress);
      13             : 
      14             : InputParameters
      15          96 : ComputeNeoHookeanStress::validParams()
      16             : {
      17          96 :   InputParameters params = ComputeLagrangianStressPK2::validParams();
      18             : 
      19         192 :   params.addParam<MaterialPropertyName>("lambda",
      20             :                                         "lambda",
      21             :                                         "Parameter conjugate to Lame parameter"
      22             :                                         " for small deformations");
      23         192 :   params.addParam<MaterialPropertyName>("mu",
      24             :                                         "mu",
      25             :                                         "Parameter conjugate to Lame parameter"
      26             :                                         " for small deformations");
      27             : 
      28          96 :   return params;
      29           0 : }
      30             : 
      31          72 : ComputeNeoHookeanStress::ComputeNeoHookeanStress(const InputParameters & parameters)
      32             :   : ComputeLagrangianStressPK2(parameters),
      33          72 :     _lambda(getMaterialProperty<Real>(getParam<MaterialPropertyName>("lambda"))),
      34         216 :     _mu(getMaterialProperty<Real>(getParam<MaterialPropertyName>("mu")))
      35             : 
      36             : {
      37          72 : }
      38             : 
      39             : void
      40     2188208 : ComputeNeoHookeanStress::computeQpPK2Stress()
      41             : {
      42             :   // Hyperelasticity is weird, we need to branch on the type of update if we
      43             :   // want a truly linear model
      44             :   //
      45             :   // This is because we need to drop quadratic terms for the linear update
      46             :   usingTensorIndices(i_, j_, k_, l_);
      47             : 
      48             :   // Large deformation = nonlinear strain
      49     2188208 :   if (_large_kinematics)
      50             :   {
      51     1211664 :     RankTwoTensor Cinv = (2 * _E[_qp] + RankTwoTensor::Identity()).inverse();
      52     1211664 :     _S[_qp] = (_lambda[_qp] * log(_F[_qp].det()) - _mu[_qp]) * Cinv +
      53     1211664 :               _mu[_qp] * RankTwoTensor::Identity();
      54     1211664 :     _C[_qp] =
      55     1211664 :         -2 * (_lambda[_qp] * log(_F[_qp].det()) - _mu[_qp]) * Cinv.times<i_, k_, l_, j_>(Cinv) +
      56     2423328 :         _lambda[_qp] * Cinv.times<i_, j_, k_, l_>(Cinv);
      57             :   }
      58             :   // Small deformations = linear strain
      59             :   else
      60             :   {
      61             :     const auto I = RankTwoTensor::Identity();
      62      976544 :     RankTwoTensor strain = 0.5 * (_F[_qp] + _F[_qp].transpose()) - I;
      63     1953088 :     _C[_qp] = _lambda[_qp] * I.times<i_, j_, k_, l_>(I) +
      64     1953088 :               2.0 * _mu[_qp] * RankFourTensor(RankFourTensor::initIdentitySymmetricFour);
      65      976544 :     _S[_qp] = _C[_qp] * strain;
      66             :   }
      67     2188208 : }

Generated by: LCOV version 1.14