> ## Documentation Index
> Fetch the complete documentation index at: https://developer.synopsys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# IRockySPHElementScalars Struct Reference

`#include <rocky_sph_element_scalars.hpp>`

Inherits EntityScalars\< rocky20::SPHParticleScalars >.

## Public Member Functions

| Type | Name |
| - | - |
| template\<class \_data\_type = float> ROCKY\_FUNCTIONS \_data\_type | [get\_scalar](#acf45b1ddd0d68df837ec264d2758693f) (int scalar\_index) const |
| ROCKY\_FUNCTIONS float | [get\_turbulent\_viscosity](#af70cf6bb3041f4c5e9a8c336ea47b201) () const |
| ROCKY\_FUNCTIONS float | [get\_temperature](#aa7d031c763a7c8c643ec7a86c07ae6d3) () const |
| ROCKY\_FUNCTIONS float | [get\_heat\_transfer](#a8a1580996da5f171f535de7e7487fe01) () const |
| ROCKY\_FUNCTIONS float3 | [get\_velocity\_gradient\_x](#a21d991fe945a35f8c7a1f4dffd7c5fe4) () const |
| ROCKY\_FUNCTIONS float3 | [get\_velocity\_gradient\_y](#a0b6e39222f53c9977ed3cdcf74cb4a9f) () const |
| ROCKY\_FUNCTIONS float3 | [get\_velocity\_gradient\_z](#ace9533abcbc59ad7581a97d988d4c880) () const |
| template\<class \_data\_type = float> ROCKY\_FUNCTIONS void | [set\_scalar](#a5dae91ede893e406367059aae00764d5) (int scalar\_index, \_data\_type value) const |
| ROCKY\_FUNCTIONS void | [set\_turbulent\_viscosity](#aebb2bc65cb47b22517249ce65c8728a8) (const float value) |
| ROCKY\_FUNCTIONS void | [set\_temperature](#aa04f956ddd857b6b6fd7e2a6fe44a494) (const float value) |
| ROCKY\_FUNCTIONS void | [set\_heat\_transfer](#af40e66b6c4bbea654f110c9d42b3a72f) (const float value) |
| template\<class \_data\_type = float> ROCKY\_FUNCTIONS void | [add\_scalar](#a72d99d6c1f69b32a5e9e77325974b1f1) (int scalar\_index, \_data\_type value) const |
| ROCKY\_FUNCTIONS void | [add\_turbulent\_viscosity](#a22c42af1b9c839d1693a42ac889a09df) (const float value) |
| ROCKY\_FUNCTIONS void | [add\_temperature](#ae6f55ad8e1a6915cccbade3f199315a4) (const float value) |
| ROCKY\_FUNCTIONS void | [add\_heat\_transfer](#ace6ee0291cca05f39eb04ba4c760afe0) (const float value) |
| template\<class \_data\_type = float> ROCKY\_FUNCTIONS void | [max\_scalar](#af020615c90124b8fe6d7168e964515b6) (int scalar\_index, \_data\_type value) const |

## Detailed Description

When running a simulation, an [`IRockySPHElementScalars`](https://developer.synopsys.com/docs/rocky/rocky-solver-sdk/2025-r2/structIRockySPHElementScalars) object gives access to all SPH element scalars defined in the project. These SPH element scalars can be built-in scalars defined within the Rocky solver, or custom SPH element scalars defined by the current module or other active modules.

## Member Function Documentation

### add\_heat\_transfer()

```cpp theme={null}
ROCKY_FUNCTIONS void IRockySPHElementScalars::add_heat_transfer(const float value)
```

**This method can be used for accumulating the heat transfer rate values that a**

SPH element interchanges with the surrounding SPH elements, DEM elements and geometries.

**Parameters**

| Name | Description |
| - | - |
| value | The heat transfer rate value to be added. |

### add\_scalar()

```cpp theme={null}
template<class _data_type = float>
ROCKY_FUNCTIONS void IRockySPHElementScalars::add_scalar(
    int scalar_index,
    _data_type value
) const
```

**If a custom scalar variable was defined during the setup of the module,**

this method can be used to sum a value to the current one stored in it.

**Parameters**

| Name | Description |
| - | - |
| scalar\_index | The integer index that was associated to the scalar variable during the setup of the module. |
| value | The value that must be summed to the current stored value. |

### add\_temperature()

```cpp theme={null}
ROCKY_FUNCTIONS void IRockySPHElementScalars::add_temperature(const float value)
```

**This method sums a value to the current temperature of a SPH element.**

**Parameters**

| Name | Description |
| - | - |
| value | The value to be added to the temperature. |

### add\_turbulent\_viscosity()

```cpp theme={null}
ROCKY_FUNCTIONS void IRockySPHElementScalars::add_turbulent_viscosity(const float value)
```

**This method sums a value to the current turbulent viscosity stored for the SPH element.**

**Parameters**

| Name | Description |
| - | - |
| value | The value summed to the turbulent viscosity. |

### get\_heat\_transfer()

```cpp theme={null}
ROCKY_FUNCTIONS float IRockySPHElementScalars::get_heat_transfer() const
```

**Returns**

The value of the total heat transfer rate towards/from the SPH element. Heat transfer rate is a built-in SPH element scalar defined by the Rocky solver, which is activated when a thermal model is enabled in a project.

### get\_scalar()

```cpp theme={null}
template<class _data_type = float>
ROCKY_FUNCTIONS _data_type IRockySPHElementScalars::get_scalar(int scalar_index) const
```

**If a custom scalar variable was defined during the setup of the module,**

the value currently stored can be accessed with this method.

**Parameters**

| Name | Description |
| - | - |
| scalar\_index | The integer index that was associated to the scalar variable during the setup of the module. |

**Returns**

The value currently stored in the scalar variable.

### get\_temperature()

```cpp theme={null}
ROCKY_FUNCTIONS float IRockySPHElementScalars::get_temperature() const
```

**Returns**

The value of the temperature of the SPH element. Temperature is a built-in SPH element scalar defined by the Rocky solver, which is activated when a thermal model is enabled in a project.

### get\_turbulent\_viscosity()

```cpp theme={null}
ROCKY_FUNCTIONS float IRockySPHElementScalars::get_turbulent_viscosity() const
```

**Returns**

The value of the turbulent viscosity. Turbulent viscosity is a built-in SPH element scalar defined in the Rocky solver, whose values can be calculated either by a built-in model or by a custom module.

### get\_velocity\_gradient\_x()

```cpp theme={null}
ROCKY_FUNCTIONS float3 IRockySPHElementScalars::get_velocity_gradient_x() const
```

**Returns**

The gradient of the component of the SPH element velocity along the X-axis. Velocity gradients are built-in SPH element scalars defined by the Rocky solver, which is activated manually when a module calls `IRockySPHElementScalarsModel::enable_gradient_velocity()` at setup hook.

### get\_velocity\_gradient\_y()

```cpp theme={null}
ROCKY_FUNCTIONS float3 IRockySPHElementScalars::get_velocity_gradient_y() const
```

**Returns**

The gradient of the component of the SPH element velocity along the Y-axis. Velocity gradients are built-in SPH element scalars defined by the Rocky solver, which is activated manually when a module calls `IRockySPHElementScalarsModel::enable_gradient_velocity()` at setup hook.

### get\_velocity\_gradient\_z()

```cpp theme={null}
ROCKY_FUNCTIONS float3 IRockySPHElementScalars::get_velocity_gradient_z() const
```

**Returns**

The gradient of the component of the SPH element velocity along the Z-axis. Velocity gradients are built-in SPH element scalars defined by the Rocky solver, which is activated manually when a module calls `IRockySPHElementScalarsModel::enable_gradient_velocity()` at setup hook.

### max\_scalar()

```cpp theme={null}
template<class _data_type = float>
ROCKY_FUNCTIONS void IRockySPHElementScalars::max_scalar(
    int scalar_index,
    _data_type value
) const
```

**If a custom scalar variable was defined during the setup of the module,**

this method can be used to make the scalar store the maximum of a set of values. A common use of this method is, for instance, to find the maximum among a set of values associated to the contacts of a particle.

**Parameters**

| Name | Description |
| - | - |
| scalar\_index | The integer index that was associated to the scalar variable during the setup of the module. |
| value | A value that must be checked if it is greater than the current stored value. |

### set\_heat\_transfer()

```cpp theme={null}
ROCKY_FUNCTIONS void IRockySPHElementScalars::set_heat_transfer(const float value)
```

**This method can be used by a custom module implementing a thermal model in order to**

set the calculated value of the total heat transfer towards/from a SPH element.

**Parameters**

| Name | Description |
| - | - |
| value | The value of the heat transfer rate to be set. |

### set\_scalar()

```cpp theme={null}
template<class _data_type = float>
ROCKY_FUNCTIONS void IRockySPHElementScalars::set_scalar(
    int scalar_index,
    _data_type value
) const
```

**If a custom scalar variable was defined during the setup of the module,**

this method can be used to store a value on it.

**Parameters**

| Name | Description |
| - | - |
| scalar\_index | The integer index that was associated to the scalar variable during the setup of the module. |
| value | The value that must be stored. |

### set\_temperature()

```cpp theme={null}
ROCKY_FUNCTIONS void IRockySPHElementScalars::set_temperature(const float value)
```

**This method can be used by a custom module implementing a thermal model in order to**

set the value of the temperature of a SPH element.

**Parameters**

| Name | Description |
| - | - |
| value | The value of the temperature to be set. |

### set\_turbulent\_viscosity()

```cpp theme={null}
ROCKY_FUNCTIONS void IRockySPHElementScalars::set_turbulent_viscosity(const float value)
```

**This method can be used by a custom module implementing a turbulent model in order to**

set the value of the turbulent viscosity for later use in the flow equations.

**Parameters**

| Name | Description |
| - | - |
| value | The value of the turbulent viscosity. |
