https://mooseframework.inl.gov
Postprocessor.C
Go to the documentation of this file.
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 "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 
23  params.addParamNamesToGroup("outputs", "Advanced");
24  params.registerBase("Postprocessor");
25  return params;
26 }
27 
29  : OutputInterface(moose_object->parameters()),
30  NonADFunctorInterface(moose_object),
31  Moose::FunctorBase<Real>(moose_object->name()),
32  _pp_name(moose_object->name()),
33  _current_value(declareValue(*moose_object)),
34  _pp_moose_object(*moose_object)
35 {
36 }
37 
38 const PostprocessorValue &
40 {
41  auto & fe_problem =
42  *moose_object.parameters().getCheckedPointerParam<FEProblemBase *>("_fe_problem_base");
43 
44  const PostprocessorReporterName r_name(_pp_name);
45 
46  const bool is_thread_0 = moose_object.parameters().get<THREAD_ID>("_tid") == 0;
47  mooseAssert(is_thread_0 ==
48  !fe_problem.getReporterData().hasReporterValue<PostprocessorValue>(r_name),
49  "Postprocessor Reporter threaded value declaration mismatch");
50 
51  // Declare the Reporter value on thread 0 only; this lets us add error checking to
52  // make sure that it really is added only once
53  if (is_thread_0)
54  fe_problem.getReporterData(ReporterData::WriteKey())
56  r_name, REPORTER_MODE_UNSET, moose_object);
57 
58  // At this point, thread 0 should have declared the value and getting it should be valid
59  return fe_problem.getReporterData().getReporterValue<PostprocessorValue>(r_name);
60 }
61 
63 Postprocessor::evaluate(const ElemArg & /*elem_arg*/, const Moose::StateArg & /*state*/) const
64 {
65  return getCurrentValue();
66 }
67 
69 Postprocessor::evaluate(const FaceArg & /*face*/, const Moose::StateArg & /*state*/) const
70 {
71  return getCurrentValue();
72 }
73 
75 Postprocessor::evaluate(const ElemQpArg & /*elem_qp*/, const Moose::StateArg & /*state*/) const
76 {
77  return getCurrentValue();
78 }
79 
81 Postprocessor::evaluate(const ElemSideQpArg & /*elem_side_qp*/,
82  const Moose::StateArg & /*state*/) const
83 {
84  return getCurrentValue();
85 }
86 
88 Postprocessor::evaluate(const ElemPointArg & /*elem_point_arg*/,
89  const Moose::StateArg & /*state*/) const
90 {
91  return getCurrentValue();
92 }
93 
95 Postprocessor::evaluate(const NodeArg & /*node_arg*/, const Moose::StateArg & /*state*/) const
96 {
97  return getCurrentValue();
98 }
99 
102  const Moose::StateArg & /*state*/) const
103 {
104  return 0;
105 }
106 
108 Postprocessor::evaluateGradient(const FaceArg & /*face*/, const Moose::StateArg & /*state*/) const
109 {
110  return 0;
111 }
112 
115  const Moose::StateArg & /*state*/) const
116 {
117  return 0;
118 }
119 
122  const Moose::StateArg & /*state*/) const
123 {
124  return 0;
125 }
126 
129  const Moose::StateArg & /*state*/) const
130 {
131  return 0;
132 }
133 
136  const Moose::StateArg & /*state*/) const
137 {
138  return 0;
139 }
140 
141 typename Postprocessor::DotType
142 Postprocessor::evaluateDot(const ElemArg & /*elem_arg*/, const Moose::StateArg & /*state*/) const
143 {
145  return 0;
146 }
147 
148 typename Postprocessor::DotType
149 Postprocessor::evaluateDot(const FaceArg & /*face*/, const Moose::StateArg & /*state*/) const
150 {
152  return 0;
153 }
154 
155 typename Postprocessor::DotType
156 Postprocessor::evaluateDot(const ElemQpArg & /*elem_qp*/, const Moose::StateArg & /*state*/) const
157 {
159  return 0;
160 }
161 
162 typename Postprocessor::DotType
163 Postprocessor::evaluateDot(const ElemSideQpArg & /*elem_side_qp*/,
164  const Moose::StateArg & /*state*/) const
165 {
167  return 0;
168 }
169 
170 typename Postprocessor::DotType
171 Postprocessor::evaluateDot(const ElemPointArg & /*elem_point_arg*/,
172  const Moose::StateArg & /*state*/) const
173 {
175  return 0;
176 }
177 
178 typename Postprocessor::DotType
179 Postprocessor::evaluateDot(const NodeArg & /*node_arg*/, const Moose::StateArg & /*state*/) const
180 {
182  return 0;
183 }
184 
185 void
187 {
188  mooseDoOnce(_pp_moose_object.mooseWarning(
189  "The time derivative functor operator was called on this post-processor.\n\nA zero value "
190  "will always be returned, even if the post-processor value changes with time."));
191 }
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.
Postprocessor(const MooseObject *moose_object)
Definition: Postprocessor.C:28
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.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:127
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...
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:39
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:63
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:27
const std::string & _pp_name
Post-processor name.
Definition: Postprocessor.h:70
Real PostprocessorValue
various MOOSE typedefs
Definition: MooseTypes.h:202
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:143
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
Definition: MooseBase.h:295
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:209
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