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_layer_bounding_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 66 of file LayeredBase.C.

67  : Restartable(parameters.getCheckedPointerParam<SubProblem *>("_subproblem")->getMooseApp(),
68  parameters.get<std::string>("_object_name") + "_layered_base",
69  "LayeredBase",
70  parameters.get<THREAD_ID>("_tid")),
71  _layered_base_name(parameters.get<std::string>("_object_name")),
72  _layered_base_params(parameters),
73  _direction_enum(parameters.get<MooseEnum>("direction")),
75  _sample_type(parameters.get<MooseEnum>("sample_type")),
76  _average_radius(parameters.get<unsigned int>("average_radius")),
77  _using_displaced_mesh(_layered_base_params.get<bool>("use_displaced_mesh")),
78  _layer_values(declareRestartableData<std::vector<Real>>("layer_values")),
79  _layer_has_value(declareRestartableData<std::vector<int>>("layer_has_value")),
80  _layered_base_subproblem(*parameters.getCheckedPointerParam<SubProblem *>("_subproblem")),
81  _cumulative(parameters.get<bool>("cumulative")),
83 {
84  if (_layered_base_params.isParamValid("num_layers") &&
86  mooseError("'bounds' and 'num_layers' cannot both be set in ", _layered_base_name);
87 
88  if (_layered_base_params.isParamValid("num_layers"))
89  {
90  _num_layers = _layered_base_params.get<unsigned int>("num_layers");
91  _interval_based = true;
92  }
93  else if (_layered_base_params.isParamValid("bounds"))
94  {
95  _interval_based = false;
96 
97  _layer_bounds = _layered_base_params.get<std::vector<Real>>("bounds");
98 
99  // Make sure the bounds are sorted - we're going to depend on this
100  std::sort(_layer_bounds.begin(), _layer_bounds.end());
101 
102  _num_layers = _layer_bounds.size() - 1; // Layers are only in-between the bounds
103  }
104  else
105  mooseError("One of 'bounds' or 'num_layers' must be specified for ", _layered_base_name);
106 
107  if (!_interval_based && _sample_type == 1)
108  mooseError("'sample_type = interpolate' not supported with 'bounds' in ", _layered_base_name);
109 
110  if (_layered_base_params.isParamValid("layer_bounding_block"))
112  _layered_base_params.get<std::vector<SubdomainName>>("layer_bounding_block"));
113  else if (_layered_base_params.isParamValid("block"))
115  _layered_base_params.get<std::vector<SubdomainName>>("block"));
116 
117  _layer_values.resize(_num_layers);
119 
120  getBounds();
121 }
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
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:330
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
std::vector< SubdomainID > _layer_bounding_blocks
List of SubdomainIDs, if given.
Definition: LayeredBase.h:136
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:60
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:1092
MooseApp & getMooseApp() const
Get the MooseApp this object is associated with.
Definition: MooseObject.h:91
unsigned int _sample_type
How to sample the values.
Definition: LayeredBase.h:111
unsigned int THREAD_ID
Definition: MooseTypes.h:162
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:204
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 271 of file Restartable.h.

272 {
273  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
274 
275  registerRecoverableDataOnApp(full_name);
276 
277  return declareRestartableDataWithContext<T>(data_name, nullptr);
278 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:196
std::string _restartable_name
The name of the object.
Definition: Restartable.h:193
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 282 of file Restartable.h.

283 {
284  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
285 
286  registerRecoverableDataOnApp(full_name);
287 
288  return declareRestartableDataWithContext<T>(data_name, init_value, nullptr);
289 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:196
std::string _restartable_name
The name of the object.
Definition: Restartable.h:193
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 204 of file Restartable.h.

205 {
206  return declareRestartableDataWithContext<T>(data_name, nullptr);
207 }

◆ 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 211 of file Restartable.h.

212 {
213  return declareRestartableDataWithContext<T>(data_name, init_value, nullptr);
214 }

◆ 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 218 of file Restartable.h.

219 {
220  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
221  auto data_ptr = libmesh_make_unique<RestartableData<T>>(full_name, context);
222  T & restartable_data_ref = data_ptr->get();
223 
224  registerRestartableDataOnApp(full_name, std::move(data_ptr), _restartable_tid);
225 
226  return restartable_data_ref;
227 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:196
std::string _restartable_name
The name of the object.
Definition: Restartable.h:193
THREAD_ID _restartable_tid
The thread ID for this object.
Definition: Restartable.h:199
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 231 of file Restartable.h.

234 {
235  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
236  auto data_ptr = libmesh_make_unique<RestartableData<T>>(full_name, context);
237  data_ptr->set() = init_value;
238 
239  T & restartable_data_ref = data_ptr->get();
240  registerRestartableDataOnApp(full_name, std::move(data_ptr), _restartable_tid);
241 
242  return restartable_data_ref;
243 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:196
std::string _restartable_name
The name of the object.
Definition: Restartable.h:193
THREAD_ID _restartable_tid
The thread ID for this object.
Definition: Restartable.h:199
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 247 of file Restartable.h.

248 {
249  return declareRestartableDataWithObjectNameWithContext<T>(data_name, object_name, nullptr);
250 }

◆ 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 254 of file Restartable.h.

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

◆ finalize()

void LayeredBase::finalize ( )
virtual

Reimplemented in LayeredSideIntegral, LayeredIntegral, LayeredSideAverage, and LayeredAverage.

Definition at line 256 of file LayeredBase.C.

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

257 {
260 
261  if (_cumulative)
262  {
263  Real value = 0;
264 
265  for (unsigned i = 0; i < _num_layers; ++i)
266  {
267  value += getLayerValue(i);
268  setLayerValue(i, value);
269  }
270  }
271 }
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:235
void setLayerValue(unsigned int layer, Real value)
Set the value for a particular layer.
Definition: LayeredBase.C:323
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 330 of file LayeredBase.C.

Referenced by initialize(), and LayeredBase().

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

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

284 {
285  Real direction_x = p(_direction);
286 
287  if (direction_x < _direction_min)
288  return 0;
289 
290  if (_interval_based)
291  {
292  unsigned int layer =
293  std::floor(((direction_x - _direction_min) / (_direction_max - _direction_min)) *
294  static_cast<Real>(_num_layers));
295 
296  if (layer >= _num_layers)
297  layer = _num_layers - 1;
298 
299  return layer;
300  }
301  else // Figure out what layer we are in from the bounds
302  {
303  // This finds the first entry in the vector that is larger than what we're looking for
304  std::vector<Real>::const_iterator one_higher =
305  std::upper_bound(_layer_bounds.begin(), _layer_bounds.end(), direction_x);
306 
307  if (one_higher == _layer_bounds.end())
308  {
309  return static_cast<unsigned int>(
310  _layer_bounds.size() -
311  2); // Just return the last layer. -2 because layers are "in-between" bounds
312  }
313  else if (one_higher == _layer_bounds.begin())
314  return 0; // Return the first layer
315  else
316  // The -1 is because the interval that we fall in is just _before_ the number that is bigger
317  // (which is what we found
318  return static_cast<unsigned int>(std::distance(_layer_bounds.begin(), one_higher - 1));
319  }
320 }
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 235 of file LayeredBase.C.

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

236 {
237  if (layer >= _layer_values.size())
238  mooseError("Layer '", layer, "' not found in '", _layered_base_name, "'.");
239  return _layer_values[layer];
240 }
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 243 of file LayeredBase.C.

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

244 {
246  getBounds();
247 
248  for (unsigned int i = 0; i < _layer_values.size(); i++)
249  {
250  _layer_values[i] = 0.0;
251  _layer_has_value[i] = false;
252  }
253 }
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:330
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 124 of file LayeredBase.C.

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

125 {
126  unsigned int layer = getLayer(p);
127 
128  int higher_layer = -1;
129  int lower_layer = -1;
130 
131  for (unsigned int i = layer; i < _layer_values.size(); i++)
132  {
133  if (_layer_has_value[i])
134  {
135  higher_layer = i;
136  break;
137  }
138  }
139 
140  for (int i = layer - 1; i >= 0; i--)
141  {
142  if (_layer_has_value[i])
143  {
144  lower_layer = i;
145  break;
146  }
147  }
148 
149  if (higher_layer == -1 && lower_layer == -1)
150  return 0; // TODO: We could error here but there are startup dependency problems
151 
152  switch (_sample_type)
153  {
154  case 0: // direct
155  {
156  if (higher_layer == -1) // Didn't find a higher layer
157  return _layer_values[lower_layer];
158 
159  if (unsigned(higher_layer) == layer) // constant in a layer
160  return _layer_values[higher_layer];
161 
162  if (lower_layer == -1) // Didn't find a lower layer
163  return _layer_values[higher_layer];
164 
165  return (_layer_values[higher_layer] + _layer_values[lower_layer]) / 2;
166  }
167  case 1: // interpolate
168  {
169  if (higher_layer == -1) // Didn't find a higher layer
170  return _layer_values[lower_layer];
171 
172  Real layer_length = (_direction_max - _direction_min) / _num_layers;
173  Real lower_coor = _direction_min;
174  Real lower_value = 0;
175  if (lower_layer != -1)
176  {
177  lower_coor += (lower_layer + 1) * layer_length;
178  lower_value = _layer_values[lower_layer];
179  }
180 
181  // Interpolate between the two points
182  Real higher_value = _layer_values[higher_layer];
183 
184  // Linear interpolation
185  return lower_value +
186  (higher_value - lower_value) * (p(_direction) - lower_coor) / layer_length;
187  }
188  case 2: // average
189  {
190  Real total = 0;
191  unsigned int num_values = 0;
192 
193  if (higher_layer != -1)
194  {
195  for (unsigned int i = 0; i < _average_radius; i++)
196  {
197  int current_layer = higher_layer + i;
198 
199  if ((size_t)current_layer >= _layer_values.size())
200  break;
201 
202  if (_layer_has_value[current_layer])
203  {
204  total += _layer_values[current_layer];
205  num_values += 1;
206  }
207  }
208  }
209 
210  if (lower_layer != -1)
211  {
212  for (unsigned int i = 0; i < _average_radius; i++)
213  {
214  int current_layer = lower_layer - i;
215 
216  if (current_layer < 0)
217  break;
218 
219  if (_layer_has_value[current_layer])
220  {
221  total += _layer_values[current_layer];
222  num_values += 1;
223  }
224  }
225  }
226 
227  return total / num_values;
228  }
229  default:
230  mooseError("Unknown sample type!");
231  }
232 }
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:283
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 323 of file LayeredBase.C.

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

324 {
325  _layer_values[layer] = value;
326  _layer_has_value[layer] = true;
327 }
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 274 of file LayeredBase.C.

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

275 {
276  const LayeredBase & lb = dynamic_cast<const LayeredBase &>(y);
277  for (unsigned int i = 0; i < _layer_values.size(); i++)
278  if (lb.layerHasValue(i))
280 }
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:235
void setLayerValue(unsigned int layer, Real value)
Set the value for a particular layer.
Definition: LayeredBase.C:323
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().

◆ _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_bounding_blocks

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

List of SubdomainIDs, if given.

Definition at line 136 of file LayeredBase.h.

Referenced by getBounds(), 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: