www.mooseframework.org
CrackDataSampler.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 "CrackDataSampler.h"
9 #include "PostprocessorInterface.h"
10 #include "SamplerBase.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<VectorPostprocessor>();
17 
18  params += validParams<SamplerBase>();
19 
20  params.addRequiredParam<std::vector<PostprocessorName>>(
21  "postprocessors", "The postprocessors whose values are to be reported");
22  params.addRequiredParam<UserObjectName>("crack_front_definition",
23  "The CrackFrontDefinition user object name");
24  MooseEnum position_type("Angle Distance", "Distance");
25  params.addParam<MooseEnum>(
26  "position_type",
27  position_type,
28  "The method used to calculate position along crack front. Options are: " +
29  position_type.getRawNames());
30  params.addClassDescription("Outputs the values of a set of domain integral postprocessors as a "
31  "vector, along with their positions along the crack front.");
32 
33  return params;
34 }
35 
36 CrackDataSampler::CrackDataSampler(const InputParameters & parameters)
37  : GeneralVectorPostprocessor(parameters),
38  SamplerBase(parameters, this, _communicator),
39  _crack_front_definition(&getUserObject<CrackFrontDefinition>("crack_front_definition")),
40  _position_type(getParam<MooseEnum>("position_type"))
41 {
42  std::vector<PostprocessorName> pps_names(
43  getParam<std::vector<PostprocessorName>>("postprocessors"));
44  for (unsigned int i = 0; i < pps_names.size(); ++i)
45  {
46  if (!hasPostprocessorByName(pps_names[i]))
47  mooseError("In CrackDataSampler, postprocessor with name: ", pps_names[i], " does not exist");
48  _domain_integral_postprocessor_values.push_back(&getPostprocessorValueByName(pps_names[i]));
49  }
50  std::vector<std::string> var_names;
51  var_names.push_back(name());
52  SamplerBase::setupVariables(var_names);
53 }
54 
55 void
57 {
60  mooseError("In CrackDataSampler, number of crack front nodes != number of domain integral "
61  "postprocessors");
63  mooseError(
64  "In CrackDataSampler, 'position_type = Angle' specified, but angle is not available. ",
65  "Must specify 'crack_mouth_boundary' in CrackFrontDefinition");
66  SamplerBase::initialize();
67 }
68 
69 void
71 {
72  if (processor_id() == 0)
73  {
74  std::vector<Real> values;
75  for (unsigned int i = 0; i < _domain_integral_postprocessor_values.size(); ++i)
76  {
77  values.clear();
78  const Point * crack_front_point = _crack_front_definition->getCrackFrontPoint(i);
79  Real position;
80  if (_position_type == "Angle")
82  else
84 
85  values.push_back(*_domain_integral_postprocessor_values[i]);
86  addSample(*crack_front_point, position, values);
87  }
88  }
89 }
90 
91 void
93 {
94  SamplerBase::finalize();
95 }
std::vector< const PostprocessorValue * > _domain_integral_postprocessor_values
The vector of PostprocessorValue objects that are used to get the values of the domain integral postp...
unsigned int getNumCrackFrontPoints() const
CrackDataSampler(const InputParameters &parameters)
Class constructor.
virtual void execute()
Populates the postprocessor vector of values with the supplied postprocessors.
const Point * getCrackFrontPoint(const unsigned int point_index) const
const CrackFrontDefinition *const _crack_front_definition
Works on top of NodalNormalsPreprocessor.
virtual void finalize()
Real getAngleAlongFront(const unsigned int point_index) const
virtual void initialize()
Initialize, clears the postprocessor vector.
InputParameters validParams< CrackDataSampler >()
Real getDistanceAlongFront(const unsigned int point_index) const
MooseEnum _position_type