https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ElementExtremeMaterialProperty.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
12#include "metaphysicl/raw_type.h"
13
14#include <algorithm>
15#include <limits>
16
19
20template <bool is_ad>
23{
25
26 params.addRequiredParam<MaterialPropertyName>("mat_prop",
27 "Material property for which to find the extreme");
28 MooseEnum type_options("max=0 min=1");
29 params.addRequiredParam<MooseEnum>("value_type",
30 type_options,
31 "Type of extreme value to return: 'max' "
32 "returns the maximum value and 'min' returns "
33 "the minimum value.");
34
36 "Determines the minimum or maximum of a material property over a volume.");
37
38 return params;
39}
40
41template <bool is_ad>
43 const InputParameters & parameters)
44 : ElementPostprocessor(parameters),
45
46 _mat_prop(getGenericMaterialProperty<Real, is_ad>("mat_prop")),
47 _type((ExtremeType)(int)parameters.get<MooseEnum>("value_type")),
48 _value(_type == 0 ? -std::numeric_limits<Real>::max() : std::numeric_limits<Real>::max()),
49 _qp(0)
50{
51}
52
53template <bool is_ad>
54void
56{
57 switch (_type)
58 {
59 case MAX:
60 _value = -std::numeric_limits<Real>::max(); // start w/ the min
61 break;
62
63 case MIN:
64 _value = std::numeric_limits<Real>::max(); // start w/ the max
65 break;
66 }
67}
68
69template <bool is_ad>
70void
72{
73 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
74 computeQpValue();
75}
76
77template <bool is_ad>
78void
80{
81 switch (_type)
82 {
83 case MAX:
84 _value = std::max(_value, MetaPhysicL::raw_value(_mat_prop[_qp]));
85 break;
86
87 case MIN:
88 _value = std::min(_value, MetaPhysicL::raw_value(_mat_prop[_qp]));
89 break;
90 }
91}
92
93template <bool is_ad>
94Real
99
100template <bool is_ad>
101void
103{
104 switch (_type)
105 {
106 case MAX:
107 gatherMax(_value);
108 break;
109 case MIN:
110 gatherMin(_value);
111 break;
112 }
113}
114
115template <bool is_ad>
116void
118{
119 const auto & pps = static_cast<const ElementExtremeMaterialPropertyTempl<is_ad> &>(y);
120
121 switch (_type)
122 {
123 case MAX:
124 _value = std::max(_value, pps._value);
125 break;
126 case MIN:
127 _value = std::min(_value, pps._value);
128 break;
129 }
130}
131
registerMooseObject("MooseApp", ElementExtremeMaterialProperty)
void ErrorVector unsigned int
Determines the minimum or maximum of a material property over a volume.
virtual void finalize() override
This is called after execute() and after threadJoin()! This is probably where you want to do MPI comm...
ElementExtremeMaterialPropertyTempl(const InputParameters &parameters)
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
virtual void threadJoin(const UserObject &y) override
Must override.
virtual void execute() override
Execute method.
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
Base class for user-specific data.
Definition UserObject.h:20
auto raw_value(const Eigen::Map< T > &in)