LCOV - code coverage report
Current view: top level - src/materials - ADExponentialSoftening.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 26 28 92.9 %
Date: 2025-07-25 05:00:39 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 "ADExponentialSoftening.h"
      11             : 
      12             : #include "MooseMesh.h"
      13             : 
      14             : registerMooseObject("SolidMechanicsApp", ADExponentialSoftening);
      15             : 
      16             : InputParameters
      17         208 : ADExponentialSoftening::validParams()
      18             : {
      19         208 :   InputParameters params = ADSmearedCrackSofteningBase::validParams();
      20         208 :   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         624 :   params.addRangeCheckedParam<Real>(
      25             :       "residual_stress",
      26         416 :       0.0,
      27             :       "residual_stress <= 1 & residual_stress >= 0",
      28             :       "The fraction of the cracking stress allowed to be maintained following a crack.");
      29         624 :   params.addRangeCheckedParam<Real>(
      30             :       "alpha",
      31         416 :       -1.0,
      32             :       "alpha <= 0",
      33             :       "Initial slope of the exponential softening curve at crack initiation. "
      34             :       "If not specified, it is equal to the negative of the Young's modulus.");
      35         624 :   params.addRangeCheckedParam<Real>(
      36             :       "beta",
      37         416 :       1.0,
      38             :       "beta >= 0",
      39             :       "Multiplier applied to alpha to control the exponential softening "
      40             :       "behavior.");
      41         208 :   return params;
      42           0 : }
      43             : 
      44         156 : ADExponentialSoftening::ADExponentialSoftening(const InputParameters & parameters)
      45             :   : ADSmearedCrackSofteningBase(parameters),
      46         156 :     _residual_stress(getParam<Real>("residual_stress")),
      47         312 :     _alpha(getParam<Real>("alpha")),
      48         156 :     _alpha_set_by_user(parameters.isParamSetByUser("alpha")),
      49         468 :     _beta(getParam<Real>("beta"))
      50             : {
      51         156 : }
      52             : 
      53             : void
      54      299248 : ADExponentialSoftening::computeCrackingRelease(ADReal & stress,
      55             :                                                ADReal & stiffness_ratio,
      56             :                                                const ADReal & /*strain*/,
      57             :                                                const ADReal & crack_initiation_strain,
      58             :                                                const ADReal & crack_max_strain,
      59             :                                                const ADReal & cracking_stress,
      60             :                                                const ADReal & youngs_modulus)
      61             : {
      62             :   mooseAssert(crack_max_strain >= crack_initiation_strain,
      63             :               "crack_max_strain must be >= crack_initiation_strain");
      64             : 
      65      299248 :   ADReal alpha = 0.0;
      66      299248 :   if (_alpha_set_by_user)
      67           0 :     alpha = _alpha;
      68             :   else
      69      299248 :     alpha = -youngs_modulus;
      70             : 
      71             :   // Compute stress that follows exponental curve
      72      299248 :   stress = cracking_stress *
      73      299248 :            (_residual_stress +
      74      598496 :             (1.0 - _residual_stress) * std::exp(alpha * _beta / cracking_stress *
      75      299248 :                                                 (crack_max_strain - crack_initiation_strain)));
      76             :   // Compute ratio of current stiffness to original stiffness
      77      299248 :   stiffness_ratio = stress * crack_initiation_strain / (crack_max_strain * cracking_stress);
      78      299248 : }

Generated by: LCOV version 1.14