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 "CrackFrontData.h" 11 : 12 : // MOOSE includes 13 : #include "MooseMesh.h" 14 : #include "MooseVariable.h" 15 : #include "SubProblem.h" 16 : 17 : #include "libmesh/boundary_info.h" 18 : 19 : registerMooseObject("SolidMechanicsApp", CrackFrontData); 20 : 21 : InputParameters 22 120 : CrackFrontData::validParams() 23 : { 24 120 : InputParameters params = GeneralPostprocessor::validParams(); 25 120 : params.addClassDescription("Determines which nodes are along the crack front"); 26 240 : params.addRequiredParam<VariableName>( 27 : "variable", "The name of a variable whose value at the crack front is to be reported"); 28 240 : params.addRequiredParam<UserObjectName>("crack_front_definition", 29 : "The CrackFrontDefinition user object name"); 30 240 : params.addParam<unsigned int>( 31 : "crack_front_point_index", 32 : "The index of the point on the crack front where data is to be reported"); 33 240 : params.addParam<Real>("scale_factor", 1, "A scale factor to be applied to the reported quantity"); 34 120 : return params; 35 0 : } 36 : 37 80 : CrackFrontData::CrackFrontData(const InputParameters & parameters) 38 : : GeneralPostprocessor(parameters), 39 80 : _crack_front_definition(&getUserObject<CrackFrontDefinition>("crack_front_definition")), 40 80 : _crack_front_point_index(isParamValid("crack_front_point_index") 41 240 : ? getParam<unsigned int>("crack_front_point_index") 42 : : 0), 43 80 : _crack_front_node(NULL), 44 80 : _mesh(_subproblem.mesh()), 45 80 : _var_name(parameters.get<VariableName>("variable")), 46 160 : _scale_factor(getParam<Real>("scale_factor")), 47 80 : _field_var(_subproblem.getStandardVariable(_tid, _var_name)), 48 80 : _value(0) 49 : { 50 80 : if (!_field_var.isNodal()) 51 0 : mooseError("CrackFrontData can be output only for nodal variables, variable '", 52 : _var_name, 53 : "' is not nodal"); 54 80 : } 55 : 56 : void 57 100 : CrackFrontData::initialize() 58 : { 59 100 : if (!(_crack_front_point_index < _crack_front_definition->getNumCrackFrontPoints())) 60 0 : mooseError("crack_front_point_index out of range in CrackFrontData"); 61 100 : if (!_crack_front_definition->hasCrackFrontNodes()) 62 0 : mooseError("CrackFrontData not currently supported if crack front is defined with points " 63 : "rather than nodes"); 64 : 65 100 : _crack_front_node = _crack_front_definition->getCrackFrontNodePtr(_crack_front_point_index); 66 100 : } 67 : void 68 100 : CrackFrontData::execute() 69 : { 70 100 : _value = 0; 71 : 72 100 : if (_crack_front_node->processor_id() == processor_id()) 73 80 : _value = _field_var.getNodalValue(*_crack_front_node); 74 100 : } 75 : 76 : Real 77 100 : CrackFrontData::getValue() const 78 : { 79 : 80 100 : return _scale_factor * _value; 81 : } 82 : 83 : void 84 100 : CrackFrontData::finalize() 85 : { 86 100 : gatherSum(_value); 87 100 : }