LCOV - code coverage report
Current view: top level - src/reporters - ParisLaw.C (source / functions) Hit Total Coverage
Test: idaholab/moose xfem: #31653 (2d163b) with base 0cc44f Lines: 35 36 97.2 %
Date: 2025-11-04 20:44:03 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 "ParisLaw.h"
      11             : #include "VectorPostprocessorInterface.h"
      12             : #include "MathUtils.h"
      13             : #include <limits>
      14             : 
      15             : registerMooseObject("XFEMApp", ParisLaw);
      16             : 
      17             : InputParameters
      18           8 : ParisLaw::validParams()
      19             : {
      20           8 :   InputParameters params = CrackGrowthReporterBase::validParams();
      21           8 :   params.addClassDescription(
      22             :       "This reporter computes the crack growth increment at all active crack front points "
      23             :       "in the CrackMeshCut3DUserObject for fatigue crack growth based on the Paris Law. "
      24             :       "Data for crack growth rates in this reporter are stored in the same order as in the "
      25             :       "fracture integral VectorPostprocessors.");
      26          16 :   params.addRequiredParam<Real>("paris_law_c", "parameter C in the Paris law for fatigue");
      27          16 :   params.addRequiredParam<Real>("paris_law_m", "parameter m in the Paris law for fatigue");
      28          16 :   params.addParam<VectorPostprocessorName>(
      29             :       "kii_vectorpostprocessor", "II_KII_1", "Name of the vectorpostprocessor that computes K_II");
      30          16 :   params.addParam<ReporterValueName>(
      31             :       "growth_increment_name",
      32             :       "growth_increment",
      33             :       "ReporterValueName for storing computed growth increments for the crack front points.");
      34          16 :   params.addParam<ReporterValueName>(
      35             :       "cycles_to_max_growth_increment_name",
      36             :       "dN",
      37             :       "ReporterValueName for storing computed number of cycles to reach max_growth_increment.");
      38           8 :   return params;
      39           0 : }
      40             : 
      41           4 : ParisLaw::ParisLaw(const InputParameters & parameters)
      42             :   : CrackGrowthReporterBase(parameters),
      43           4 :     _paris_law_c(getParam<Real>("paris_law_c")),
      44           8 :     _paris_law_m(getParam<Real>("paris_law_m")),
      45           4 :     _kii_vpp(getVectorPostprocessorValue(
      46           4 :         "kii_vectorpostprocessor", getParam<VectorPostprocessorName>("kii_vectorpostprocessor"))),
      47          12 :     _dn(declareValueByName<Real>(getParam<ReporterValueName>("cycles_to_max_growth_increment_name"),
      48             :                                  REPORTER_MODE_ROOT)),
      49           8 :     _growth_increment(declareValueByName<std::vector<Real>>(
      50           4 :         getParam<ReporterValueName>("growth_increment_name"), REPORTER_MODE_ROOT))
      51             : {
      52           4 : }
      53             : 
      54             : void
      55          38 : ParisLaw::computeGrowth(std::vector<int> & index)
      56             : {
      57          38 :   _growth_increment.resize(_ki_x.size(), 0.0);
      58          38 :   std::vector<Real> effective_k(_ki_x.size(), 0.0);
      59         190 :   for (std::size_t i = 0; i < _ki_vpp.size(); ++i)
      60         152 :     if (index[i] != -1)
      61          76 :       effective_k[i] = std::sqrt(Utility::pow<2>(_ki_vpp[i]) + 2 * Utility::pow<2>(_kii_vpp[i]));
      62             : 
      63          38 :   Real _max_k = *std::max_element(effective_k.begin(), effective_k.end());
      64          38 :   if (_max_k == 0)
      65           4 :     _dn = std::numeric_limits<Real>::max();
      66             :   else
      67          34 :     _dn = _max_growth_increment / (_paris_law_c * std::pow(_max_k, _paris_law_m));
      68             : 
      69         190 :   for (std::size_t i = 0; i < _ki_vpp.size(); ++i)
      70         152 :     if (index[i] != -1)
      71             :     {
      72          76 :       if (_max_k == 0)
      73           8 :         _growth_increment[i] = 0;
      74             :       else
      75          68 :         _growth_increment[i] =
      76          68 :             _max_growth_increment * std::pow(effective_k[i] / _max_k, _paris_law_m);
      77             :     }
      78          38 : }

Generated by: LCOV version 1.14