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

Generated by: LCOV version 1.14