LCOV - code coverage report
Current view: top level - src/auxkernels - RankTwoBasedFailureCriteriaNOSPD.C (source / functions) Hit Total Coverage
Test: idaholab/moose peridynamics: #31405 (292dce) with base fef103 Lines: 22 38 57.9 %
Date: 2025-09-04 07:55:08 Functions: 3 3 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 "RankTwoBasedFailureCriteriaNOSPD.h"
      11             : #include "RankTwoScalarTools.h"
      12             : 
      13             : registerMooseObject("PeridynamicsApp", RankTwoBasedFailureCriteriaNOSPD);
      14             : 
      15             : InputParameters
      16          22 : RankTwoBasedFailureCriteriaNOSPD::validParams()
      17             : {
      18          22 :   InputParameters params = BondStatusBasePD::validParams();
      19          22 :   params.addClassDescription(
      20             :       "Class for rank two tensor based failure criteria in non-ordinary state-based model");
      21             : 
      22          44 :   params.addRequiredParam<MaterialPropertyName>("rank_two_tensor",
      23             :                                                 "The rank two material tensor name");
      24             :   MooseEnum FailureCriterionTypes(
      25          44 :       "Axial MaxPrincipal TrescaStrain TrescaStress VonMisesStrain VonMisesStress");
      26          44 :   params.addRequiredParam<MooseEnum>("failure_criterion",
      27             :                                      FailureCriterionTypes,
      28             :                                      "Which stress based failure criterion to be used");
      29             : 
      30          22 :   return params;
      31          22 : }
      32             : 
      33          12 : RankTwoBasedFailureCriteriaNOSPD::RankTwoBasedFailureCriteriaNOSPD(
      34          12 :     const InputParameters & parameters)
      35             :   : BondStatusBasePD(parameters),
      36          12 :     _failure_criterion(getParam<MooseEnum>("failure_criterion")),
      37          12 :     _tensor(nullptr)
      38             : {
      39          24 :   if (hasMaterialProperty<RankTwoTensor>("rank_two_tensor"))
      40          12 :     _tensor = &getMaterialProperty<RankTwoTensor>("rank_two_tensor");
      41             :   else
      42           0 :     mooseError("Error in RankTwoBasedFailureCriteriaNOSPD! Required rank two tensor is not "
      43             :                "available for current peridynamics model!");
      44             : 
      45          12 :   if (isNodal())
      46           0 :     paramError("variable", "This AuxKernel only supports Elemental fields");
      47          12 : }
      48             : 
      49             : Real
      50       15344 : RankTwoBasedFailureCriteriaNOSPD::computeFailureCriterionValue()
      51             : {
      52             :   Real val = 0.0;
      53       15344 :   RankTwoTensor avg_tensor = 0.5 * ((*_tensor)[0] + (*_tensor)[1]);
      54             :   Point dirc;
      55             : 
      56       15344 :   switch (_failure_criterion)
      57             :   {
      58           0 :     case 0:
      59           0 :       val = RankTwoScalarTools::axialStress(
      60           0 :           avg_tensor, *_current_elem->node_ptr(0), *_current_elem->node_ptr(1), dirc);
      61           0 :       break;
      62             :     case 1:
      63             :       val = RankTwoScalarTools::maxPrincipal(avg_tensor, dirc);
      64             :       break;
      65           0 :     case 2:
      66           0 :       val = 4.0 / 3.0 * RankTwoScalarTools::maxShear(avg_tensor);
      67           0 :       break;
      68           0 :     case 3:
      69           0 :       val = 2.0 * RankTwoScalarTools::maxShear(avg_tensor);
      70           0 :       break;
      71           0 :     case 4:
      72           0 :       val = RankTwoScalarTools::effectiveStrain(avg_tensor);
      73             :       break;
      74       15344 :     case 5:
      75       15344 :       val = RankTwoScalarTools::vonMisesStress(avg_tensor);
      76             :       break;
      77           0 :     default:
      78           0 :       mooseError("Unsupported rank two tensor-based failure criterion. Choose from: Axial "
      79             :                  "MaxPrincipal TrescaStrain TrescaStress VonMisesStrain VonMisesStress");
      80             :   }
      81             : 
      82       15344 :   return val - _critical_val[0];
      83             : }

Generated by: LCOV version 1.14