www.mooseframework.org
Postprocessor.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 "Postprocessor.h"
11 #include "UserObject.h"
12 #include "ReporterName.h"
13 #include "ReporterContext.h"
14 #include "FEProblemBase.h"
15 
18 {
20  params += OutputInterface::validParams();
22  ExecFlagEnum & exec_enum = params.set<ExecFlagEnum>("execute_on", true);
24 
25  params.addParamNamesToGroup("outputs", "Advanced");
26  params.registerBase("Postprocessor");
27  return params;
28 }
29 
31  : OutputInterface(moose_object->parameters()),
32  NonADFunctorInterface(moose_object),
33  Moose::FunctorBase<Real>(moose_object->name()),
34  _pp_name(moose_object->name()),
35  _current_value(declareValue(*moose_object)),
36  _pp_moose_object(*moose_object)
37 {
38 }
39 
40 const PostprocessorValue &
42 {
43  auto & fe_problem =
44  *moose_object.parameters().getCheckedPointerParam<FEProblemBase *>("_fe_problem_base");
45 
46  const PostprocessorReporterName r_name(_pp_name);
47 
48  const bool is_thread_0 = moose_object.parameters().get<THREAD_ID>("_tid") == 0;
49  mooseAssert(is_thread_0 ==
50  !fe_problem.getReporterData().hasReporterValue<PostprocessorValue>(r_name),
51  "Postprocessor Reporter threaded value declaration mismatch");
52 
53  // Declare the Reporter value on thread 0 only; this lets us add error checking to
54  // make sure that it really is added only once
55  if (is_thread_0)
56  fe_problem.getReporterData(ReporterData::WriteKey())
58  r_name, REPORTER_MODE_UNSET, moose_object);
59 
60  // At this point, thread 0 should have declared the value and getting it should be valid
61  return fe_problem.getReporterData().getReporterValue<PostprocessorValue>(r_name);
62 }
63 
65 Postprocessor::evaluate(const ElemArg & /*elem_arg*/, const Moose::StateArg & /*state*/) const
66 {
67  return getCurrentValue();
68 }
69 
71 Postprocessor::evaluate(const FaceArg & /*face*/, const Moose::StateArg & /*state*/) const
72 {
73  return getCurrentValue();
74 }
75 
77 Postprocessor::evaluate(const ElemQpArg & /*elem_qp*/, const Moose::StateArg & /*state*/) const
78 {
79  return getCurrentValue();
80 }
81 
83 Postprocessor::evaluate(const ElemSideQpArg & /*elem_side_qp*/,
84  const Moose::StateArg & /*state*/) const
85 {
86  return getCurrentValue();
87 }
88 
90 Postprocessor::evaluate(const ElemPointArg & /*elem_point_arg*/,
91  const Moose::StateArg & /*state*/) const
92 {
93  return getCurrentValue();
94 }
95 
97 Postprocessor::evaluate(const NodeArg & /*node_arg*/, const Moose::StateArg & /*state*/) const
98 {
99  return getCurrentValue();
100 }
101 
104  const Moose::StateArg & /*state*/) const
105 {
106  return 0;
107 }
108 
110 Postprocessor::evaluateGradient(const FaceArg & /*face*/, const Moose::StateArg & /*state*/) const
111 {
112  return 0;
113 }
114 
117  const Moose::StateArg & /*state*/) const
118 {
119  return 0;
120 }
121 
124  const Moose::StateArg & /*state*/) const
125 {
126  return 0;
127 }
128 
131  const Moose::StateArg & /*state*/) const
132 {
133  return 0;
134 }
135 
138  const Moose::StateArg & /*state*/) const
139 {
140  return 0;
141 }
142 
143 typename Postprocessor::DotType
144 Postprocessor::evaluateDot(const ElemArg & /*elem_arg*/, const Moose::StateArg & /*state*/) const
145 {
147  return 0;
148 }
149 
150 typename Postprocessor::DotType
151 Postprocessor::evaluateDot(const FaceArg & /*face*/, const Moose::StateArg & /*state*/) const
152 {
154  return 0;
155 }
156 
157 typename Postprocessor::DotType
158 Postprocessor::evaluateDot(const ElemQpArg & /*elem_qp*/, const Moose::StateArg & /*state*/) const
159 {
161  return 0;
162 }
163 
164 typename Postprocessor::DotType
165 Postprocessor::evaluateDot(const ElemSideQpArg & /*elem_side_qp*/,
166  const Moose::StateArg & /*state*/) const
167 {
169  return 0;
170 }
171 
172 typename Postprocessor::DotType
173 Postprocessor::evaluateDot(const ElemPointArg & /*elem_point_arg*/,
174  const Moose::StateArg & /*state*/) const
175 {
177  return 0;
178 }
179 
180 typename Postprocessor::DotType
181 Postprocessor::evaluateDot(const NodeArg & /*node_arg*/, const Moose::StateArg & /*state*/) const
182 {
184  return 0;
185 }
186 
187 void
189 {
190  mooseDoOnce(_pp_moose_object.mooseWarning(
191  "The time derivative functor operator was called on this post-processor.\n\nA zero value "
192  "will always be returned, even if the post-processor value changes with time."));
193 }
An interface for accessing Moose::Functors for systems that do not care about automatic differentiati...
std::string name(const ElemQuality q)
void evaluateDotWarning() const
Internal method for giving a one-time warning for calling an evaluateDot() method.
const ExecFlagType EXEC_TRANSFER
Definition: Moose.C:47
Postprocessor(const MooseObject *moose_object)
Definition: Postprocessor.C:30
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
static InputParameters validParams()
const ReporterMode REPORTER_MODE_UNSET
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
static InputParameters validParams()
Definition: Postprocessor.C:17
T getCheckedPointerParam(const std::string &name, const std::string &error_string="") const
Verifies that the requested parameter exists and is not NULL and returns it to the caller...
A class to provide an common interface to objects requiring "outputs" option.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addAvailableFlags(const ExecFlagType &flag, Args... flags)
Add additional execute_on flags to the list of possible flags.
Definition: ExecFlagEnum.h:82
A structure that is used to evaluate Moose functors at an arbitrary physical point contained within a...
const PostprocessorValue & getCurrentValue() const
Definition: Postprocessor.h:56
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
const PostprocessorValue & declareValue(const MooseObject &moose_object)
Internal method to be used to declare the value and store it within _current_value in the constructor...
Definition: Postprocessor.C:41
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
typename FunctorReturnType< Real, FunctorEvaluationKind::Gradient >::type GradientType
This rigmarole makes it so that a user can create functors that return containers (std::vector...
Definition: MooseFunctor.h:149
ValueType evaluate(const ElemArg &elem, const Moose::StateArg &state) const override final
Evaluate the functor with a given element.
Definition: Postprocessor.C:65
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
A structure defining a "face" evaluation calling argument for Moose functors.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:33
const std::string & _pp_name
Post-processor name.
Definition: Postprocessor.h:70
Real PostprocessorValue
various MOOSE typedefs
Definition: MooseTypes.h:191
A structure that is used to evaluate Moose functors logically at an element/cell center.
Argument for requesting functor evaluation at a quadrature point location in an element.
DotType evaluateDot(const ElemArg &elem, const Moose::StateArg &state) const override final
Evaluate the functor time derivative with a given element.
const MooseObject & _pp_moose_object
MOOSE object.
A ReporterName that represents a Postprocessor.
Definition: ReporterName.h:134
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const InputParameters & parameters() const
Get the parameters of the object.
State argument for evaluating functors.
static InputParameters validParams()
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
GradientType evaluateGradient(const ElemArg &elem, const Moose::StateArg &state) const override final
Evaluate the functor gradient with a given element.
Argument for requesting functor evaluation at quadrature point locations on an element side...
unsigned int THREAD_ID
Definition: MooseTypes.h:198
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...
static InputParameters validParams()
Definition: UserObject.C:18