https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
51{
52 auto & fe_problem =
53 *moose_object.parameters().getCheckedPointerParam<FEProblemBase *>("_fe_problem_base");
54
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
74Postprocessor::evaluate(const ElemArg & /*elem_arg*/, const Moose::StateArg & /*state*/) const
75{
76 return getCurrentValue();
77}
78
80Postprocessor::evaluate(const FaceArg & /*face*/, const Moose::StateArg & /*state*/) const
81{
82 return getCurrentValue();
83}
84
86Postprocessor::evaluate(const ElemQpArg & /*elem_qp*/, const Moose::StateArg & /*state*/) const
87{
88 return getCurrentValue();
89}
90
92Postprocessor::evaluate(const ElemSideQpArg & /*elem_side_qp*/,
93 const Moose::StateArg & /*state*/) const
94{
95 return getCurrentValue();
96}
97
99Postprocessor::evaluate(const ElemPointArg & /*elem_point_arg*/,
100 const Moose::StateArg & /*state*/) const
101{
102 return getCurrentValue();
103}
104
106Postprocessor::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
119Postprocessor::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
153Postprocessor::evaluateDot(const ElemArg & /*elem_arg*/, const Moose::StateArg & /*state*/) const
154{
156 return 0;
157}
158
160Postprocessor::evaluateDot(const FaceArg & /*face*/, const Moose::StateArg & /*state*/) const
161{
163 return 0;
164}
165
167Postprocessor::evaluateDot(const ElemQpArg & /*elem_qp*/, const Moose::StateArg & /*state*/) const
168{
170 return 0;
171}
172
175 const Moose::StateArg & /*state*/) const
176{
178 return 0;
179}
180
182Postprocessor::evaluateDot(const ElemPointArg & /*elem_point_arg*/,
183 const Moose::StateArg & /*state*/) const
184{
186 return 0;
187}
188
190Postprocessor::evaluateDot(const NodeArg & /*node_arg*/, const Moose::StateArg & /*state*/) const
191{
193 return 0;
194}
195
196void
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}
Real PostprocessorValue
various MOOSE typedefs
Definition MooseTypes.h:230
unsigned int THREAD_ID
Definition MooseTypes.h:237
const ReporterMode REPORTER_MODE_UNSET
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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...
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System.
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 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.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
typename FunctorReturnType< Real, FunctorEvaluationKind::Gradient >::type GradientType
This rigmarole makes it so that a user can create functors that return containers (std::vector,...
An interface for accessing Moose::Functors for systems that do not care about automatic differentiati...
static InputParameters validParams()
A class to provide an common interface to objects requiring "outputs" option.
static InputParameters validParams()
A ReporterName that represents a Postprocessor.
Base class for all Postprocessors.
GradientType evaluateGradient(const ElemArg &elem, const Moose::StateArg &state) const override final
Evaluate the functor gradient with a given element.
void evaluateDotWarning() const
Internal method for giving a one-time warning for calling an evaluateDot() method.
const std::string & _pp_name
Post-processor name.
const MooseObject & _pp_moose_object
MOOSE object.
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...
static InputParameters validParams()
DotType evaluateDot(const ElemArg &elem, const Moose::StateArg &state) const override final
Evaluate the functor time derivative with a given element.
const PostprocessorValue & getCurrentValue() const
Postprocessor(const MooseObject *moose_object)
ValueType evaluate(const ElemArg &elem, const Moose::StateArg &state) const override final
Evaluate the functor with a given element.
void mooseWarning(Args &&... args) const
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
A structure that is used to evaluate Moose functors logically at an element/cell center.
A structure that is used to evaluate Moose functors at an arbitrary physical point contained within a...
Argument for requesting functor evaluation at a quadrature point location in an element.
Argument for requesting functor evaluation at quadrature point locations on an element side.
A structure defining a "face" evaluation calling argument for Moose functors.
State argument for evaluating functors.