LCOV - code coverage report
Current view: top level - src/materials/lagrangian - ComputeLagrangianStressBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #33390 (250e9c) with base 846a5c Lines: 47 48 97.9 %
Date: 2026-07-31 18:20:40 Functions: 5 5 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 "ComputeLagrangianStressBase.h"
      11             : 
      12             : InputParameters
      13        5636 : ComputeLagrangianStressBase::validParams()
      14             : {
      15        5636 :   InputParameters params = Material::validParams();
      16             : 
      17       16908 :   params.addDeprecatedParam<bool>(
      18             :       "large_kinematics",
      19       11272 :       false,
      20             :       "Use a large displacement stress update.",
      21             :       "large_kinematics is no longer set on the stress calculator; it is derived from the "
      22             :       "ComputeLagrangianStrain calculator (the single source of truth) via the LARGE_KINEMATICS "
      23             :       "guarantee. Remove it here and set it only on the strain calculator.");
      24             : 
      25       11272 :   params.addParam<std::string>("base_name", "Material property base name");
      26             : 
      27        5636 :   return params;
      28           0 : }
      29             : 
      30        4227 : ComputeLagrangianStressBase::ComputeLagrangianStressBase(const InputParameters & parameters)
      31             :   : Material(parameters),
      32             :     GuaranteeConsumer(this),
      33             :     // Derived from the strain calculator's guarantee in initialSetup(); the local parameter is
      34             :     // deprecated and only consulted for a consistency cross-check.
      35        4227 :     _large_kinematics(false),
      36        4275 :     _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
      37        4227 :     _cauchy_stress(declareProperty<RankTwoTensor>(_base_name + "cauchy_stress")),
      38        4227 :     _cauchy_jacobian(declareProperty<RankFourTensor>(_base_name + "cauchy_jacobian")),
      39        4227 :     _pk1_stress(declareProperty<RankTwoTensor>(_base_name + "pk1_stress")),
      40        4227 :     _pk1_jacobian(declareProperty<RankFourTensor>(_base_name + "pk1_jacobian")),
      41        4227 :     _pk1_jacobian_bypass_fbar(
      42        4227 :         declareProperty<RankFourTensor>(_base_name + "pk1_jacobian_bypass_fbar")),
      43        4227 :     _dpk1_d_grad_u(declareProperty<RankFourTensor>(_base_name + "dpk1_d_grad_u")),
      44        4227 :     _d_F_d_grad_u(getMaterialPropertyByName<RankFourTensor>(
      45        4227 :         _base_name + "d_deformation_gradient_d_grad_displacement")),
      46        4227 :     _F_ust(
      47        4227 :         getMaterialPropertyByName<RankTwoTensor>(_base_name + "unstabilized_deformation_gradient")),
      48        4227 :     _d_deformation_gradient_increment_d_F(getMaterialPropertyByName<RankFourTensor>(
      49        4227 :         _base_name + "d_spatial_deformation_gradient_increment_d_deformation_gradient")),
      50        4227 :     _d_F_stab_d_F_ust(
      51        4227 :         getMaterialPropertyByName<RankFourTensor>(_base_name + "d_F_stab_d_F_unstabilized")),
      52        4227 :     _d_F_stab_d_F_avg(
      53        4227 :         getMaterialPropertyByName<RankFourTensor>(_base_name + "d_F_stab_d_F_average")),
      54        8454 :     _d_nl_fbar(declareProperty<RankFourTensor>(_base_name + "d_nl_fbar_operator"))
      55             : {
      56        4227 : }
      57             : 
      58             : void
      59        4220 : ComputeLagrangianStressBase::initialSetup()
      60             : {
      61        4220 :   Material::initialSetup();
      62             : 
      63             :   // Derive the kinematics regime from the strain calculator's LARGE_KINEMATICS guarantee -- the
      64             :   // single source of truth. Block-restricted (per subdomain) and keyed by the base_name-prefixed
      65             :   // deformation_gradient (so a given base_name matches its own strain calculator).
      66        8440 :   _large_kinematics = hasGuaranteedMaterialProperty(_base_name + "deformation_gradient",
      67             :                                                     Guarantee::LARGE_KINEMATICS);
      68             : 
      69             :   // The deprecated local parameter must not silently disagree with the strain calculator.
      70       12660 :   if (isParamSetByUser("large_kinematics") &&
      71       15088 :       getParam<bool>("large_kinematics") != _large_kinematics)
      72           1 :     paramError("large_kinematics",
      73             :                "large_kinematics disagrees with the ComputeLagrangianStrain calculator (which "
      74             :                "computes ",
      75           1 :                _large_kinematics ? "large" : "small",
      76             :                " kinematics). large_kinematics is deprecated here; set it only on the strain "
      77             :                "calculator.");
      78        4219 : }
      79             : 
      80             : void
      81      655890 : ComputeLagrangianStressBase::initQpStatefulProperties()
      82             : {
      83             :   // Actually no need to zero out the stresses as they aren't stateful (yet)
      84      655890 : }
      85             : 
      86             : void
      87    53356122 : ComputeLagrangianStressBase::computeQpProperties()
      88             : {
      89    53356122 :   computeQpStressUpdate();
      90             :   // Chain the kinematic policy into the PK1 Jacobian so the TL kernel consumes a single
      91             :   // d(PK1)/d(grad u) property and doesn't need to know about the generalized-alpha weighting.
      92             :   // For alpha = 1 (default) this is _pk1_jacobian itself. These are read only during Jacobian
      93             :   // assembly, so skip the R4*R4 work on residual-only sweeps.
      94    53356122 :   if (_fe_problem.currentlyComputingJacobian() ||
      95    51543019 :       _fe_problem.currentlyComputingResidualAndJacobian())
      96             :   {
      97     1813103 :     _dpk1_d_grad_u[_qp] = _pk1_jacobian[_qp] * _d_F_d_grad_u[_qp];
      98             : 
      99             :     // Non-local F-bar operator, composed once per qp here (shared by all displacement kernels)
     100             :     // instead of per-kernel in the assembly precalculate. `isPropertyActive`-gated so only the
     101             :     // F-bar (stabilized) kernels pay for the R4*R4*R4 chain.
     102     3397078 :     if (isPropertyActive(_d_nl_fbar.id()))
     103      458256 :       _d_nl_fbar[_qp] = _cauchy_jacobian[_qp] * _d_deformation_gradient_increment_d_F[_qp] *
     104      229128 :                         _d_F_stab_d_F_avg[_qp];
     105             :   }
     106    53356122 : }

Generated by: LCOV version 1.14