(surface-integral-output)=
# Surface Integral Output

*Surface Integral Output computes surface integrals of custom user variables on selected surfaces and can optionally report moving statistics over time.*

---

## Available Options

| *Option* | *Description* | *Applicable* |
|----------|---------------|--------------|
| **Output fields** | Custom user variables to integrate over the assigned surfaces | always |
| **Statistics function** | Optional moving statistic applied to the integrated values | always |
| **Moving window size** | Window size for moving statistics (in output data points) | when **Statistics function** is not `None` |
| **Start step** | Step at which to start statistics calculation | when **Statistics function** is not `None` |
| **Assigned surfaces** | Surfaces used for the integral | always |


```{seealso}
For the underlying physics and configuration of outputs, see the {doc}`/user_guide/OutputConfiguration/OutputConfiguration` user guide.
```

---

## Detailed Descriptions

### Output fields

*The custom user variables to integrate over the selected surfaces.*

- **Required** (at least one field must be selected)
- **Allowed fields:** Custom user variables only
- **Example:** `PressureForce`, `HingeTorqueZ`
>**Note:** Surface Integral Output only accepts custom user variables. Define them in [Variable Settings](../../../05.tools/02.variable-settings.md) (Custom variables tab).

```{note}
Define the variable as the **local** quantity at a point on the surface. Area weighting is applied for you, so do not multiply by area yourself. The result is reported under the variable's name with an `_integral` suffix. Its unit is the variable's unit (the base unit of the **Unit system** selected for the variable in Variable Settings) multiplied by the area unit of the simulation's unit system: a mass flux in kg/(m²·s) integrates to kg/s, and a dimensionless variable integrates to m². The Monitor chart and the CSV file show the numbers without a unit label.
```

### Statistics function

*Optional moving statistic applied to the integrated values. When set to `None`, raw integral values are reported.*

- **Default:** `None`
- **Options:**
  - `None` - No statistics processing
  - `Mean` - Moving average
  - `Min` - Minimum in the window
  - `Max` - Maximum in the window
  - `Standard deviation` - Sample standard deviation (Bessel's correction)
  - `Deviation` - Range (maximum minus minimum) in the window

### Moving window size

*The number of output data points used in the moving statistics window.*

- **Default:** `10`
- **Minimum value:** `2`
>**Note:** For steady simulations, the solver typically outputs a data point every 10 pseudo steps. For unsteady simulations, it outputs every physical step.

### Start step

*The number of steps to skip before statistics calculation begins.*

- **Default:** `0`
>**Note:** For steady simulations, this value is rounded up to the nearest multiple of 10 (based on output cadence).

### Assigned surfaces

*The surfaces on which the integral is computed.*

- **Required:** Yes (at least one surface must be selected)
- **Supported surface types:**
  - Simulation surfaces (mesh boundaries)
  - Imported sample surfaces
>**Notes:**
> - Import sample surfaces in the Entities browser before selecting them. See [Sample Surfaces](../../../04.entities-browser/10.sample-surfaces.md).
> - Do not mix simulation surfaces and imported sample surfaces in a single Surface Integral Output. Create separate outputs if you need both.

---

## Examples

The two worked setups below show how to combine a custom user variable with assigned surfaces to integrate a quantity of interest. In every case the custom variable is defined first in [Variable Settings](../../../05.tools/02.variable-settings.md) (Custom variables tab), then selected under **Output fields** and integrated over the surfaces chosen under **Assigned surfaces**.

### (a) Hinge moment

- **Custom variable:** Define a user variable for the moment of the local surface force (pressure + viscous) about the hinge axis, e.g. the cross product of the position vector relative to a point on the hinge line with the combined pressure and wall-shear force, projected onto the hinge-axis direction: `HingeMoment = dot(cross(r - r_hinge, PressureForce + ViscousForce), hinge_axis)`.
- **Assigned surfaces:** The wall surfaces of the control surface that rotates about the hinge (e.g. the flap or aileron) only.
- **Result:** Integrating this variable over those surfaces yields the hinge moment, i.e. the moment required to hold (or actuate) the control surface about its hinge line.

### (b) Surface heat flux

- **Custom variable:** Define a user variable for the local wall heat flux (the conductive heat flux normal to the wall, e.g. `WallHeatFlux`).
- **Assigned surfaces:** The wall surface(s) of interest whose heat transfer you want to quantify.
- **Result:** Integrating this variable over those surfaces yields the total heat transfer rate through them.

```{seealso}
Python API: {py:class}`~flow360.SurfaceIntegralOutput`.

Define custom variables in {doc}`Variable Settings </gui_guide/05.tools/02.variable-settings>`.

Grab-and-Go snippet: {doc}`Show averaged force on a surface </python_api/grab_and_go_snippets/show_averaged_force_on_surface>`.

E2E Python example: {doc}`Hinge torques calculation </python_api/example_library/notebooks/hinge_torques>`.
```
