www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
LayeredBase Class Reference

This UserObject (????? this isn't a userobject) computes volume integrals of a variable storing partial sums for the specified number of intervals in a direction (x,y,z). More...

#include <LayeredBase.h>

Inheritance diagram for LayeredBase:
[legend]

Public Member Functions

 LayeredBase (const InputParameters &parameters)
 
virtual Real integralValue (Point p) const
 Given a Point return the integral value associated with the layer that point falls in. More...
 
virtual Real getLayerValue (unsigned int layer) const
 Get the value for a given layer. More...
 
virtual unsigned int getLayer (Point p) const
 Helper function to return the layer the point lies in. More...
 
virtual void initialize ()
 
virtual void finalize ()
 
virtual void threadJoin (const UserObject &y)
 

Protected Member Functions

void setLayerValue (unsigned int layer, Real value)
 Set the value for a particular layer. More...
 
bool layerHasValue (unsigned int layer) const
 Whether or not a layer has a value. More...
 
void getBounds ()
 Compute bounds, restricted to blocks if given. More...
 

Protected Attributes

std::string _layered_base_name
 Name of this object. More...
 
const InputParameters_layered_base_params
 Params for this object. More...
 
MooseEnum _direction_enum
 The MooseEnum direction the layers are going in. More...
 
unsigned int _direction
 The component direction the layers are going in. We cache this for speed (so we're not always going through the MooseEnum) More...
 
bool _interval_based
 Whether or not this object is based on equally spaced intervals or "bounds". More...
 
unsigned int _num_layers
 Number of layers to split the mesh into. More...
 
std::vector< Real > _layer_bounds
 The boundaries of the layers. More...
 
unsigned int _sample_type
 How to sample the values. More...
 
unsigned int _average_radius
 How many layers both above and below the found layer will be used in the average. More...
 
bool _using_displaced_mesh
 true if this object operates on the displaced mesh, otherwise false More...
 
Real _direction_min
 
Real _direction_max
 

Private Member Functions

template<typename T >
T & declareRestartableData (std::string data_name)
 Declare a piece of data as "restartable". More...
 
template<typename T >
T & declareRestartableData (std::string data_name, const T &init_value)
 Declare a piece of data as "restartable" and initialize it. More...
 
template<typename T >
T & declareRestartableDataWithContext (std::string data_name, void *context)
 Declare a piece of data as "restartable". More...
 
template<typename T >
T & declareRestartableDataWithContext (std::string data_name, const T &init_value, void *context)
 Declare a piece of data as "restartable" and initialize it. More...
 
template<typename T >
T & declareRecoverableData (std::string data_name)
 Declare a piece of data as "recoverable". More...
 
template<typename T >
T & declareRecoverableData (std::string data_name, const T &init_value)
 Declare a piece of data as "restartable" and initialize it. More...
 
template<typename T >
T & declareRestartableDataWithObjectName (std::string data_name, std::string object_name)
 Declare a piece of data as "restartable". More...
 
template<typename T >
T & declareRestartableDataWithObjectNameWithContext (std::string data_name, std::string object_name, void *context)
 Declare a piece of data as "restartable". More...
 

Private Attributes

std::vector< Real > & _layer_values
 Value of the integral for each layer. More...
 
std::vector< int > & _layer_has_value
 Whether or not each layer has had any value summed into it. More...
 
SubProblem_layered_base_subproblem
 Subproblem for the child object. More...
 
bool _cumulative
 Whether the values are cumulative over the layers. More...
 
std::vector< SubdomainID_blocks
 List of SubdomainIDs, if given. More...
 

Detailed Description

This UserObject (????? this isn't a userobject) computes volume integrals of a variable storing partial sums for the specified number of intervals in a direction (x,y,z).

Definition at line 41 of file LayeredBase.h.

Constructor & Destructor Documentation

◆ LayeredBase()

LayeredBase::LayeredBase ( const InputParameters parameters)

Definition at line 60 of file LayeredBase.C.

61  : Restartable(parameters.getCheckedPointerParam<SubProblem *>("_subproblem")->getMooseApp(),
62  parameters.get<std::string>("_object_name") + "_layered_base",
63  "LayeredBase",
64  parameters.get<THREAD_ID>("_tid")),
65  _layered_base_name(parameters.get<std::string>("_object_name")),
66  _layered_base_params(parameters),
67  _direction_enum(parameters.get<MooseEnum>("direction")),
69  _sample_type(parameters.get<MooseEnum>("sample_type")),
70  _average_radius(parameters.get<unsigned int>("average_radius")),
71  _using_displaced_mesh(_layered_base_params.get<bool>("use_displaced_mesh")),
72  _layer_values(declareRestartableData<std::vector<Real>>("layer_values")),
73  _layer_has_value(declareRestartableData<std::vector<int>>("layer_has_value")),
74  _layered_base_subproblem(*parameters.getCheckedPointerParam<SubProblem *>("_subproblem")),
75  _cumulative(parameters.get<bool>("cumulative")),
76  _blocks()
77 {
78  if (_layered_base_params.isParamValid("num_layers") &&
80  mooseError("'bounds' and 'num_layers' cannot both be set in ", _layered_base_name);
81 
82  if (_layered_base_params.isParamValid("num_layers"))
83  {
84  _num_layers = _layered_base_params.get<unsigned int>("num_layers");
85  _interval_based = true;
86  }
87  else if (_layered_base_params.isParamValid("bounds"))
88  {
89  _interval_based = false;
90 
91  _layer_bounds = _layered_base_params.get<std::vector<Real>>("bounds");
92 
93  // Make sure the bounds are sorted - we're going to depend on this
94  std::sort(_layer_bounds.begin(), _layer_bounds.end());
95 
96  _num_layers = _layer_bounds.size() - 1; // Layers are only in-between the bounds
97  }
98  else
99  mooseError("One of 'bounds' or 'num_layers' must be specified for ", _layered_base_name);
100 
101  if (!_interval_based && _sample_type == 1)
102  mooseError("'sample_type = interpolate' not supported with 'bounds' in ", _layered_base_name);
103 
104  if (_layered_base_params.isParamValid("block"))
106  _layered_base_params.get<std::vector<SubdomainName>>("block"));
107 
108  _layer_values.resize(_num_layers);
110 
111  getBounds();
112 }
virtual MooseMesh & mesh()=0
std::vector< Real > & _layer_values
Value of the integral for each layer.
Definition: LayeredBase.h:124
bool _using_displaced_mesh
true if this object operates on the displaced mesh, otherwise false
Definition: LayeredBase.h:117
std::string _layered_base_name
Name of this object.
Definition: LayeredBase.h:90
SubProblem & _layered_base_subproblem
Subproblem for the child object.
Definition: LayeredBase.h:130
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::vector< SubdomainID > _blocks
List of SubdomainIDs, if given.
Definition: LayeredBase.h:136
bool _interval_based
Whether or not this object is based on equally spaced intervals or "bounds".
Definition: LayeredBase.h:102
bool _cumulative
Whether the values are cumulative over the layers.
Definition: LayeredBase.h:133
T getCheckedPointerParam(const std::string &name, const std::string &error_string="") const
Verifies that the requested parameter exists and is not NULL and returns it to the caller...
void getBounds()
Compute bounds, restricted to blocks if given.
Definition: LayeredBase.C:323
std::vector< int > & _layer_has_value
Whether or not each layer has had any value summed into it.
Definition: LayeredBase.h:127
const InputParameters & _layered_base_params
Params for this object.
Definition: LayeredBase.h:93
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:99
unsigned int _average_radius
How many layers both above and below the found layer will be used in the average. ...
Definition: LayeredBase.h:114
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:32
unsigned int _num_layers
Number of layers to split the mesh into.
Definition: LayeredBase.h:105
Restartable(const MooseObject *moose_object, const std::string &system_name)
Class constructor.
Definition: Restartable.C:17
std::vector< Real > _layer_bounds
The boundaries of the layers.
Definition: LayeredBase.h:108
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:53
std::vector< SubdomainID > getSubdomainIDs(const std::vector< SubdomainName > &subdomain_name) const
Get the associated subdomainIDs for the subdomain names that are passed in.
Definition: MooseMesh.C:1126
MooseApp & getMooseApp() const
Get the MooseApp this object is associated with.
Definition: MooseObject.h:86
unsigned int _sample_type
How to sample the values.
Definition: LayeredBase.h:111
unsigned int THREAD_ID
Definition: MooseTypes.h:97
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.
T & declareRestartableData(std::string data_name)
Declare a piece of data as "restartable".
Definition: Restartable.h:202
MooseEnum _direction_enum
The MooseEnum direction the layers are going in.
Definition: LayeredBase.h:96

Member Function Documentation

◆ declareRecoverableData() [1/2]

template<typename T >
T & Restartable::declareRecoverableData ( std::string  data_name)
protectedinherited

Declare a piece of data as "recoverable".

This means that in the event of a recovery this piece of data will be restored back to its previous value.

Note - this data will NOT be restored on Restart!

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)

Definition at line 269 of file Restartable.h.

270 {
271  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
272 
273  registerRecoverableDataOnApp(full_name);
274 
275  return declareRestartableDataWithContext<T>(data_name, nullptr);
276 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:194
std::string _restartable_name
The name of the object.
Definition: Restartable.h:191
void registerRecoverableDataOnApp(std::string name)
Helper function for actually registering the restartable data.
Definition: Restartable.C:54

◆ declareRecoverableData() [2/2]

template<typename T >
T & Restartable::declareRecoverableData ( std::string  data_name,
const T &  init_value 
)
protectedinherited

Declare a piece of data as "restartable" and initialize it.

This means that in the event of a restart this piece of data will be restored back to its previous value.

Note - this data will NOT be restored on Restart!

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
init_valueThe initial value of the data

Definition at line 280 of file Restartable.h.

281 {
282  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
283 
284  registerRecoverableDataOnApp(full_name);
285 
286  return declareRestartableDataWithContext<T>(data_name, init_value, nullptr);
287 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:194
std::string _restartable_name
The name of the object.
Definition: Restartable.h:191
void registerRecoverableDataOnApp(std::string name)
Helper function for actually registering the restartable data.
Definition: Restartable.C:54

◆ declareRestartableData() [1/2]

template<typename T >
T & Restartable::declareRestartableData ( std::string  data_name)
protectedinherited

Declare a piece of data as "restartable".

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)

Definition at line 202 of file Restartable.h.

203 {
204  return declareRestartableDataWithContext<T>(data_name, nullptr);
205 }

◆ declareRestartableData() [2/2]

template<typename T >
T & Restartable::declareRestartableData ( std::string  data_name,
const T &  init_value 
)
protectedinherited

Declare a piece of data as "restartable" and initialize it.

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
init_valueThe initial value of the data

Definition at line 209 of file Restartable.h.

210 {
211  return declareRestartableDataWithContext<T>(data_name, init_value, nullptr);
212 }

◆ declareRestartableDataWithContext() [1/2]

template<typename T >
T & Restartable::declareRestartableDataWithContext ( std::string  data_name,
void *  context 
)
protectedinherited

Declare a piece of data as "restartable".

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
contextContext pointer that will be passed to the load and store functions

Definition at line 216 of file Restartable.h.

217 {
218  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
219  auto data_ptr = libmesh_make_unique<RestartableData<T>>(full_name, context);
220  T & restartable_data_ref = data_ptr->get();
221 
222  registerRestartableDataOnApp(full_name, std::move(data_ptr), _restartable_tid);
223 
224  return restartable_data_ref;
225 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:194
std::string _restartable_name
The name of the object.
Definition: Restartable.h:191
THREAD_ID _restartable_tid
The thread ID for this object.
Definition: Restartable.h:197
void registerRestartableDataOnApp(std::string name, std::unique_ptr< RestartableDataValue > data, THREAD_ID tid)
Helper function for actually registering the restartable data.
Definition: Restartable.C:46

◆ declareRestartableDataWithContext() [2/2]

template<typename T >
T & Restartable::declareRestartableDataWithContext ( std::string  data_name,
const T &  init_value,
void *  context 
)
protectedinherited

Declare a piece of data as "restartable" and initialize it.

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
init_valueThe initial value of the data
contextContext pointer that will be passed to the load and store functions

Definition at line 229 of file Restartable.h.

232 {
233  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
234  auto data_ptr = libmesh_make_unique<RestartableData<T>>(full_name, context);
235  data_ptr->set() = init_value;
236 
237  T & restartable_data_ref = data_ptr->get();
238  registerRestartableDataOnApp(full_name, std::move(data_ptr), _restartable_tid);
239 
240  return restartable_data_ref;
241 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:194
std::string _restartable_name
The name of the object.
Definition: Restartable.h:191
THREAD_ID _restartable_tid
The thread ID for this object.
Definition: Restartable.h:197
void registerRestartableDataOnApp(std::string name, std::unique_ptr< RestartableDataValue > data, THREAD_ID tid)
Helper function for actually registering the restartable data.
Definition: Restartable.C:46

◆ declareRestartableDataWithObjectName()

template<typename T >
T & Restartable::declareRestartableDataWithObjectName ( std::string  data_name,
std::string  object_name 
)
protectedinherited

Declare a piece of data as "restartable".

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
object_nameA supplied name for the object that is declaring this data.

Definition at line 245 of file Restartable.h.

246 {
247  return declareRestartableDataWithObjectNameWithContext<T>(data_name, object_name, nullptr);
248 }

◆ declareRestartableDataWithObjectNameWithContext()

template<typename T >
T & Restartable::declareRestartableDataWithObjectNameWithContext ( std::string  data_name,
std::string  object_name,
void *  context 
)
protectedinherited

Declare a piece of data as "restartable".

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
object_nameA supplied name for the object that is declaring this data.
contextContext pointer that will be passed to the load and store functions

Definition at line 252 of file Restartable.h.

255 {
256  std::string old_name = _restartable_name;
257 
258  _restartable_name = object_name;
259 
260  T & value = declareRestartableDataWithContext<T>(data_name, context);
261 
262  _restartable_name = old_name;
263 
264  return value;
265 }
std::string _restartable_name
The name of the object.
Definition: Restartable.h:191

◆ finalize()

void LayeredBase::finalize ( )
virtual

Reimplemented in LayeredSideIntegral, LayeredIntegral, LayeredSideAverage, and LayeredAverage.

Definition at line 249 of file LayeredBase.C.

Referenced by LayeredIntegral::finalize(), and LayeredSideIntegral::finalize().

250 {
253 
254  if (_cumulative)
255  {
256  Real value = 0;
257 
258  for (unsigned i = 0; i < _num_layers; ++i)
259  {
260  value += getLayerValue(i);
261  setLayerValue(i, value);
262  }
263  }
264 }
std::vector< Real > & _layer_values
Value of the integral for each layer.
Definition: LayeredBase.h:124
SubProblem & _layered_base_subproblem
Subproblem for the child object.
Definition: LayeredBase.h:130
bool _cumulative
Whether the values are cumulative over the layers.
Definition: LayeredBase.h:133
std::vector< int > & _layer_has_value
Whether or not each layer has had any value summed into it.
Definition: LayeredBase.h:127
virtual Real getLayerValue(unsigned int layer) const
Get the value for a given layer.
Definition: LayeredBase.C:226
void setLayerValue(unsigned int layer, Real value)
Set the value for a particular layer.
Definition: LayeredBase.C:316
unsigned int _num_layers
Number of layers to split the mesh into.
Definition: LayeredBase.h:105

◆ getBounds()

void LayeredBase::getBounds ( )
protected

Compute bounds, restricted to blocks if given.

Definition at line 323 of file LayeredBase.C.

Referenced by initialize(), and LayeredBase().

324 {
325  if (_blocks.size() == 0)
326  {
327  BoundingBox bounding_box = MeshTools::create_bounding_box(_layered_base_subproblem.mesh());
328  _direction_min = bounding_box.min()(_direction);
329  _direction_max = bounding_box.max()(_direction);
330  }
331  else
332  {
333  _direction_min = std::numeric_limits<Real>::infinity();
334  _direction_max = -std::numeric_limits<Real>::infinity();
335 
337 
338  for (auto & elem_ptr : *mesh.getActiveLocalElementRange())
339  {
340  auto subdomain_id = elem_ptr->subdomain_id();
341 
342  if (std::find(_blocks.begin(), _blocks.end(), subdomain_id) == _blocks.end())
343  continue;
344 
345  for (auto & node : elem_ptr->node_ref_range())
346  {
347  _direction_min = std::min(_direction_min, node(_direction));
348  _direction_max = std::max(_direction_max, node(_direction));
349  }
350  }
351 
352  mesh.comm().min(_direction_min);
353  mesh.comm().max(_direction_max);
354  }
355 }
virtual MooseMesh & mesh()=0
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:779
SubProblem & _layered_base_subproblem
Subproblem for the child object.
Definition: LayeredBase.h:130
std::vector< SubdomainID > _blocks
List of SubdomainIDs, if given.
Definition: LayeredBase.h:136
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:99
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:72
Real _direction_min
Definition: LayeredBase.h:119
Real _direction_max
Definition: LayeredBase.h:120

◆ getLayer()

unsigned int LayeredBase::getLayer ( Point  p) const
virtual

Helper function to return the layer the point lies in.

Parameters
pThe point.
Returns
The layer the Point is found in.

Definition at line 276 of file LayeredBase.C.

Referenced by LayeredAverage::execute(), LayeredSideAverage::execute(), LayeredIntegral::execute(), LayeredSideIntegral::execute(), and integralValue().

277 {
278  Real direction_x = p(_direction);
279 
280  if (direction_x < _direction_min)
281  return 0;
282 
283  if (_interval_based)
284  {
285  unsigned int layer =
286  std::floor(((direction_x - _direction_min) / (_direction_max - _direction_min)) *
287  static_cast<Real>(_num_layers));
288 
289  if (layer >= _num_layers)
290  layer = _num_layers - 1;
291 
292  return layer;
293  }
294  else // Figure out what layer we are in from the bounds
295  {
296  // This finds the first entry in the vector that is larger than what we're looking for
297  std::vector<Real>::const_iterator one_higher =
298  std::upper_bound(_layer_bounds.begin(), _layer_bounds.end(), direction_x);
299 
300  if (one_higher == _layer_bounds.end())
301  {
302  return static_cast<unsigned int>(
303  _layer_bounds.size() -
304  2); // Just return the last layer. -2 because layers are "in-between" bounds
305  }
306  else if (one_higher == _layer_bounds.begin())
307  return 0; // Return the first layer
308  else
309  // The -1 is because the interval that we fall in is just _before_ the number that is bigger
310  // (which is what we found
311  return static_cast<unsigned int>(std::distance(_layer_bounds.begin(), one_higher - 1));
312  }
313 }
bool _interval_based
Whether or not this object is based on equally spaced intervals or "bounds".
Definition: LayeredBase.h:102
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:99
unsigned int _num_layers
Number of layers to split the mesh into.
Definition: LayeredBase.h:105
std::vector< Real > _layer_bounds
The boundaries of the layers.
Definition: LayeredBase.h:108
Real _direction_min
Definition: LayeredBase.h:119
Real _direction_max
Definition: LayeredBase.h:120

◆ getLayerValue()

Real LayeredBase::getLayerValue ( unsigned int  layer) const
virtual

Get the value for a given layer.

Parameters
layerThe layer index
Returns
The value for the given layer

Definition at line 226 of file LayeredBase.C.

Referenced by LayeredIntegral::execute(), LayeredSideIntegral::execute(), LayeredAverage::finalize(), LayeredSideAverage::finalize(), finalize(), and threadJoin().

227 {
228  if (layer >= _layer_values.size())
229  mooseError("Layer '", layer, "' not found in '", _layered_base_name, "'.");
230  return _layer_values[layer];
231 }
std::vector< Real > & _layer_values
Value of the integral for each layer.
Definition: LayeredBase.h:124
std::string _layered_base_name
Name of this object.
Definition: LayeredBase.h:90
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ initialize()

void LayeredBase::initialize ( )
virtual

Reimplemented in LayeredSideIntegral, LayeredIntegral, LayeredSideAverage, and LayeredAverage.

Definition at line 234 of file LayeredBase.C.

Referenced by LayeredIntegral::initialize(), and LayeredSideIntegral::initialize().

235 {
237  {
238  getBounds();
239  }
240 
241  for (unsigned int i = 0; i < _layer_values.size(); i++)
242  {
243  _layer_values[i] = 0.0;
244  _layer_has_value[i] = false;
245  }
246 }
std::vector< Real > & _layer_values
Value of the integral for each layer.
Definition: LayeredBase.h:124
bool _using_displaced_mesh
true if this object operates on the displaced mesh, otherwise false
Definition: LayeredBase.h:117
void getBounds()
Compute bounds, restricted to blocks if given.
Definition: LayeredBase.C:323
std::vector< int > & _layer_has_value
Whether or not each layer has had any value summed into it.
Definition: LayeredBase.h:127

◆ integralValue()

Real LayeredBase::integralValue ( Point  p) const
virtual

Given a Point return the integral value associated with the layer that point falls in.

Parameters
pThe point to look for in the layers.

Definition at line 115 of file LayeredBase.C.

Referenced by LayeredIntegral::spatialValue(), and LayeredSideIntegral::spatialValue().

116 {
117  unsigned int layer = getLayer(p);
118 
119  int higher_layer = -1;
120  int lower_layer = -1;
121 
122  for (unsigned int i = layer; i < _layer_values.size(); i++)
123  {
124  if (_layer_has_value[i])
125  {
126  higher_layer = i;
127  break;
128  }
129  }
130 
131  for (int i = layer - 1; i >= 0; i--)
132  {
133  if (_layer_has_value[i])
134  {
135  lower_layer = i;
136  break;
137  }
138  }
139 
140  if (higher_layer == -1 && lower_layer == -1)
141  return 0; // TODO: We could error here but there are startup dependency problems
142 
143  switch (_sample_type)
144  {
145  case 0: // direct
146  {
147  if (higher_layer == -1) // Didn't find a higher layer
148  return _layer_values[lower_layer];
149 
150  if (unsigned(higher_layer) == layer) // constant in a layer
151  return _layer_values[higher_layer];
152 
153  if (lower_layer == -1) // Didn't find a lower layer
154  return _layer_values[higher_layer];
155 
156  return (_layer_values[higher_layer] + _layer_values[lower_layer]) / 2;
157  }
158  case 1: // interpolate
159  {
160  if (higher_layer == -1) // Didn't find a higher layer
161  return _layer_values[lower_layer];
162 
163  Real layer_length = (_direction_max - _direction_min) / _num_layers;
164  Real lower_coor = _direction_min;
165  Real lower_value = 0;
166  if (lower_layer != -1)
167  {
168  lower_coor += (lower_layer + 1) * layer_length;
169  lower_value = _layer_values[lower_layer];
170  }
171 
172  // Interpolate between the two points
173  Real higher_value = _layer_values[higher_layer];
174 
175  // Linear interpolation
176  return lower_value +
177  (higher_value - lower_value) * (p(_direction) - lower_coor) / layer_length;
178  }
179  case 2: // average
180  {
181  Real total = 0;
182  unsigned int num_values = 0;
183 
184  if (higher_layer != -1)
185  {
186  for (unsigned int i = 0; i < _average_radius; i++)
187  {
188  int current_layer = higher_layer + i;
189 
190  if ((size_t)current_layer >= _layer_values.size())
191  break;
192 
193  if (_layer_has_value[current_layer])
194  {
195  total += _layer_values[current_layer];
196  num_values += 1;
197  }
198  }
199  }
200 
201  if (lower_layer != -1)
202  {
203  for (unsigned int i = 0; i < _average_radius; i++)
204  {
205  int current_layer = lower_layer - i;
206 
207  if (current_layer < 0)
208  break;
209 
210  if (_layer_has_value[current_layer])
211  {
212  total += _layer_values[current_layer];
213  num_values += 1;
214  }
215  }
216  }
217 
218  return total / num_values;
219  }
220  default:
221  mooseError("Unknown sample type!");
222  }
223 }
std::vector< Real > & _layer_values
Value of the integral for each layer.
Definition: LayeredBase.h:124
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::vector< int > & _layer_has_value
Whether or not each layer has had any value summed into it.
Definition: LayeredBase.h:127
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:99
unsigned int _average_radius
How many layers both above and below the found layer will be used in the average. ...
Definition: LayeredBase.h:114
unsigned int _num_layers
Number of layers to split the mesh into.
Definition: LayeredBase.h:105
virtual unsigned int getLayer(Point p) const
Helper function to return the layer the point lies in.
Definition: LayeredBase.C:276
Real _direction_min
Definition: LayeredBase.h:119
unsigned int _sample_type
How to sample the values.
Definition: LayeredBase.h:111
Real _direction_max
Definition: LayeredBase.h:120

◆ layerHasValue()

bool LayeredBase::layerHasValue ( unsigned int  layer) const
inlineprotected

Whether or not a layer has a value.

Definition at line 82 of file LayeredBase.h.

Referenced by LayeredAverage::finalize(), LayeredSideAverage::finalize(), LayeredSideAverage::threadJoin(), and threadJoin().

82 { return _layer_has_value[layer]; }
std::vector< int > & _layer_has_value
Whether or not each layer has had any value summed into it.
Definition: LayeredBase.h:127

◆ setLayerValue()

void LayeredBase::setLayerValue ( unsigned int  layer,
Real  value 
)
protected

Set the value for a particular layer.

Parameters
layerThe layer you are setting the value for
valueThe value to set

Definition at line 316 of file LayeredBase.C.

Referenced by LayeredIntegral::execute(), LayeredSideIntegral::execute(), LayeredAverage::finalize(), LayeredSideAverage::finalize(), finalize(), and threadJoin().

317 {
318  _layer_values[layer] = value;
319  _layer_has_value[layer] = true;
320 }
std::vector< Real > & _layer_values
Value of the integral for each layer.
Definition: LayeredBase.h:124
std::vector< int > & _layer_has_value
Whether or not each layer has had any value summed into it.
Definition: LayeredBase.h:127

◆ threadJoin()

void LayeredBase::threadJoin ( const UserObject y)
virtual

Reimplemented in LayeredSideIntegral, LayeredIntegral, LayeredSideAverage, and LayeredAverage.

Definition at line 267 of file LayeredBase.C.

Referenced by LayeredIntegral::threadJoin(), and LayeredSideIntegral::threadJoin().

268 {
269  const LayeredBase & lb = dynamic_cast<const LayeredBase &>(y);
270  for (unsigned int i = 0; i < _layer_values.size(); i++)
271  if (lb.layerHasValue(i))
273 }
std::vector< Real > & _layer_values
Value of the integral for each layer.
Definition: LayeredBase.h:124
bool layerHasValue(unsigned int layer) const
Whether or not a layer has a value.
Definition: LayeredBase.h:82
virtual Real getLayerValue(unsigned int layer) const
Get the value for a given layer.
Definition: LayeredBase.C:226
void setLayerValue(unsigned int layer, Real value)
Set the value for a particular layer.
Definition: LayeredBase.C:316
This UserObject (????? this isn&#39;t a userobject) computes volume integrals of a variable storing parti...
Definition: LayeredBase.h:41

Member Data Documentation

◆ _average_radius

unsigned int LayeredBase::_average_radius
protected

How many layers both above and below the found layer will be used in the average.

Definition at line 114 of file LayeredBase.h.

Referenced by integralValue().

◆ _blocks

std::vector<SubdomainID> LayeredBase::_blocks
private

List of SubdomainIDs, if given.

Definition at line 136 of file LayeredBase.h.

Referenced by getBounds(), and LayeredBase().

◆ _cumulative

bool LayeredBase::_cumulative
private

Whether the values are cumulative over the layers.

Definition at line 133 of file LayeredBase.h.

Referenced by finalize().

◆ _direction

unsigned int LayeredBase::_direction
protected

The component direction the layers are going in. We cache this for speed (so we're not always going through the MooseEnum)

Definition at line 99 of file LayeredBase.h.

Referenced by getBounds(), getLayer(), and integralValue().

◆ _direction_enum

MooseEnum LayeredBase::_direction_enum
protected

The MooseEnum direction the layers are going in.

Definition at line 96 of file LayeredBase.h.

◆ _direction_max

Real LayeredBase::_direction_max
protected

Definition at line 120 of file LayeredBase.h.

Referenced by getBounds(), getLayer(), and integralValue().

◆ _direction_min

Real LayeredBase::_direction_min
protected

Definition at line 119 of file LayeredBase.h.

Referenced by getBounds(), getLayer(), and integralValue().

◆ _interval_based

bool LayeredBase::_interval_based
protected

Whether or not this object is based on equally spaced intervals or "bounds".

Definition at line 102 of file LayeredBase.h.

Referenced by getLayer(), and LayeredBase().

◆ _layer_bounds

std::vector<Real> LayeredBase::_layer_bounds
protected

The boundaries of the layers.

Definition at line 108 of file LayeredBase.h.

Referenced by getLayer(), and LayeredBase().

◆ _layer_has_value

std::vector<int>& LayeredBase::_layer_has_value
private

Whether or not each layer has had any value summed into it.

Definition at line 127 of file LayeredBase.h.

Referenced by finalize(), initialize(), integralValue(), LayeredBase(), layerHasValue(), and setLayerValue().

◆ _layer_values

std::vector<Real>& LayeredBase::_layer_values
private

Value of the integral for each layer.

Definition at line 124 of file LayeredBase.h.

Referenced by finalize(), getLayerValue(), initialize(), integralValue(), LayeredBase(), setLayerValue(), and threadJoin().

◆ _layered_base_name

std::string LayeredBase::_layered_base_name
protected

Name of this object.

Definition at line 90 of file LayeredBase.h.

Referenced by getLayerValue(), and LayeredBase().

◆ _layered_base_params

const InputParameters& LayeredBase::_layered_base_params
protected

Params for this object.

Definition at line 93 of file LayeredBase.h.

Referenced by LayeredBase().

◆ _layered_base_subproblem

SubProblem& LayeredBase::_layered_base_subproblem
private

Subproblem for the child object.

Definition at line 130 of file LayeredBase.h.

Referenced by finalize(), getBounds(), and LayeredBase().

◆ _num_layers

unsigned int LayeredBase::_num_layers
protected

Number of layers to split the mesh into.

Definition at line 105 of file LayeredBase.h.

Referenced by finalize(), getLayer(), integralValue(), LayeredAverage::LayeredAverage(), LayeredBase(), and LayeredSideAverage::LayeredSideAverage().

◆ _sample_type

unsigned int LayeredBase::_sample_type
protected

How to sample the values.

Definition at line 111 of file LayeredBase.h.

Referenced by integralValue(), and LayeredBase().

◆ _using_displaced_mesh

bool LayeredBase::_using_displaced_mesh
protected

true if this object operates on the displaced mesh, otherwise false

Definition at line 117 of file LayeredBase.h.

Referenced by initialize().


The documentation for this class was generated from the following files: