    

 ## On this page

  

 

 # IRockyTriangleScalarsModel Struct Reference

 Last update: 17.07.2025 

`#include <<a class="el" href="rocky__triangle__scalars_8hpp_source.xhtml">rocky_triangle_scalars.hpp</a>>`

Inherits ScalarsModel&lt; rocky20::TriangleScalarsController &gt;.

## <a id="pub-methods" name="pub-methods"></a>Public Member Functions

int [find](structIRockyTriangleScalarsModel.xhtml#afc273a1e67e4995f848452fda3f71c31) (const char \*name) int [add](structIRockyTriangleScalarsModel.xhtml#a41b8986cbde7d37e0946a3a8a8361d19) (const char \*name, const char \*unit, bool output=true) template&lt;class data\_type &gt; int [add\_accumulation\_scalar](structIRockyTriangleScalarsModel.xhtml#ac3e84af17e0dfaea602eab3a7a888b83) (const char \*name, const char \*unit, bool output=true) void [reset](structIRockyTriangleScalarsModel.xhtml#ae4f5d565ed2b3fa05b52f9274d542d69) (int scalar\_index) void [set\_dimension](structIRockyTriangleScalarsModel.xhtml#aa02d862be5d91a62af18a1b1320286e7) (int scalar\_index, double dimension\_factor) void [enable\_storage\_of\_exchanged\_heat](structIRockyTriangleScalarsModel.xhtml#a01f4979062e25a0fb10b874f9f1f81d9) () void [reset\_exchanged\_heat](structIRockyTriangleScalarsModel.xhtml#abe794fd133422249549fad8c56fee6eb) () std::vector&lt; double &gt; [calculate\_sum\_over\_geometries](structIRockyTriangleScalarsModel.xhtml#acba5f06875d88bba1d66bd829c37fb52) (int scalar\_index) void [pull\_scalar\_from\_devices](structIRockyTriangleScalarsModel.xhtml#a60ee5f18541c3104a7a286d244a5f896) (int scalar\_index) void [push\_scalar\_to\_devices](structIRockyTriangleScalarsModel.xhtml#a1111ee6479b40ce1e086aec31c405e3e) (int scalar\_index) <a id="details" name="details"></a>## Detailed Description

`<a class="el" href="structIRockyTriangleScalarsModel.xhtml">IRockyTriangleScalarsModel</a>` 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

<a id="a41b8986cbde7d37e0946a3a8a8361d19" name="a41b8986cbde7d37e0946a3a8a8361d19"></a>## [◆ ](#a41b8986cbde7d37e0946a3a8a8361d19)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 nameThe 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.unitA string specifying the unit in S.I. associated to the scalar variable.outputEnables/disables the storage in disk at output times, for the visualization and post-processing of the scalar values.ReturnsThe index that will uniquely identify the scalar variable during the execution of the simulation. 



<a id="ac3e84af17e0dfaea602eab3a7a888b83" name="ac3e84af17e0dfaea602eab3a7a888b83"></a>## [◆ ](#ac3e84af17e0dfaea602eab3a7a888b83)add\_accumulation\_scalar()

template&lt;class data_type &gt; 

 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 nameThe 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.unitA string specifying the unit in S.I. associated to the scalar variable.outputEnables/disables the storage in disk at output times, for the visualization and post-processing of the scalar values.ReturnsThe index that will uniquely identify the scalar variable during the execution of the simulation. 



<a id="acba5f06875d88bba1d66bd829c37fb52" name="acba5f06875d88bba1d66bd829c37fb52"></a>## [◆ ](#acba5f06875d88bba1d66bd829c37fb52)calculate\_sum\_over\_geometries()

 std::vector&lt; double &gt; IRockyTriangleScalarsModel::calculate\_sum\_over\_geometries  ( int  *scalar\_index*) 

ReturnsA 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` or `<a class="el" href="structIRockyStatisticsAccumulator.xhtml">IRockyStatisticsAccumulator</a>`. 



<a id="a01f4979062e25a0fb10b874f9f1f81d9" name="a01f4979062e25a0fb10b874f9f1f81d9"></a>## [◆ ](#a01f4979062e25a0fb10b874f9f1f81d9)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 `<a class="el" href="structIRockyTriangleScalarsModel.xhtml#abe794fd133422249549fad8c56fee6eb">IRockyTriangleScalarsModel::reset_exchanged_heat()</a>` function. 



<a id="afc273a1e67e4995f848452fda3f71c31" name="afc273a1e67e4995f848452fda3f71c31"></a>## [◆ ](#afc273a1e67e4995f848452fda3f71c31)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 nameThe name given to the scalar at the moment of its creation.ReturnsThe index that uniquely identifies the wanted scalar if it was actually found. It returns -1 otherwise. 



<a id="a60ee5f18541c3104a7a286d244a5f896" name="a60ee5f18541c3104a7a286d244a5f896"></a>## [◆ ](#a60ee5f18541c3104a7a286d244a5f896)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\_indexthe index of the scalar we want to copy. 



<a id="a1111ee6479b40ce1e086aec31c405e3e" name="a1111ee6479b40ce1e086aec31c405e3e"></a>## [◆ ](#a1111ee6479b40ce1e086aec31c405e3e)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\_indexthe index of the scalar we want to push to devices. 



<a id="ae4f5d565ed2b3fa05b52f9274d542d69" name="ae4f5d565ed2b3fa05b52f9274d542d69"></a>## [◆ ](#ae4f5d565ed2b3fa05b52f9274d542d69)reset()

 void IRockyTriangleScalarsModel::reset  ( int  *scalar\_index*) 

This method resets to zero all values stored in a scalar variable.Parameters scalar\_indexThe index attributed to the scalar variable at the moment of its creation. 



<a id="abe794fd133422249549fad8c56fee6eb" name="abe794fd133422249549fad8c56fee6eb"></a>## [◆ ](#abe794fd133422249549fad8c56fee6eb)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. 



<a id="aa02d862be5d91a62af18a1b1320286e7" name="aa02d862be5d91a62af18a1b1320286e7"></a>## [◆ ](#aa02d862be5d91a62af18a1b1320286e7)set\_dimension()

 void IRockyTriangleScalarsModel::set\_dimension  ( int  *scalar\_index*,    double  *dimension\_factor*   ) 

The purpose of this method is to associate a dimensional factorto 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 `<a class="el" href="structIRockyModel.xhtml">IRockyModel</a>` object.Parameters scalar\_indexThe index attributed to the scalar variable at the moment of its creation.dimension\_factorThe appropriate dimensional factor for the scalar variable.