LCOV - code coverage report
Current view: top level - src/materials/lagrangian - ComputeNeoHookeanStress.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 22 23 95.7 %
Date: 2025-07-25 05:00:39 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://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 "ComputeNeoHookeanStress.h"
      11             : 
      12             : registerMooseObject("SolidMechanicsApp", ComputeNeoHookeanStress);
      13             : 
      14             : InputParameters
      15         192 : ComputeNeoHookeanStress::validParams()
      16             : {
      17         192 :   InputParameters params = ComputeLagrangianStressPK2::validParams();
      18             : 
      19         384 :   params.addParam<MaterialPropertyName>("lambda",
      20             :                                         "lambda",
      21             :                                         "Parameter conjugate to Lame parameter"
      22             :                                         " for small deformations");
      23         384 :   params.addParam<MaterialPropertyName>("mu",
      24             :                                         "mu",
      25             :                                         "Parameter conjugate to Lame parameter"
      26             :                                         " for small deformations");
      27             : 
      28         192 :   return params;
      29           0 : }
      30             : 
      31         144 : ComputeNeoHookeanStress::ComputeNeoHookeanStress(const InputParameters & parameters)
      32             :   : ComputeLagrangianStressPK2(parameters),
      33         144 :     _lambda(getMaterialProperty<Real>(getParam<MaterialPropertyName>("lambda"))),
      34         432 :     _mu(getMaterialProperty<Real>(getParam<MaterialPropertyName>("mu")))
      35             : 
      36             : {
      37         144 : }
      38             : 
      39             : void
      40     4312064 : 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     4312064 :   if (_large_kinematics)
      50             :   {
      51     2364160 :     RankTwoTensor Cinv = (2 * _E[_qp] + RankTwoTensor::Identity()).inverse();
      52     2364160 :     _S[_qp] = (_lambda[_qp] * log(_F[_qp].det()) - _mu[_qp]) * Cinv +
      53     2364160 :               _mu[_qp] * RankTwoTensor::Identity();
      54     2364160 :     _C[_qp] =
      55     2364160 :         -2 * (_lambda[_qp] * log(_F[_qp].det()) - _mu[_qp]) * Cinv.times<i_, k_, l_, j_>(Cinv) +
      56     4728320 :         _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     1947904 :     RankTwoTensor strain = 0.5 * (_F[_qp] + _F[_qp].transpose()) - I;
      63     3895808 :     _C[_qp] = _lambda[_qp] * I.times<i_, j_, k_, l_>(I) +
      64     3895808 :               2.0 * _mu[_qp] * RankFourTensor(RankFourTensor::initIdentitySymmetricFour);
      65     1947904 :     _S[_qp] = _C[_qp] * strain;
      66             :   }
      67     4312064 : }

Generated by: LCOV version 1.14