LCOV - code coverage report
Current view: top level - src/userobjects - SolidMechanicsPlasticIsotropicSD.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #32971 (54bef8) with base c6cf66 Lines: 72 75 96.0 %
Date: 2026-05-29 20:40:07 Functions: 14 14 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 "SolidMechanicsPlasticIsotropicSD.h"
      11             : 
      12             : registerMooseObject("SolidMechanicsApp", SolidMechanicsPlasticIsotropicSD);
      13             : registerMooseObjectRenamed("SolidMechanicsApp",
      14             :                            TensorMechanicsPlasticIsotropicSD,
      15             :                            "01/01/2025 00:00",
      16             :                            SolidMechanicsPlasticIsotropicSD);
      17             : 
      18             : InputParameters
      19          32 : SolidMechanicsPlasticIsotropicSD::validParams()
      20             : {
      21          32 :   InputParameters params = SolidMechanicsPlasticJ2::validParams();
      22          64 :   params.addRequiredParam<Real>("b", "A constant to model the influence of pressure");
      23          64 :   params.addParam<Real>(
      24          64 :       "c", 0.0, "A constant to model the influence of strength differential effect");
      25          64 :   params.addParam<bool>("associative", true, "Flag for flow-rule, true if not specified");
      26          32 :   params.addClassDescription("IsotropicSD plasticity for pressure sensitive materials and also "
      27             :                              "models the strength differential effect");
      28          32 :   return params;
      29           0 : }
      30             : 
      31          16 : SolidMechanicsPlasticIsotropicSD::SolidMechanicsPlasticIsotropicSD(
      32          16 :     const InputParameters & parameters)
      33             :   : SolidMechanicsPlasticJ2(parameters),
      34          16 :     _b(getParam<Real>("b")),
      35          32 :     _c(getParam<Real>("c")),
      36          48 :     _associative(getParam<bool>("associative"))
      37             : {
      38          16 :   _a = 1.0 / (_b + std::pow(1.0 / std::sqrt(27.0) - _c / 27.0, 1.0 / 3.0));
      39          64 :   for (unsigned i = 0; i < 3; ++i)
      40         192 :     for (unsigned j = 0; j < 3; ++j)
      41         576 :       for (unsigned k = 0; k < 3; ++k)
      42        1728 :         for (unsigned l = 0; l < 3; ++l)
      43        3024 :           _h(i, j, k, l) = ((i == k) * (j == l) - 1.0 / 3.0 * (i == j) * (k == l));
      44          16 : }
      45             : 
      46             : Real
      47       48440 : SolidMechanicsPlasticIsotropicSD::dphi_dj2(const Real j2, const Real j3) const
      48             : {
      49       48440 :   return std::pow(j2, 1.0 / 2.0) / (2 * std::pow(std::pow(j2, 3.0 / 2.0) - _c * j3, 2.0 / 3.0));
      50             : }
      51             : 
      52             : Real
      53       48440 : SolidMechanicsPlasticIsotropicSD::dphi_dj3(const Real j2, const Real j3) const
      54             : {
      55       48440 :   return -_c / (3 * std::pow(std::pow(j2, 3.0 / 2.0) - _c * j3, 2.0 / 3.0));
      56             : }
      57             : 
      58             : Real
      59       11752 : SolidMechanicsPlasticIsotropicSD::dfj2_dj2(const Real j2, const Real j3) const
      60             : {
      61       11752 :   return std::pow(j2, -1.0 / 2.0) / (4 * std::pow(std::pow(j2, 3.0 / 2.0) - _c * j3, 2.0 / 3.0)) -
      62       11752 :          j2 / (2 * std::pow(std::pow(j2, 3.0 / 2.0) - _c * j3, 5.0 / 3.0));
      63             : }
      64             : 
      65             : Real
      66       11752 : SolidMechanicsPlasticIsotropicSD::dfj2_dj3(const Real j2, const Real j3) const
      67             : {
      68       11752 :   return _c * std::pow(j2, 1.0 / 2.0) /
      69       11752 :          (3 * std::pow(std::pow(j2, 3.0 / 2.0) - _c * j3, 5.0 / 3.0));
      70             : }
      71             : 
      72             : Real
      73       11752 : SolidMechanicsPlasticIsotropicSD::dfj3_dj2(const Real j2, const Real j3) const
      74             : {
      75       11752 :   return _c * std::pow(j2, 1.0 / 2.0) /
      76       11752 :          (3 * std::pow(std::pow(j2, 3.0 / 2.0) - _c * j3, 5.0 / 3.0));
      77             : }
      78             : 
      79             : Real
      80       11752 : SolidMechanicsPlasticIsotropicSD::dfj3_dj3(const Real j2, const Real j3) const
      81             : {
      82       11752 :   return -_c * _c * 2.0 / (9 * std::pow(std::pow(j2, 3.0 / 2.0) - _c * j3, 5.0 / 3.0));
      83             : }
      84             : 
      85             : RankTwoTensor
      86       48440 : SolidMechanicsPlasticIsotropicSD::dI_sigma() const
      87             : {
      88       48440 :   return RankTwoTensor(RankTwoTensor::initIdentity);
      89             : }
      90             : 
      91             : RankTwoTensor
      92       60192 : SolidMechanicsPlasticIsotropicSD::dj2_dSkl(const RankTwoTensor & stress) const
      93             : {
      94       60192 :   RankTwoTensor a;
      95       60192 :   const Real trace = stress.trace();
      96      240768 :   for (unsigned i = 0; i < 3; ++i)
      97      722304 :     for (unsigned j = 0; j < 3; ++j)
      98     1083456 :       a(i, j) = (trace - stress(i, j)) * -1 * (i == j) + stress(i, j) * (i != j);
      99             : 
     100       60192 :   return a;
     101             : }
     102             : 
     103             : Real
     104       26832 : SolidMechanicsPlasticIsotropicSD::yieldFunction(const RankTwoTensor & stress, Real intnl) const
     105             : {
     106       26832 :   return _a * (_b * stress.trace() +
     107       26832 :                std::pow(std::pow(stress.secondInvariant(), 1.5) - _c * stress.thirdInvariant(),
     108             :                         1.0 / 3.0)) -
     109       26832 :          yieldStrength(intnl);
     110             : }
     111             : 
     112             : RankTwoTensor
     113       41280 : SolidMechanicsPlasticIsotropicSD::dyieldFunction_dstress(const RankTwoTensor & stress,
     114             :                                                          Real /*intnl*/) const
     115             : {
     116       41280 :   const RankTwoTensor sDev = stress.deviatoric();
     117       41280 :   const Real j2 = stress.secondInvariant();
     118       41280 :   const Real j3 = stress.thirdInvariant();
     119       41280 :   return _a * (_b * dI_sigma() + dphi_dj2(j2, j3) * _h.innerProductTranspose(dj2_dSkl(sDev)) +
     120       41280 :                dphi_dj3(j2, j3) * _h.innerProductTranspose(sDev.ddet()));
     121             : }
     122             : 
     123             : RankFourTensor
     124       10320 : SolidMechanicsPlasticIsotropicSD::dflowPotential_dstress(const RankTwoTensor & stress,
     125             :                                                          Real /*intnl*/) const
     126             : {
     127       10320 :   if (_associative)
     128             :   {
     129       10320 :     const RankTwoTensor sDev = stress.deviatoric();
     130       10320 :     const RankTwoTensor dj2 = dj2_dSkl(sDev);
     131       10320 :     const RankTwoTensor dj3 = sDev.ddet();
     132       10320 :     const Real j2 = stress.secondInvariant();
     133       10320 :     const Real j3 = stress.thirdInvariant();
     134       10320 :     return _a * (dfj2_dj2(j2, j3) *
     135       10320 :                      _h.innerProductTranspose(dj2).outerProduct(_h.innerProductTranspose(dj2)) +
     136       10320 :                  dfj2_dj3(j2, j3) *
     137       20640 :                      _h.innerProductTranspose(dj2).outerProduct(_h.innerProductTranspose(dj3)) +
     138       10320 :                  dfj3_dj2(j2, j3) *
     139       20640 :                      _h.innerProductTranspose(dj3).outerProduct(_h.innerProductTranspose(dj2)) +
     140       10320 :                  dfj3_dj3(j2, j3) *
     141       30960 :                      _h.innerProductTranspose(dj3).outerProduct(_h.innerProductTranspose(dj3)));
     142             :   }
     143             :   else
     144           0 :     return SolidMechanicsPlasticJ2::dflowPotential_dstress(stress, 0);
     145             : }
     146             : 
     147             : RankTwoTensor
     148       30960 : SolidMechanicsPlasticIsotropicSD::flowPotential(const RankTwoTensor & stress, Real intnl) const
     149             : {
     150       30960 :   if (_associative)
     151       30960 :     return dyieldFunction_dstress(stress, intnl);
     152             :   else
     153           0 :     return SolidMechanicsPlasticJ2::dyieldFunction_dstress(stress, intnl);
     154             : }

Generated by: LCOV version 1.14