https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LayeredExtremumMaterialProperty.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 "libmesh/mesh_tools.h"
13
15
18{
20 params += LayeredBase::validParams();
21 params.addClassDescription("Compute material property extrema over layers.");
22 params.registerBase("UserObject");
23
24 return params;
25}
26
31
32void
34{
37
38 // Initialize layer values
39 for (const auto layer : make_range(_num_layers))
41 layer, _type == MIN ? std::numeric_limits<Real>::max() : -std::numeric_limits<Real>::max());
42}
43
44void
46{
47 // Do not keep track of the layer extremum with _value
50 const auto layer = getLayer(_current_elem->vertex_average());
51
53}
54
55Real
56LayeredExtremumMaterialProperty::extreme_value(const Real a, const Real b) const
57{
58 if (_type == MIN)
59 return std::min(a, b);
60 else
61 return std::max(a, b);
62}
63
64void
66{
67 if (_type == MIN)
69 else
72
73 if (_cumulative)
74 {
75 Real value =
76 _type == MIN ? std::numeric_limits<Real>::max() : -std::numeric_limits<Real>::max();
77
79 for (unsigned i = 0; i < _num_layers; i++)
80 {
81 value = extreme_value(value, getLayerValue(i));
82 setLayerValue(i, value);
83 }
84 else
85 for (int i = _num_layers - 1; i >= 0; i--)
86 {
87 value = extreme_value(value, getLayerValue(i));
88 setLayerValue(i, value);
89 }
90 }
91}
92
93void
95{
96 const auto & lb = static_cast<const LayeredExtremumMaterialProperty &>(y);
97 for (const auto i : make_range(_num_layers))
98 if (lb.layerHasValue(i))
99 setLayerValue(i, extreme_value(getLayerValue(i), lb.getLayerValue(i)));
100}
101
102const std::vector<Point>
104{
105 std::vector<Point> points;
106
107 for (const auto & l : _layer_centers)
108 {
109 Point pt(0.0, 0.0, 0.0);
110 pt(_direction) = l;
111 points.push_back(pt);
112 }
113
114 return points;
115}
registerMooseObject("MooseApp", LayeredExtremumMaterialProperty)
Determines the minimum or maximum of a material property over a volume.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
ExtremeType _type
Type of extreme value to compute.
virtual void execute() override
Execute method.
const Elem *const & _current_elem
The current element pointer (available during execute())
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System.
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 base class computes volume integrals of a variable storing partial sums for the specified number...
Definition LayeredBase.h:37
unsigned int _num_layers
Number of layers to split the mesh into.
virtual Real getLayerValue(unsigned int layer) const
Get the value for a given layer.
virtual unsigned int getLayer(const Point &p) const
Helper function to return the layer the point lies in.
void setLayerValue(unsigned int layer, Real value)
Set the value for a particular layer.
std::vector< int > & _layer_has_value
Whether or not each layer has had any value summed into it.
std::vector< Real > _layer_centers
center coordinates of each layer
bool _cumulative
Whether the values are cumulative over the layers.
const bool _positive_cumulative_direction
Whether the cumulative values should be summed in the positive or negative direction.
static InputParameters validParams()
Definition LayeredBase.C:22
unsigned int _direction
The component direction the layers are going in. We cache this for speed (so we're not always going t...
virtual void initialize()
std::vector< Real > & _layer_values
Value of the integral for each layer.
This UserObject computes volume integrals of a variable storing partial sums for the specified number...
virtual void execute() override
Execute method.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
virtual void finalize() override
This is called after execute() and after threadJoin()! This is probably where you want to do MPI comm...
LayeredExtremumMaterialProperty(const InputParameters &parameters)
virtual const std::vector< Point > spatialPoints() const override
Optional interface function for providing the points at which a UserObject attains spatial values.
Real extreme_value(const Real a, const Real b) const
virtual void threadJoin(const UserObject &y) override
Must override.
void max(const T &r, T &o, Request &req) const
void min(const T &r, T &o, Request &req) const
Base class for user-specific data.
Definition UserObject.h:20
const Parallel::Communicator & comm() const