www.mooseframework.org
CrackFrontData.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #include "CrackFrontData.h"
9 
10 // MOOSE includes
11 #include "MooseMesh.h"
12 #include "MooseVariable.h"
13 #include "SubProblem.h"
14 
15 #include "libmesh/boundary_info.h"
16 
17 template <>
18 InputParameters
20 {
21  InputParameters params = validParams<GeneralPostprocessor>();
22  params.addRequiredParam<VariableName>(
23  "variable", "The name of a variable whose value at the crack front is to be reported");
24  params.addRequiredParam<UserObjectName>("crack_front_definition",
25  "The CrackFrontDefinition user object name");
26  params.addParam<unsigned int>(
27  "crack_front_point_index",
28  "The index of the point on the crack front where data is to be reported");
29  params.addParam<Real>("scale_factor", 1, "A scale factor to be applied to the reported quantity");
30  return params;
31 }
32 
33 CrackFrontData::CrackFrontData(const InputParameters & parameters)
34  : GeneralPostprocessor(parameters),
35  _crack_front_definition(&getUserObject<CrackFrontDefinition>("crack_front_definition")),
36  _crack_front_point_index(isParamValid("crack_front_point_index")
37  ? getParam<unsigned int>("crack_front_point_index")
38  : 0),
39  _crack_front_node(NULL),
40  _mesh(_subproblem.mesh()),
41  _var_name(parameters.get<VariableName>("variable")),
42  _scale_factor(getParam<Real>("scale_factor"))
43 {
44  if (!_subproblem.getVariable(_tid, _var_name).isNodal())
45  mooseError("CrackFrontData can be output only for nodal variables, variable '",
46  _var_name,
47  "' is not nodal");
48 }
49 
50 void
52 {
53  if (!(_crack_front_point_index < _crack_front_definition->getNumCrackFrontPoints()))
54  mooseError("crack_front_point_index out of range in CrackFrontData");
56  mooseError("CrackFrontData not currently supported if crack front is defined with points "
57  "rather than nodes");
58 
60 }
61 
62 Real
64 {
65  Real value = 0;
66 
67  if (_crack_front_node->processor_id() == processor_id())
68  value = _subproblem.getVariable(_tid, _var_name).getNodalValue(*_crack_front_node);
69 
70  gatherSum(value);
71 
72  return _scale_factor * value;
73 }
CrackFrontData(const InputParameters &parameters)
const CrackFrontDefinition *const _crack_front_definition
const Real _scale_factor
virtual Real getValue()
This will return the degrees of freedom in the system.
Works on top of NodalNormalsPreprocessor.
const unsigned int _crack_front_point_index
std::string _var_name
virtual void initialize()
InputParameters validParams< CrackFrontData >()
bool hasCrackFrontNodes() const
const Node * _crack_front_node
const Node * getCrackFrontNodePtr(const unsigned int node_index) const