www.mooseframework.org
CrackFrontData.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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("TensorMechanicsApp", CrackFrontData);
20 
22 
23 InputParameters
25 {
26  InputParameters params = GeneralPostprocessor::validParams();
27  params.addClassDescription("Determines which nodes are along the crack front");
28  params.addRequiredParam<VariableName>(
29  "variable", "The name of a variable whose value at the crack front is to be reported");
30  params.addRequiredParam<UserObjectName>("crack_front_definition",
31  "The CrackFrontDefinition user object name");
32  params.addParam<unsigned int>(
33  "crack_front_point_index",
34  "The index of the point on the crack front where data is to be reported");
35  params.addParam<Real>("scale_factor", 1, "A scale factor to be applied to the reported quantity");
36  return params;
37 }
38 
39 CrackFrontData::CrackFrontData(const InputParameters & parameters)
40  : GeneralPostprocessor(parameters),
41  _crack_front_definition(&getUserObject<CrackFrontDefinition>("crack_front_definition")),
42  _crack_front_point_index(isParamValid("crack_front_point_index")
43  ? getParam<unsigned int>("crack_front_point_index")
44  : 0),
45  _crack_front_node(NULL),
46  _mesh(_subproblem.mesh()),
47  _var_name(parameters.get<VariableName>("variable")),
48  _scale_factor(getParam<Real>("scale_factor")),
49  _field_var(_subproblem.getStandardVariable(_tid, _var_name))
50 {
51  if (!_field_var.isNodal())
52  mooseError("CrackFrontData can be output only for nodal variables, variable '",
53  _var_name,
54  "' is not nodal");
55 }
56 
57 void
59 {
60  if (!(_crack_front_point_index < _crack_front_definition->getNumCrackFrontPoints()))
61  mooseError("crack_front_point_index out of range in CrackFrontData");
63  mooseError("CrackFrontData not currently supported if crack front is defined with points "
64  "rather than nodes");
65 
67 }
68 
69 Real
71 {
72  Real value = 0;
73 
74  if (_crack_front_node->processor_id() == processor_id())
75  value = _field_var.getNodalValue(*_crack_front_node);
76 
77  gatherSum(value);
78 
79  return _scale_factor * value;
80 }
CrackFrontData::_field_var
MooseVariable & _field_var
Definition: CrackFrontData.h:47
CrackFrontData::_crack_front_point_index
const unsigned int _crack_front_point_index
Definition: CrackFrontData.h:42
CrackFrontDefinition::getCrackFrontNodePtr
const Node * getCrackFrontNodePtr(const unsigned int node_index) const
Definition: CrackFrontDefinition.C:1048
registerMooseObject
registerMooseObject("TensorMechanicsApp", CrackFrontData)
CrackFrontData::_var_name
std::string _var_name
Definition: CrackFrontData.h:45
CrackFrontDefinition
Works on top of NodalNormalsPreprocessor.
Definition: CrackFrontDefinition.h:36
CrackFrontData.h
CrackFrontData::validParams
static InputParameters validParams()
Definition: CrackFrontData.C:24
CrackFrontData::CrackFrontData
CrackFrontData(const InputParameters &parameters)
Definition: CrackFrontData.C:39
defineLegacyParams
defineLegacyParams(CrackFrontData)
CrackFrontData::_scale_factor
const Real _scale_factor
Definition: CrackFrontData.h:46
CrackFrontData::_crack_front_node
const Node * _crack_front_node
Definition: CrackFrontData.h:43
validParams
InputParameters validParams()
CrackFrontData::getValue
virtual Real getValue()
This will return the degrees of freedom in the system.
Definition: CrackFrontData.C:70
CrackFrontData::initialize
virtual void initialize()
Definition: CrackFrontData.C:58
CrackFrontData
Definition: CrackFrontData.h:25
CrackFrontData::_crack_front_definition
const CrackFrontDefinition *const _crack_front_definition
Definition: CrackFrontData.h:41
CrackFrontDefinition::hasCrackFrontNodes
bool hasCrackFrontNodes() const
Definition: CrackFrontDefinition.h:89