LCOV - code coverage report
Current view: top level - src/materials - ExponentialEnergyBasedSoftening.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #32971 (54bef8) with base c6cf66 Lines: 27 31 87.1 %
Date: 2026-05-29 20:40:07 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://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 "ExponentialEnergyBasedSoftening.h"
      11             : 
      12             : #include "MooseMesh.h"
      13             : 
      14             : registerMooseObject("SolidMechanicsApp", ExponentialEnergyBasedSoftening);
      15             : 
      16             : InputParameters
      17          16 : ExponentialEnergyBasedSoftening::validParams()
      18             : {
      19          16 :   InputParameters params = SmearedCrackSofteningBase::validParams();
      20          16 :   params.addClassDescription(
      21             :       "Softening model with an exponential softening response upon cracking. This "
      22             :       "class is intended to be used with ComputeSmearedCrackingStress.");
      23          48 :   params.addRangeCheckedParam<Real>(
      24             :       "residual_stress",
      25          32 :       0.0,
      26             :       "residual_stress <= 1 & residual_stress >= 0",
      27             :       "The fraction of the cracking stress allowed to be maintained following a crack.");
      28          32 :   params.addRequiredRangeCheckedParam<Real>(
      29             :       "fracture_toughness",
      30             :       "fracture_toughness > 0",
      31             :       "Fracture toughness used to calculate the softening slope. ");
      32          16 :   return params;
      33           0 : }
      34             : 
      35          12 : ExponentialEnergyBasedSoftening::ExponentialEnergyBasedSoftening(const InputParameters & parameters)
      36             :   : SmearedCrackSofteningBase(parameters),
      37          12 :     _residual_stress(getParam<Real>("residual_stress")),
      38          36 :     _fracture_toughness(getParam<Real>("fracture_toughness"))
      39             : {
      40          12 : }
      41             : 
      42             : void
      43       18816 : ExponentialEnergyBasedSoftening::computeCrackingRelease(Real & stress,
      44             :                                                         Real & stiffness_ratio,
      45             :                                                         const Real /*strain*/,
      46             :                                                         const Real crack_initiation_strain,
      47             :                                                         const Real crack_max_strain,
      48             :                                                         const Real cracking_stress,
      49             :                                                         const Real youngs_modulus,
      50             :                                                         const Real poissons_ratio)
      51             : {
      52             :   mooseAssert(crack_max_strain >= crack_initiation_strain,
      53             :               "crack_max_strain must be >= crack_initiation_strain");
      54             : 
      55       18816 :   unsigned int dim = _current_elem->dim();
      56             : 
      57             :   // Get estimate of element size
      58             :   Real ele_len = 0.0;
      59       18816 :   if (dim == 3)
      60             :   {
      61       18816 :     ele_len = std::cbrt(_current_elem->volume());
      62             :   }
      63             :   else
      64             :   {
      65           0 :     ele_len = std::sqrt(_current_elem->volume());
      66             :   }
      67             : 
      68             :   // Calculate initial slope of exponential curve
      69       18816 :   const Real energy_release_rate = (_fracture_toughness * _fracture_toughness) *
      70       18816 :                                    (1 - poissons_ratio * poissons_ratio) / youngs_modulus;
      71       18816 :   const Real frac_stress_sqr = cracking_stress * cracking_stress;
      72       18816 :   const Real l_max = 2 * energy_release_rate * youngs_modulus / frac_stress_sqr;
      73             : 
      74             :   // Check against maximum allowed element size - avoid the divide by zero by capping at a large
      75             :   // slope
      76       18816 :   Real initial_slope = -1e5 * youngs_modulus;
      77       18816 :   if (ele_len < l_max) // TODO: need to log if this isn't true
      78           0 :     initial_slope =
      79           0 :         -frac_stress_sqr / (energy_release_rate / ele_len - frac_stress_sqr / (2 * youngs_modulus));
      80             : 
      81             :   // Compute stress that follows exponental curve
      82       18816 :   stress = cracking_stress *
      83       18816 :            (_residual_stress +
      84       18816 :             (1.0 - _residual_stress) * std::exp(initial_slope / cracking_stress *
      85       18816 :                                                 (crack_max_strain - crack_initiation_strain)));
      86             :   // Compute ratio of current stiffness to original stiffness
      87       18816 :   stiffness_ratio = stress * crack_initiation_strain / (crack_max_strain * cracking_stress);
      88       18816 : }

Generated by: LCOV version 1.14