LCOV - code coverage report
Current view: top level - src/materials/lagrangian - ComputeLagrangianStressPK1.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 23 24 95.8 %
Date: 2025-07-25 05:00:39 Functions: 4 4 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 "ComputeLagrangianStressPK1.h"
      11             : 
      12             : InputParameters
      13         392 : ComputeLagrangianStressPK1::validParams()
      14             : {
      15         392 :   InputParameters params = ComputeLagrangianStressBase::validParams();
      16             : 
      17         392 :   params.addClassDescription("Stress update based on the first Piola-Kirchhoff stress");
      18             : 
      19         392 :   return params;
      20           0 : }
      21             : 
      22         294 : ComputeLagrangianStressPK1::ComputeLagrangianStressPK1(const InputParameters & parameters)
      23             :   : ComputeLagrangianStressBase(parameters),
      24         294 :     _inv_df(getMaterialPropertyByName<RankTwoTensor>(_base_name +
      25             :                                                      "inverse_incremental_deformation_gradient")),
      26         882 :     _F(getMaterialPropertyByName<RankTwoTensor>(_base_name + "deformation_gradient"))
      27             : {
      28         294 : }
      29             : 
      30             : void
      31     8446240 : ComputeLagrangianStressPK1::computeQpStressUpdate()
      32             : {
      33     8446240 :   computeQpPK1Stress();
      34     8446240 :   computeQpCauchyStress(); // This could be "switched"
      35     8446240 : }
      36             : 
      37             : void
      38     8446240 : ComputeLagrangianStressPK1::computeQpCauchyStress()
      39             : {
      40             :   // Actually do the (annoying) wrapping
      41     8446240 :   if (_large_kinematics)
      42             :   {
      43     4550432 :     _cauchy_stress[_qp] = _pk1_stress[_qp] * _F[_qp].transpose() / _F[_qp].det();
      44             : 
      45     4550432 :     auto f = _inv_df[_qp].inverse();
      46             :     usingTensorIndices(i_, j_, k_, l_);
      47     9100864 :     _cauchy_jacobian[_qp] = _cauchy_stress[_qp].times<i_, l_, j_, k_>(f) -
      48     9100864 :                             _cauchy_stress[_qp].times<i_, j_, k_, l_>(f.transpose());
      49     4550432 :     _cauchy_jacobian[_qp] +=
      50     9100864 :         _pk1_jacobian[_qp].tripleProductJkl(_F[_qp], f.transpose(), _F[_qp]) / _F[_qp].det();
      51             :   }
      52             :   // Small deformations these are the same
      53             :   else
      54             :   {
      55     3895808 :     _cauchy_stress[_qp] = _pk1_stress[_qp];
      56     3895808 :     _cauchy_jacobian[_qp] = _pk1_jacobian[_qp];
      57             :   }
      58     8446240 : }

Generated by: LCOV version 1.14