https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TimeExtremeValue.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 "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");
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 {
60 _value = -std::numeric_limits<Real>::max();
61 break;
62
64 _value = std::numeric_limits<Real>::max();
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
74 _value = std::numeric_limits<Real>::max();
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
85void
87{
88 switch (_type)
89 {
91 _value = std::max(_value, _postprocessor);
93 break;
94
96 _value = std::min(_value, _postprocessor);
98 break;
99
101 _value = std::max(_value, std::abs(_postprocessor));
102 _time = (_value == std::abs(_postprocessor)) ? _t : _time;
103 break;
104
106 _value = std::min(_value, std::abs(_postprocessor));
107 _time = (_value == std::abs(_postprocessor)) ? _t : _time;
108 break;
109
110 default:
111 mooseError("Unrecognized ExtremeType");
112 }
113}
114
115Real
117{
119 return _value;
120 else
121 return _time;
122}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
registerMooseObject("MooseApp", TimeExtremeValue)
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
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...
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.
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition MooseApp.C:1669
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
A postprocessor for reporting the max/min value of another postprocessor over time.
ExtremeType
What type of extreme value we are going to compute.
Real & _time
The time the extreme value occurred.
OutputType
What output to return, the extreme value, or the time it occurred.
static InputParameters validParams()
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
TimeExtremeValue(const InputParameters &parameters)
Class constructor.
virtual void execute() override
Execute method.
Real & _value
The extreme value.
const PostprocessorValue & _postprocessor
ExtremeType _type
The extreme value type ("max", "min", etc.)
OutputType _output_type