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

Generated by: LCOV version 1.14