www.mooseframework.org
NodalExtremeValue.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "NodalExtremeValue.h"
16 
17 #include <algorithm>
18 #include <limits>
19 
20 template <>
23 {
24  // Define the min/max enumeration
25  MooseEnum type_options("max=0 min=1", "max");
26 
27  // Define the parameters
29  params.addParam<MooseEnum>("value_type",
30  type_options,
31  "Type of extreme value to return. 'max' "
32  "returns the maximum value. 'min' returns "
33  "the minimum value.");
34  return params;
35 }
36 
38  : NodalVariablePostprocessor(parameters),
39  _type((ExtremeType)(int)parameters.get<MooseEnum>("value_type")),
40  _value(_type == 0 ? -std::numeric_limits<Real>::max() : std::numeric_limits<Real>::max())
41 {
42 }
43 
44 void
46 {
47  switch (_type)
48  {
49  case MAX:
50  _value = -std::numeric_limits<Real>::max(); // start w/ the min
51  break;
52 
53  case MIN:
54  _value = std::numeric_limits<Real>::max(); // start w/ the max
55  break;
56  }
57 }
58 
59 void
61 {
62  switch (_type)
63  {
64  case MAX:
65  _value = std::max(_value, _u[_qp]);
66  break;
67 
68  case MIN:
69  _value = std::min(_value, _u[_qp]);
70  break;
71  }
72 }
73 
74 Real
76 {
77  switch (_type)
78  {
79  case MAX:
81  break;
82  case MIN:
84  break;
85  }
86 
87  return _value;
88 }
89 
90 void
92 {
93  const NodalExtremeValue & pps = static_cast<const NodalExtremeValue &>(y);
94 
95  switch (_type)
96  {
97  case MAX:
98  _value = std::max(_value, pps._value);
99  break;
100  case MIN:
101  _value = std::min(_value, pps._value);
102  break;
103  }
104 }
ExtremeType _type
The extreme value type ("min" or "max")
This is a base class for other classes which compute post-processed values based on nodal solution va...
void gatherMax(T &value)
Definition: UserObject.h:125
const VariableValue & _u
Holds the solution at current quadrature points.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void gatherMin(T &value)
Definition: UserObject.h:131
ExtremeType
What type of extreme value we are going to compute.
virtual Real getValue() override
This will get called to actually grab the final value the postprocessor has calculated.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
A postprocessor for collecting the nodal min or max value.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
const unsigned int _qp
Quadrature point index.
virtual void threadJoin(const UserObject &y) override
Must override.
InputParameters validParams< NodalExtremeValue >()
virtual void execute() override
Execute method.
NodalExtremeValue(const InputParameters &parameters)
Class constructor.
InputParameters validParams< NodalVariablePostprocessor >()
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.
Base class for user-specific data.
Definition: UserObject.h:42