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

Generated by: LCOV version 1.14