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 : 12 : // MOOSE includes 13 : #include "Function.h" 14 : #include "MooseMesh.h" 15 : #include "MooseVariable.h" 16 : #include "SubProblem.h" 17 : 18 : #include "libmesh/system.h" 19 : 20 : registerMooseObject("XFEMApp", ParisLaw); 21 : 22 : InputParameters 23 8 : ParisLaw::validParams() 24 : { 25 8 : InputParameters params = GeneralPostprocessor::validParams(); 26 8 : params.addClassDescription("Computes the crack extension size at all active crack front points."); 27 16 : params.addRequiredParam<Real>( 28 : "max_growth_size", 29 : "the max growth size at the crack front in each increment of a fatigue simulation"); 30 16 : params.addRequiredParam<Real>("paris_law_c", "parameter C in the Paris law for fatigue"); 31 16 : params.addRequiredParam<Real>("paris_law_m", "parameter m in the Paris law for fatigue"); 32 8 : return params; 33 0 : } 34 : 35 4 : ParisLaw::ParisLaw(const InputParameters & parameters) 36 : : GeneralPostprocessor(parameters), 37 4 : _cutter(&_fe_problem.getUserObject<CrackMeshCut3DUserObject>("cut_mesh")), 38 8 : _max_growth_size(getParam<Real>("max_growth_size")), 39 8 : _paris_law_c(getParam<Real>("paris_law_c")), 40 12 : _paris_law_m(getParam<Real>("paris_law_m")) 41 : { 42 4 : } 43 : 44 : void 45 17 : ParisLaw::initialize() 46 : { 47 17 : } 48 : 49 : void 50 17 : ParisLaw::execute() 51 : { 52 : // Generate _active_boundary and _inactive_boundary_pos; 53 : // This is a duplicated call before the one in CrackMeshCut3DUserObject; 54 : // That one cannot be deleted because this one is for subcritical cracking only. 55 17 : _cutter->findActiveBoundaryNodes(); 56 : 57 17 : std::vector<int> index = _cutter->getFrontPointsIndex(); 58 : 59 51 : const VectorPostprocessorValue & k1 = getVectorPostprocessorValueByName("II_KI_1", "II_KI_1"); 60 51 : const VectorPostprocessorValue & k2 = getVectorPostprocessorValueByName("II_KII_1", "II_KII_1"); 61 : mooseAssert(k1.size() == k2.size(), "KI and KII VPPs should have the same size"); 62 17 : unsigned int size_this_segment = k1.size(); 63 : 64 17 : _effective_k.clear(); 65 : 66 85 : for (unsigned int i = 0; i < size_this_segment; ++i) 67 : { 68 68 : int ind = index[i]; 69 68 : if (ind == -1) 70 34 : _effective_k.push_back(0.0); 71 34 : else if (ind >= 0) 72 : { 73 34 : Real effective_k = sqrt(pow(k1[ind], 2) + 2 * pow(k2[ind], 2)); 74 34 : _effective_k.push_back(effective_k); 75 : } 76 : else 77 0 : mooseError("index must be either -1 (inactive) or >= 0 (active)"); 78 : } 79 : 80 17 : Real _max_k = *std::max_element(_effective_k.begin(), _effective_k.end()); 81 : 82 : // Calculate dN 83 17 : _dn = (unsigned long int)(_max_growth_size / (_paris_law_c * pow(_max_k, _paris_law_m))); 84 : 85 17 : _growth_size.clear(); 86 : 87 85 : for (unsigned int i = 0; i < size_this_segment; ++i) 88 : { 89 68 : int ind = index[i]; 90 68 : if (ind == -1) 91 34 : _growth_size.push_back(0.0); 92 34 : else if (ind >= 0) 93 : { 94 34 : Real effective_k = _effective_k[i]; 95 34 : Real growth_size = _max_growth_size * pow(effective_k / _max_k, _paris_law_m); 96 34 : _growth_size.push_back(growth_size); 97 : } 98 : } 99 : 100 17 : _cutter->setSubCriticalGrowthSize(_growth_size); 101 17 : } 102 : 103 : Real 104 17 : ParisLaw::getValue() const 105 : { 106 17 : return Real(_dn); 107 : }