www.mooseframework.org
TimeExtremeValue.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 "TimeExtremeValue.h"
11 
12 #include <algorithm>
13 #include <limits>
14 
16 
19 {
20  // Define the min/max enumeration
21  MooseEnum type_options("max=0 min=1 abs_max=2 abs_min=3", "max");
22 
23  // Define the extreme value/time enumeration
24  MooseEnum output_type_options("extreme_value=0 time=1", "extreme_value");
25 
26  // Define the parameters
28  params.addParam<MooseEnum>("value_type",
29  type_options,
30  "Type of extreme value to return."
31  "'max' returns the maximum value."
32  "'min' returns the minimum value."
33  "'abs_max' returns the maximum absolute value."
34  "'abs_min' returns the minimum absolute value.");
35  params.addParam<MooseEnum>("output_type",
36  output_type_options,
37  "Output to return. 'extreme_value' returns the extreme_value. 'time' "
38  "returns the time at which the extreme_value occurred.");
39  params.addRequiredParam<PostprocessorName>(
40  "postprocessor", "The name of the postprocessor used for reporting time extreme values");
41  params.addClassDescription(
42  "A postprocessor for reporting the extreme value of another postprocessor over time.");
43 
44  return params;
45 }
46 
48  : GeneralPostprocessor(parameters),
49  _postprocessor(getPostprocessorValue("postprocessor")),
50  _type(getParam<MooseEnum>("value_type").getEnum<ExtremeType>()),
51  _output_type(getParam<MooseEnum>("output_type").getEnum<OutputType>()),
52  _value(declareRestartableData<Real>("value")),
53  _time(declareRestartableData<Real>("time"))
54 {
55  if (!_app.isRecovering())
56  {
57  switch (_type)
58  {
59  case ExtremeType::MAX:
61  break;
62 
63  case ExtremeType::MIN:
65  break;
66 
68  // the max absolute value of anything is greater than or equal to 0
69  _value = 0;
70  break;
71 
73  // the min absolute value of anything is less than this
75  break;
76 
77  default:
78  mooseError("Unrecognzed ExtremeType");
79 
80  _time = 0; // Time has to be greater than or equal to zero.
81  }
82  }
83 }
84 
85 void
87 {
88  switch (_type)
89  {
90  case ExtremeType::MAX:
92  _time = (_value == _postprocessor) ? _t : _time;
93  break;
94 
95  case ExtremeType::MIN:
97  _time = (_value == _postprocessor) ? _t : _time;
98  break;
99 
103  break;
104 
108  break;
109 
110  default:
111  mooseError("Unrecognized ExtremeType");
112  }
113 }
114 
115 Real
117 {
119  return _value;
120  else
121  return _time;
122 }
static InputParameters validParams()
registerMooseObject("MooseApp", TimeExtremeValue)
ExtremeType _type
The extreme value type ("max", "min", etc.)
Real & _time
The time the extreme value occurred.
OutputType _output_type
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.
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
auto max(const L &left, const R &right)
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
static InputParameters validParams()
TimeExtremeValue(const InputParameters &parameters)
Class constructor.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:69
ExtremeType
What type of extreme value we are going to compute.
const PostprocessorValue & _postprocessor
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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 option parameter and a documentation string to the InputParameters object...
Real & _value
The extreme value.
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition: MooseApp.C:1167
auto min(const L &left, const R &right)
A postprocessor for reporting the max/min value of another postprocessor over time.
OutputType
What output to return, the extreme value, or the time it occurred.