https://mooseframework.inl.gov
TimeIntegratedPostprocessor.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 
11 #include "CrankNicolson.h"
12 #include "TransientBase.h"
13 
16  TotalVariableValue,
17  "04/01/2022 00:00",
19 
22 {
24  params.addClassDescription("Integrate a Postprocessor value over time.");
25  params.addParam<PostprocessorName>("value", "The name of the postprocessor");
26  MooseEnum schemes("implicit-euler trapezoidal-rule", "trapezoidal-rule");
27  params.addParam<MooseEnum>(
28  "time_integration_scheme", schemes, "Time integration scheme to use for the postprocessors");
29  return params;
30 }
31 
33  : GeneralPostprocessor(parameters),
34  _value(0),
35  _value_old(getPostprocessorValueOldByName(name())),
36  _pps_value(getPostprocessorValue("value")),
37  _pps_value_old(getPostprocessorValueOld("value")),
38  _time_integration_scheme(getParam<MooseEnum>("time_integration_scheme"))
39 {
40  if (!dynamic_cast<TransientBase *>(_app.getExecutioner()))
41  mooseError(
42  "Time integration of postprocessor has only been implemented with a transient executioner");
43 
44  // Only check if the user did not select it manually
45  if (!isParamSetByUser("time_integration_scheme"))
46  {
47  const auto time_integrators =
48  dynamic_cast<TransientBase *>(_app.getExecutioner())->getTimeIntegrators();
49  for (const auto & ti : time_integrators)
50  if (_time_integration_scheme == TimeIntegration::TrapezoidalRule &&
51  !dynamic_cast<CrankNicolson *>(ti))
52  mooseInfo(
53  "The time integration in this postprocessor uses the trapezoidal rule method. The "
54  "equation time integration scheme does not use the trapezoidal rule. If the "
55  "postprocessor uses variable values, even indirectly, we would recommend you "
56  "code the same time integration method for the time-integrated postprocessor. "
57  "Specify the 'time_integration_scheme' parameter to silence this warning.");
58  }
59 }
60 
61 void
63 {
64 }
65 
66 void
68 {
69  if (_time_integration_scheme == TimeIntegration::ImplicitEuler)
71  // 2nd order trapezoidal rule is a better default for other integrators
72  else
74 }
75 
76 Real
78 {
79  return _value;
80 }
std::string name(const ElemQuality q)
void mooseInfo(Args &&... args) const
Definition: MooseBase.h:344
registerMooseObjectRenamed("MooseApp", TotalVariableValue, "04/01/2022 00:00", TimeIntegratedPostprocessor)
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void execute() override
Execute method.
Real & _dt
Time step size.
const MooseEnum & _time_integration_scheme
The time integration method.
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
static InputParameters validParams()
registerMooseObject("MooseApp", TimeIntegratedPostprocessor)
static InputParameters validParams()
Real _value
The total value of the variable.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:54
Base class for transient executioners that use a FixedPointSolve solve object for multiapp-main app i...
Definition: TransientBase.h:27
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:385
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition: MooseApp.C:1815
const PostprocessorValue & _pps_value
The current post-processor value.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const PostprocessorValue & _value_old
My old value.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:281
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
bool isParamSetByUser(const std::string &name) const
Test if the supplied parameter is set by a user, as opposed to not set or set to default.
Definition: MooseBase.h:215
Integrate a post-processor value over time using trapezoidal rule.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
TimeIntegratedPostprocessor(const InputParameters &parameters)
const PostprocessorValue & _pps_value_old
The old post-processor value.