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-02-21 01:06:12 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         146 : SmallDeformationJ2Plasticity::validParams()
      11             : {
      12         146 :   InputParameters params = SmallDeformationPlasticityModel::validParams();
      13         146 :   params.addClassDescription("Small deformation $J_2$ plasticity. The plastic deformation is "
      14             :                              "updated using the additive decompsition of strain.");
      15         146 :   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             :   // First assume no plastic increment
      28      139608 :   ADReal delta_ep = 0;
      29      139608 :   elastic_strain -= _plastic_strain_old[_qp];
      30      139608 :   stress = _elasticity_model->computeStress(elastic_strain);
      31             : 
      32             :   // Compute the flow direction following the Prandtl-Reuss flow rule.
      33             :   // We guard against zero denominator.
      34      139608 :   ADRankTwoTensor stress_dev = stress.deviatoric();
      35      139608 :   ADReal stress_dev_norm = stress_dev.doubleContraction(stress_dev);
      36      139608 :   if (MooseUtils::absoluteFuzzyEqual(stress_dev_norm, 0))
      37       49268 :     stress_dev_norm.value() = libMesh::TOLERANCE * libMesh::TOLERANCE;
      38      279216 :   stress_dev_norm = std::sqrt(1.5 * stress_dev_norm);
      39      279216 :   _Np[_qp] = 1.5 * stress_dev / stress_dev_norm;
      40             : 
      41             :   // Return mapping
      42      139608 :   ADReal phi = computeResidual(stress_dev_norm, delta_ep);
      43      139608 :   if (phi > 0)
      44         134 :     returnMappingSolve(stress_dev_norm, delta_ep, _console);
      45      279216 :   _ep[_qp] = _ep_old[_qp] + delta_ep;
      46      139608 :   _plastic_strain[_qp] = _plastic_strain_old[_qp] + delta_ep * _Np[_qp];
      47             : 
      48             :   // Update stress
      49      279216 :   elastic_strain -= delta_ep * _Np[_qp];
      50      139608 :   stress = _elasticity_model->computeStress(elastic_strain);
      51      139608 :   _hardening_model->plasticEnergy(_ep[_qp]);
      52      139608 : }
      53             : 
      54             : Real
      55         398 : SmallDeformationJ2Plasticity::computeReferenceResidual(const ADReal & effective_trial_stress,
      56             :                                                        const ADReal & delta_ep)
      57             : {
      58             :   return raw_value(
      59         398 :       effective_trial_stress -
      60        1194 :       _elasticity_model->computeStress(delta_ep * _Np[_qp]).doubleContraction(_Np[_qp]));
      61             : }
      62             : 
      63             : ADReal
      64      140006 : SmallDeformationJ2Plasticity::computeResidual(const ADReal & effective_trial_stress,
      65             :                                               const ADReal & delta_ep)
      66             : {
      67      140006 :   return effective_trial_stress -
      68      280012 :          _elasticity_model->computeStress(delta_ep * _Np[_qp]).doubleContraction(_Np[_qp]) -
      69      420018 :          _hardening_model->plasticEnergy(_ep_old[_qp] + delta_ep, 1);
      70             : }
      71             : 
      72             : ADReal
      73         398 : SmallDeformationJ2Plasticity::computeDerivative(const ADReal & /*effective_trial_stress*/,
      74             :                                                 const ADReal & delta_ep)
      75             : {
      76         398 :   return -_elasticity_model->computeStress(_Np[_qp]).doubleContraction(_Np[_qp]) -
      77         796 :          _hardening_model->plasticEnergy(_ep_old[_qp] + delta_ep, 2);
      78             : }

Generated by: LCOV version 1.16