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 "DomainIntegralTopologicalQFunction.h" 11 : 12 : registerMooseObject("SolidMechanicsApp", DomainIntegralTopologicalQFunction); 13 : 14 : InputParameters 15 90 : DomainIntegralTopologicalQFunction::validParams() 16 : { 17 90 : InputParameters params = AuxKernel::validParams(); 18 90 : params.addClassDescription( 19 : "Determines if a node is within the ring of the crack front defintion; this object is " 20 : "normally created by the DomainIntegralAction."); 21 180 : params.addRequiredParam<unsigned int>("ring_index", 22 : "The ring of elements that defines the integration domain"); 23 180 : params.addRequiredParam<UserObjectName>("crack_front_definition", 24 : "The CrackFrontDefinition user object name"); 25 180 : params.addParam<unsigned int>( 26 : "crack_front_point_index", 27 : "The index of the point on the crack front corresponding to this q function"); 28 90 : params.set<bool>("use_displaced_mesh") = false; 29 90 : return params; 30 0 : } 31 : 32 78 : DomainIntegralTopologicalQFunction::DomainIntegralTopologicalQFunction( 33 78 : const InputParameters & parameters) 34 : : AuxKernel(parameters), 35 78 : _ring_number(getParam<unsigned int>("ring_index")), 36 78 : _crack_front_definition(&getUserObject<CrackFrontDefinition>("crack_front_definition")), 37 156 : _has_crack_front_point_index(isParamValid("crack_front_point_index")), 38 78 : _crack_front_point_index( 39 132 : _has_crack_front_point_index ? getParam<unsigned int>("crack_front_point_index") : 0), 40 78 : _treat_as_2d(false) 41 : { 42 78 : } 43 : 44 : void 45 78 : DomainIntegralTopologicalQFunction::initialSetup() 46 : { 47 78 : _treat_as_2d = _crack_front_definition->treatAs2D(); 48 : 49 78 : if (_treat_as_2d) 50 : { 51 24 : if (_has_crack_front_point_index) 52 : { 53 0 : mooseWarning( 54 : "crack_front_point_index ignored because CrackFrontDefinition is set to treat as 2D"); 55 : } 56 : } 57 : else 58 : { 59 54 : if (!_has_crack_front_point_index) 60 : { 61 0 : mooseError("crack_front_point_index must be specified in DomainIntegralTopologicalQFunction"); 62 : } 63 : } 64 78 : } 65 : 66 : Real 67 12472 : DomainIntegralTopologicalQFunction::computeValue() 68 : { 69 : 70 : Real q = 0; 71 12472 : bool is_node_in_ring = _crack_front_definition->isNodeInRing( 72 12472 : _ring_number, _current_node->id(), _crack_front_point_index); 73 12472 : if (is_node_in_ring) 74 : q = 1; 75 : 76 12472 : return q; 77 : }