https://mooseframework.inl.gov
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 
28  : ElementExtremeMaterialProperty(parameters), LayeredBase(parameters)
29 {
30 }
31 
32 void
34 {
37 
38  // Initialize layer values
39  for (const auto layer : make_range(_num_layers))
42 }
43 
44 void
46 {
47  // Do not keep track of the layer extremum with _value
50  const auto layer = getLayer(_current_elem->vertex_average());
51 
53 }
54 
55 Real
56 LayeredExtremumMaterialProperty::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 
64 void
66 {
67  if (_type == MIN)
69  else
72 
73  if (_cumulative)
74  {
75  Real value =
77 
79  for (unsigned i = 0; i < _num_layers; i++)
80  {
82  setLayerValue(i, value);
83  }
84  else
85  for (int i = _num_layers - 1; i >= 0; i--)
86  {
88  setLayerValue(i, value);
89  }
90  }
91 }
92 
93 void
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 
102 const 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 }
virtual void threadJoin(const UserObject &y) override
Must override.
std::vector< Real > & _layer_values
Value of the integral for each layer.
Definition: LayeredBase.h:139
virtual void execute() override
Execute method.
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
bool _cumulative
Whether the values are cumulative over the layers.
Definition: LayeredBase.h:145
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const Parallel::Communicator & comm() const
std::vector< int > & _layer_has_value
Whether or not each layer has had any value summed into it.
Definition: LayeredBase.h:142
registerMooseObject("MooseApp", LayeredExtremumMaterialProperty)
static InputParameters validParams()
Definition: LayeredBase.C:22
std::vector< Real > _layer_centers
center coordinates of each layer
Definition: LayeredBase.h:133
auto max(const L &left, const R &right)
unsigned int _direction
The component direction the layers are going in. We cache this for speed (so we&#39;re not always going t...
Definition: LayeredBase.h:112
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
ExtremeType _type
Type of extreme value to compute.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
void min(const T &r, T &o, Request &req) const
virtual Real getLayerValue(unsigned int layer) const
Get the value for a given layer.
Definition: LayeredBase.C:318
void setLayerValue(unsigned int layer, Real value)
Set the value for a particular layer.
Definition: LayeredBase.C:432
const bool _positive_cumulative_direction
Whether the cumulative values should be summed in the positive or negative direction.
Definition: LayeredBase.h:148
virtual unsigned int getLayer(const Point &p) const
Helper function to return the layer the point lies in.
Definition: LayeredBase.C:373
virtual void initialize()
Definition: LayeredBase.C:326
unsigned int _num_layers
Number of layers to split the mesh into.
Definition: LayeredBase.h:118
This UserObject computes volume integrals of a variable storing partial sums for the specified number...
LayeredExtremumMaterialProperty(const InputParameters &parameters)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void execute() override
Execute method.
const Elem *const & _current_elem
The current element pointer (available during execute())
void max(const T &r, T &o, Request &req) const
This base class computes volume integrals of a variable storing partial sums for the specified number...
Definition: LayeredBase.h:36
IntRange< T > make_range(T beg, T end)
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...
auto min(const L &left, const R &right)
virtual void finalize() override
This is called after execute() and after threadJoin()! This is probably where you want to do MPI comm...
Base class for user-specific data.
Definition: UserObject.h:40
Determines the minimum or maximum of a material property over a volume.