IRockyTriangleScalarsModel Struct Reference
Last update: 08.07.2024
IRockyTriangleScalarsModel Struct Reference
#include <rocky_triangle_scalars.hpp>
Inherits ScalarsModel< rocky20::TriangleScalarsController >.
Public Member Functions | |
int | find (const char *name) |
int | add (const char *name, const char *unit, bool output=true) |
template<class data_type > | |
int | add_accumulation_scalar (const char *name, const char *unit, bool output=true) |
void | reset (int scalar_index) |
void | set_dimension (int scalar_index, double dimension_factor) |
void | enable_storage_of_exchanged_heat () |
void | reset_exchanged_heat () |
std::vector< double > | calculate_sum_over_geometries (int scalar_index) |
void | pull_scalar_from_devices (int scalar_index) |
void | push_scalar_to_devices (int scalar_index) |
Detailed Description
IRockyTriangleScalarsModel
allows users to add new triangle scalars, find triangle scalars created in other modules or activate triangle scalars known to Rocky, during the setup phase of a module. Triangle scalars are special variables attached to boundary triangles, which are able to store values per triangle that are preserved between time iterations during a simulation.
Member Function Documentation
◆ add()
int IRockyTriangleScalarsModel::add | ( | const char * | name, |
const char * | unit, | ||
bool | output = true |
||
) |
- This method creates a new scalar variable of type
double
- for storing custom values during a simulation, preserving them between time iterations.
- Parameters
-
name The name given to the scalar variable. The purpose of this name is twofold. First, it enables to find this scalar variable from other module, in order to share their values. Second, if the scalar variable can be displayed in a 3D window as a property, this name will identify it in the Rocky UI. unit A string specifying the unit in S.I. associated to the scalar variable. output Enables/disables the storage in disk at output times, for the visualization and post-processing of the scalar values.
- Returns
- The index that will uniquely identify the scalar variable during the execution of the simulation.
◆ add_accumulation_scalar()
int IRockyTriangleScalarsModel::add_accumulation_scalar | ( | const char * | name, |
const char * | unit, | ||
bool | output = true |
||
) |
- This method creates a new scalar variable of type defined by template parameter
data_type
for storing custom values during a simulation, preserving them between time iterations. The scalar added with this method has a special behavior defined for pulling data from devices in multi-gpu simulations: It will accumulate those values in the host memory.
- Parameters
-
name The name given to the scalar variable. The purpose of this name is twofold. First, it enables to find this scalar variable from other module, in order to share their values. Second, if the scalar variable can be displayed in a 3D window as a property, this name will identify it in the Rocky UI. unit A string specifying the unit in S.I. associated to the scalar variable. output Enables/disables the storage in disk at output times, for the visualization and post-processing of the scalar values.
- Returns
- The index that will uniquely identify the scalar variable during the execution of the simulation.
◆ calculate_sum_over_geometries()
std::vector< double > IRockyTriangleScalarsModel::calculate_sum_over_geometries | ( | int | scalar_index | ) |
- Returns
- A vector of the size of geometries in a project, in which every value is the sum of the triangle scalar values associated to the triangles belonging to a geometry. Those values are ordered in the vector according to the indices assigned to the geometries in a project. The sums are performed only if the triangle scalars are of type
double
orIRockyStatisticsAccumulator
.
◆ enable_storage_of_exchanged_heat()
void IRockyTriangleScalarsModel::enable_storage_of_exchanged_heat | ( | ) |
- This method activates an internal triangle scalar that accumulates the heat
- exchanged by geometry triangles with surrounding particles and/or SPH fluid elements during a simulation. The value of this scalar at each geometry triangle and at a given time will be equal to the sum of the heat received by the triangle from all particles and/or SPH elements that interacted with it since the last reset event, which is triggered by the
IRockyTriangleScalarsModel::reset_exchanged_heat()
function.
◆ find()
int IRockyTriangleScalarsModel::find | ( | const char * | name | ) |
- This method searches for a scalar variable already created by other modules,
- in order to allow access to its values, or store new values on it, during the execution of the simulation.
- Parameters
-
name The name given to the scalar at the moment of its creation.
- Returns
- The index that uniquely identifies the wanted scalar if it was actually found. It returns -1 otherwise.
◆ pull_scalar_from_devices()
void IRockyTriangleScalarsModel::pull_scalar_from_devices | ( | int | scalar_index | ) |
Copies the scalar values defined by scalar_index from the device memory to the host memory (DRAM). When running a simulation in multi-GPU, the values of different devices will be accumulated (summed) in the scalar host memory. This method can only be called for scalars added with add_accumulation_scalar in multi-gpu simulations.
- Parameters
-
scalar_index the index of the scalar we want to copy.
◆ push_scalar_to_devices()
void IRockyTriangleScalarsModel::push_scalar_to_devices | ( | int | scalar_index | ) |
Send the current scalar values defined by scalar_index located in host memory (DRAM) to the devices memory.
- Parameters
-
scalar_index the index of the scalar we want to push to devices.
◆ reset()
void IRockyTriangleScalarsModel::reset | ( | int | scalar_index | ) |
- This method resets to zero all values stored in a scalar variable.
- Parameters
-
scalar_index The index attributed to the scalar variable at the moment of its creation.
◆ reset_exchanged_heat()
void IRockyTriangleScalarsModel::reset_exchanged_heat | ( | ) |
- This method resets an internal triangle scalar that accumulates the heat
- exchanged by geometry triangles with surrounding particles and/or SPH fluid elements. For example, this function may be called from within the
ROCKY_PLUGIN_BEGIN_ITERATION
hook. In that case, at the end of an iteration, a custom module can get the value of the total heat received by each triangle during the last timestep.
◆ set_dimension()
void IRockyTriangleScalarsModel::set_dimension | ( | int | scalar_index, |
double | dimension_factor | ||
) |
- The purpose of this method is to associate a dimensional factor
- to a scalar variable. This factor will be used to nondimensionalize their values. For instance, if the scalar represents a force, a force dimensional factor must be associated through this method. Dimensional factors for the fundamental magnitudes are provided by functions of a
IRockyModel
object.
- Parameters
-
scalar_index The index attributed to the scalar variable at the moment of its creation. dimension_factor The appropriate dimensional factor for the scalar variable.