LCOV - code coverage report
Current view: top level - src/materials/small_deformation_models - SmallDeformationJ2Plasticity.C (source / functions) Hit Total Coverage
Test: coverage.info Lines: 36 37 97.3 %
Date: 2025-11-27 01:11:00 Functions: 6 6 100.0 %

          Line data    Source code
       1             : //* This file is part of the RACCOON application
       2             : //* being developed at Dolbow lab at Duke University
       3             : //* http://dolbow.pratt.duke.edu
       4             : 
       5             : #include "SmallDeformationJ2Plasticity.h"
       6             : 
       7             : registerMooseObject("raccoonApp", SmallDeformationJ2Plasticity);
       8             : 
       9             : InputParameters
      10         144 : SmallDeformationJ2Plasticity::validParams()
      11             : {
      12         144 :   InputParameters params = SmallDeformationPlasticityModel::validParams();
      13         144 :   params.addClassDescription("Small deformation $J_2$ plasticity. The plastic deformation is "
      14             :                              "updated using the additive decompsition of strain.");
      15         144 :   return params;
      16           0 : }
      17             : 
      18           6 : SmallDeformationJ2Plasticity::SmallDeformationJ2Plasticity(const InputParameters & parameters)
      19           6 :   : SmallDeformationPlasticityModel(parameters)
      20             : {
      21           6 : }
      22             : 
      23             : void
      24      139608 : SmallDeformationJ2Plasticity::updateState(ADRankTwoTensor & stress,
      25             :                                           ADRankTwoTensor & elastic_strain)
      26             : {
      27             :   using std::sqrt;
      28             :   // First assume no plastic increment
      29      139608 :   ADReal delta_ep = 0;
      30      139608 :   elastic_strain -= _plastic_strain_old[_qp];
      31      139608 :   stress = _elasticity_model->computeStress(elastic_strain);
      32             : 
      33             :   // Compute the flow direction following the Prandtl-Reuss flow rule.
      34             :   // We guard against zero denominator.
      35      139608 :   ADRankTwoTensor stress_dev = stress.deviatoric();
      36      139608 :   ADReal stress_dev_norm = stress_dev.doubleContraction(stress_dev);
      37      139608 :   if (MooseUtils::absoluteFuzzyEqual(stress_dev_norm, 0))
      38       49268 :     stress_dev_norm.value() = libMesh::TOLERANCE * libMesh::TOLERANCE;
      39      279216 :   stress_dev_norm = sqrt(1.5 * stress_dev_norm);
      40      279216 :   _Np[_qp] = 1.5 * stress_dev / stress_dev_norm;
      41             : 
      42             :   // Return mapping
      43      139608 :   ADReal phi = computeResidual(stress_dev_norm, delta_ep);
      44      139608 :   if (phi > 0)
      45         134 :     returnMappingSolve(stress_dev_norm, delta_ep, _console);
      46      279216 :   _ep[_qp] = _ep_old[_qp] + delta_ep;
      47      139608 :   _plastic_strain[_qp] = _plastic_strain_old[_qp] + delta_ep * _Np[_qp];
      48             : 
      49             :   // Update stress
      50      279216 :   elastic_strain -= delta_ep * _Np[_qp];
      51      139608 :   stress = _elasticity_model->computeStress(elastic_strain);
      52      139608 :   _hardening_model->plasticEnergy(_ep[_qp]);
      53      139608 : }
      54             : 
      55             : Real
      56         398 : SmallDeformationJ2Plasticity::computeReferenceResidual(const ADReal & effective_trial_stress,
      57             :                                                        const ADReal & delta_ep)
      58             : {
      59             :   return raw_value(
      60         398 :       effective_trial_stress -
      61        1194 :       _elasticity_model->computeStress(delta_ep * _Np[_qp]).doubleContraction(_Np[_qp]));
      62             : }
      63             : 
      64             : ADReal
      65      140006 : SmallDeformationJ2Plasticity::computeResidual(const ADReal & effective_trial_stress,
      66             :                                               const ADReal & delta_ep)
      67             : {
      68      140006 :   return effective_trial_stress -
      69      280012 :          _elasticity_model->computeStress(delta_ep * _Np[_qp]).doubleContraction(_Np[_qp]) -
      70      420018 :          _hardening_model->plasticEnergy(_ep_old[_qp] + delta_ep, 1);
      71             : }
      72             : 
      73             : ADReal
      74         398 : SmallDeformationJ2Plasticity::computeDerivative(const ADReal & /*effective_trial_stress*/,
      75             :                                                 const ADReal & delta_ep)
      76             : {
      77         398 :   return -_elasticity_model->computeStress(_Np[_qp]).doubleContraction(_Np[_qp]) -
      78         796 :          _hardening_model->plasticEnergy(_ep_old[_qp] + delta_ep, 2);
      79             : }

Generated by: LCOV version 1.16