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

Generated by: LCOV version 1.14