LCOV - code coverage report
Current view: top level - src/vectorpostprocessors - MixedModeEquivalentK.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #32971 (54bef8) with base c6cf66 Lines: 51 52 98.1 %
Date: 2026-05-29 20:40:07 Functions: 4 4 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 "MixedModeEquivalentK.h"
      11             : 
      12             : registerMooseObject("SolidMechanicsApp", MixedModeEquivalentK);
      13             : 
      14             : InputParameters
      15         114 : MixedModeEquivalentK::validParams()
      16             : {
      17         114 :   InputParameters params = GeneralVectorPostprocessor::validParams();
      18         114 :   params.addClassDescription("Computes the mixed-mode stress intensity factor "
      19             :                              "given the $K_I$, $K_{II}$, and $K_{III}$ stress "
      20             :                              "intensity factors");
      21         228 :   params.addParam<unsigned int>("ring_index", "Ring ID");
      22         228 :   params.addRequiredParam<VectorPostprocessorName>(
      23             :       "KI_vectorpostprocessor", "The name of the VectorPostprocessor that computes KI");
      24         228 :   params.addRequiredParam<VectorPostprocessorName>(
      25             :       "KII_vectorpostprocessor", "The name of the VectorPostprocessor that computes KII");
      26         228 :   params.addRequiredParam<VectorPostprocessorName>(
      27             :       "KIII_vectorpostprocessor", "The name of the VectorPostprocessor that computes KIII");
      28         228 :   params.addRequiredParam<std::string>("KI_vector_name", "The name of the vector that contains KI");
      29         228 :   params.addRequiredParam<std::string>("KII_vector_name",
      30             :                                        "The name of the vector that contains KII");
      31         228 :   params.addRequiredParam<std::string>("KIII_vector_name",
      32             :                                        "The name of the vector that contains KIII");
      33         228 :   params.addRequiredParam<Real>("poissons_ratio", "Poisson's ratio for the material.");
      34         114 :   return params;
      35           0 : }
      36             : 
      37          88 : MixedModeEquivalentK::MixedModeEquivalentK(const InputParameters & parameters)
      38             :   : GeneralVectorPostprocessor(parameters),
      39         176 :     _ki_vpp_name(getParam<VectorPostprocessorName>("KI_vectorpostprocessor")),
      40          88 :     _kii_vpp_name(getParam<VectorPostprocessorName>("KII_vectorpostprocessor")),
      41          88 :     _kiii_vpp_name(getParam<VectorPostprocessorName>("KIII_vectorpostprocessor")),
      42         176 :     _ki_vector_name(getParam<std::string>("KI_vector_name")),
      43         176 :     _kii_vector_name(getParam<std::string>("KII_vector_name")),
      44         176 :     _kiii_vector_name(getParam<std::string>("KIII_vector_name")),
      45          88 :     _ki_value(getVectorPostprocessorValue("KI_vectorpostprocessor", _ki_vector_name)),
      46          88 :     _kii_value(getVectorPostprocessorValue("KII_vectorpostprocessor", _kii_vector_name)),
      47          88 :     _kiii_value(getVectorPostprocessorValue("KIII_vectorpostprocessor", _kiii_vector_name)),
      48          88 :     _x_value(getVectorPostprocessorValue("KI_vectorpostprocessor", "x")),
      49          88 :     _y_value(getVectorPostprocessorValue("KI_vectorpostprocessor", "y")),
      50          88 :     _z_value(getVectorPostprocessorValue("KI_vectorpostprocessor", "z")),
      51          88 :     _position_value(getVectorPostprocessorValue("KI_vectorpostprocessor", "id")),
      52         176 :     _poissons_ratio(getParam<Real>("poissons_ratio")),
      53         176 :     _ring_index(getParam<unsigned int>("ring_index")),
      54          88 :     _x(declareVector("x")),
      55          88 :     _y(declareVector("y")),
      56          88 :     _z(declareVector("z")),
      57          88 :     _position(declareVector("id")),
      58         176 :     _k_eq(declareVector("Keq_" + Moose::stringify(_ring_index)))
      59             : {
      60          88 : }
      61             : 
      62             : void
      63         132 : MixedModeEquivalentK::initialize()
      64             : {
      65         132 :   const unsigned int num_pts = _x_value.size();
      66             : 
      67         132 :   _x.assign(num_pts, 0.0);
      68         132 :   _y.assign(num_pts, 0.0);
      69         132 :   _z.assign(num_pts, 0.0);
      70         132 :   _position.assign(num_pts, 0.0);
      71         132 :   _k_eq.assign(num_pts, 0.0);
      72         132 : }
      73             : 
      74             : void
      75         132 : MixedModeEquivalentK::execute()
      76             : {
      77         348 :   for (unsigned int i = 0; i < _k_eq.size(); ++i)
      78             :   {
      79         216 :     _x[i] = _x_value[i];
      80         216 :     _y[i] = _y_value[i];
      81         216 :     _z[i] = _z_value[i];
      82         216 :     _position[i] = _position_value[i];
      83         216 :     _k_eq[i] = std::sqrt(_ki_value[i] * _ki_value[i] + _kii_value[i] * _kii_value[i] +
      84         216 :                          1.0 / (1.0 - _poissons_ratio) * _kiii_value[i] * _kiii_value[i]);
      85             :   }
      86         132 : }

Generated by: LCOV version 1.14