> ## 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.

# IRockyFluidScalars Struct Reference

`#include <rocky_fluid_scalars.hpp>`

Inherits EntityScalars\< rocky20::FluidScalars >.

## Public Member Functions

| Type | Name |
| - | - |
| ROCKY\_FUNCTIONS double | [get\_scalar](#a75d5c92f06422a5d29704788404405d0) (int scalar\_index) const |
| ROCKY\_FUNCTIONS void | [set\_scalar](#aec66ca90576555d400f9c6d401b049e4) (int scalar\_index, double value) const |
| ROCKY\_FUNCTIONS void | [add\_scalar](#a536c29f3a14dc5bbed6047f43baa37ec) (int scalar\_index, double value) const |
| ROCKY\_FUNCTIONS void | [max\_scalar](#aaa969c416dea0ac4eb4721c5b8d75b24) (int scalar\_index, double value) const |

## Detailed Description

During the iterative process of a simulation, [`IRockyFluidScalars`](https://developer.synopsys.com/docs/rocky/rocky-solver-sdk/2025-r2/structIRockyFluidScalars) gives access to all fluid scalars defined in the project. These fluid scalars can be built-in scalars defined in the Rocky solver, or custom fluid scalars defined by the current module or other active modules.

## Member Function Documentation

### add\_scalar()

```cpp theme={null}
ROCKY_FUNCTIONS void IRockyFluidScalars::add_scalar(
    int scalar_index,
    double 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.

**In the case of fluid scalars that are marked as additional variables to be shared with Fluent,**

the value refers to the particle's contribution to the fluid cell, since Rocky will convert it to the cell value automatically by dividing by the cell volume \[m3] which the particle belongs to, and by the CFD timestep \[s].

**For example, when adding a mass source \[kg] to the fluid, the value**

will be converted to kg/m3.s before sending it to Fluent.

**In the case of fluid scalars which are Fluent additional inputs,**

**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. |

### get\_scalar()

```cpp theme={null}
ROCKY_FUNCTIONS double IRockyFluidScalars::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.

### max\_scalar()

```cpp theme={null}
ROCKY_FUNCTIONS void IRockyFluidScalars::max_scalar(
    int scalar_index,
    double 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\_scalar()

```cpp theme={null}
ROCKY_FUNCTIONS void IRockyFluidScalars::set_scalar(
    int scalar_index,
    double 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.

**In the case of fluid scalars that are marked as additional variables to be shared with Fluent,**

the value refers to the particle's contribution to the fluid cell, since Rocky will convert it to the cell value automatically by dividing by the cell volume \[m3] which the particle belongs to, and by the CFD timestep \[s].

**For example, when adding a mass source \[kg] to the fluid, the value**

will be converted to kg/m3.s before sending it to Fluent.

**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. |
