www.mooseframework.org
ElementExtremeValue.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 "ElementExtremeValue.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 
30  params.addParam<MooseEnum>("value_type",
31  type_options,
32  "Type of extreme value to return. 'max' "
33  "returns the maximum value. 'min' returns "
34  "the minimum value.");
35 
36  return params;
37 }
38 
40  : ElementVariablePostprocessor(parameters),
41  _type((ExtremeType)(int)parameters.get<MooseEnum>("value_type")),
42  _value(_type == 0 ? -std::numeric_limits<Real>::max() : std::numeric_limits<Real>::max())
43 {
44 }
45 
46 void
48 {
49  switch (_type)
50  {
51  case MAX:
52  _value = -std::numeric_limits<Real>::max(); // start w/ the min
53  break;
54 
55  case MIN:
56  _value = std::numeric_limits<Real>::max(); // start w/ the max
57  break;
58  }
59 }
60 
61 void
63 {
64  switch (_type)
65  {
66  case MAX:
67  _value = std::max(_value, _u[_qp]);
68  break;
69 
70  case MIN:
71  _value = std::min(_value, _u[_qp]);
72  break;
73  }
74 }
75 
76 Real
78 {
79  switch (_type)
80  {
81  case MAX:
83  break;
84  case MIN:
86  break;
87  }
88 
89  return _value;
90 }
91 
92 void
94 {
95  const ElementExtremeValue & pps = static_cast<const ElementExtremeValue &>(y);
96 
97  switch (_type)
98  {
99  case MAX:
100  _value = std::max(_value, pps._value);
101  break;
102  case MIN:
103  _value = std::min(_value, pps._value);
104  break;
105  }
106 }
InputParameters validParams< ElementExtremeValue >()
const VariableValue & _u
Holds the solution at current quadrature points.
virtual void threadJoin(const UserObject &y) override
Must override.
void gatherMax(T &value)
Definition: UserObject.h:125
ExtremeType _type
The extreme value type.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void gatherMin(T &value)
Definition: UserObject.h:131
unsigned int _qp
The current quadrature point.
Real _value
The extreme value.
ExtremeType
Type of extreme value we are going to compute.
InputParameters validParams< ElementVariablePostprocessor >()
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
A postprocessor for collecting the nodal min or max value.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
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...
ElementExtremeValue(const InputParameters &parameters)
Class constructor.
Base class for user-specific data.
Definition: UserObject.h:42
virtual void computeQpValue() override
Get the extreme value at each quadrature point.
virtual Real getValue() override
This will get called to actually grab the final value the postprocessor has calculated.