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 {
21 
22  params.addParamNamesToGroup("outputs", "Advanced");
23  params.registerBase("Postprocessor");
24  return params;
25 }
26 
28  : OutputInterface(moose_object->parameters()),
29  NonADFunctorInterface(moose_object),
30  Moose::FunctorBase<Real>(moose_object->name()),
31  _pp_name(moose_object->name()),
32  _current_value(declareValue(*moose_object)),
33  _pp_moose_object(*moose_object)
34 {
35 }
36 
37 #ifdef MOOSE_KOKKOS_ENABLED
39  : OutputInterface(object, key),
40  NonADFunctorInterface(object, key),
41  Moose::FunctorBase<Real>(object, key),
42  _pp_name(object._pp_name),
43  _current_value(object._current_value),
44  _pp_moose_object(object._pp_moose_object)
45 {
46 }
47 #endif
48 
49 const PostprocessorValue &
51 {
52  auto & fe_problem =
53  *moose_object.parameters().getCheckedPointerParam<FEProblemBase *>("_fe_problem_base");
54 
55  const PostprocessorReporterName r_name(_pp_name);
56 
57  const bool is_thread_0 = moose_object.parameters().get<THREAD_ID>("_tid") == 0;
58  mooseAssert(is_thread_0 ==
59  !fe_problem.getReporterData().hasReporterValue<PostprocessorValue>(r_name),
60  "Postprocessor Reporter threaded value declaration mismatch");
61 
62  // Declare the Reporter value on thread 0 only; this lets us add error checking to
63  // make sure that it really is added only once
64  if (is_thread_0)
65  fe_problem.getReporterData(ReporterData::WriteKey())
67  r_name, REPORTER_MODE_UNSET, moose_object);
68 
69  // At this point, thread 0 should have declared the value and getting it should be valid
70  return fe_problem.getReporterData().getReporterValue<PostprocessorValue>(r_name);
71 }
72 
74 Postprocessor::evaluate(const ElemArg & /*elem_arg*/, const Moose::StateArg & /*state*/) const
75 {
76  return getCurrentValue();
77 }
78 
80 Postprocessor::evaluate(const FaceArg & /*face*/, const Moose::StateArg & /*state*/) const
81 {
82  return getCurrentValue();
83 }
84 
86 Postprocessor::evaluate(const ElemQpArg & /*elem_qp*/, const Moose::StateArg & /*state*/) const
87 {
88  return getCurrentValue();
89 }
90 
92 Postprocessor::evaluate(const ElemSideQpArg & /*elem_side_qp*/,
93  const Moose::StateArg & /*state*/) const
94 {
95  return getCurrentValue();
96 }
97 
99 Postprocessor::evaluate(const ElemPointArg & /*elem_point_arg*/,
100  const Moose::StateArg & /*state*/) const
101 {
102  return getCurrentValue();
103 }
104 
106 Postprocessor::evaluate(const NodeArg & /*node_arg*/, const Moose::StateArg & /*state*/) const
107 {
108  return getCurrentValue();
109 }
110 
113  const Moose::StateArg & /*state*/) const
114 {
115  return 0;
116 }
117 
119 Postprocessor::evaluateGradient(const FaceArg & /*face*/, const Moose::StateArg & /*state*/) const
120 {
121  return 0;
122 }
123 
126  const Moose::StateArg & /*state*/) const
127 {
128  return 0;
129 }
130 
133  const Moose::StateArg & /*state*/) const
134 {
135  return 0;
136 }
137 
140  const Moose::StateArg & /*state*/) const
141 {
142  return 0;
143 }
144 
147  const Moose::StateArg & /*state*/) const
148 {
149  return 0;
150 }
151 
152 typename Postprocessor::DotType
153 Postprocessor::evaluateDot(const ElemArg & /*elem_arg*/, const Moose::StateArg & /*state*/) const
154 {
156  return 0;
157 }
158 
159 typename Postprocessor::DotType
160 Postprocessor::evaluateDot(const FaceArg & /*face*/, const Moose::StateArg & /*state*/) const
161 {
163  return 0;
164 }
165 
166 typename Postprocessor::DotType
167 Postprocessor::evaluateDot(const ElemQpArg & /*elem_qp*/, const Moose::StateArg & /*state*/) const
168 {
170  return 0;
171 }
172 
173 typename Postprocessor::DotType
174 Postprocessor::evaluateDot(const ElemSideQpArg & /*elem_side_qp*/,
175  const Moose::StateArg & /*state*/) const
176 {
178  return 0;
179 }
180 
181 typename Postprocessor::DotType
182 Postprocessor::evaluateDot(const ElemPointArg & /*elem_point_arg*/,
183  const Moose::StateArg & /*state*/) const
184 {
186  return 0;
187 }
188 
189 typename Postprocessor::DotType
190 Postprocessor::evaluateDot(const NodeArg & /*node_arg*/, const Moose::StateArg & /*state*/) const
191 {
193  return 0;
194 }
195 
196 void
198 {
199  mooseDoOnce(_pp_moose_object.mooseWarning(
200  "The time derivative functor operator was called on this post-processor.\n\nA zero value "
201  "will always be returned, even if the post-processor value changes with time."));
202 }
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:27
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:131
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:63
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:50
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:74
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
void mooseWarning(Args &&... args) const
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:28
const std::string & _pp_name
Post-processor name.
Definition: Postprocessor.h:77
Real PostprocessorValue
various MOOSE typedefs
Definition: MooseTypes.h:230
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.
Base class for all Postprocessors.
Definition: Postprocessor.h:23
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
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:237
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...