# Mesh parameters

*The Mesh parameters in Flow360 provide fundamental control over mesh generation, affecting both surface and volume mesh characteristics. These settings serve as global defaults that determine the quality and characteristics of the computational mesh.*

## Available Options

### Surface mesh

| *Option* | *Description* | *Applicable* |
|----------|---------------|--------------|
| [**Surface max edge length**](#surface-max-edge-length) | Maximum allowable edge length for surface elements | always |
| [**Geometry accuracy**](#geometry-accuracy) | Smallest length scale to be resolved by surface meshing | GeometryAI |
| [**Curvature resolution angle**](#curvature-resolution-angle) | Maximum angle a single surface mesh element can span | always |
| [**Target surface node count**](#target-surface-node-count) | Target number of nodes for the surface mesh | beta mesher, GeometryAI |
| [**Surface edge growth rate**](#surface-edge-growth-rate) | Controls the size progression of elements grown from edges | `advanced` |
| [**Surface max aspect ratio**](#surface-max-aspect-ratio) | Maximum aspect ratio for surface cells | `advanced`, GeometryAI |
| [**Resolve face boundaries**](#resolve-face-boundaries) | Whether to resolve boundaries between adjacent faces | `advanced`, GeometryAI |
| [**Surface max adaptation iterations**](#surface-max-adaptation-iterations) | Maximum iterations for surface mesh adaptation | `advanced`, GeometryAI |

### Volume mesh

| *Option* | *Description* | *Applicable* |
|----------|---------------|--------------|
| [**Boundary layer first layer thickness**](#boundary-layer-first-layer-thickness) | First layer thickness for volumetric anisotropic layers | always |
| [**Boundary layer growth rate**](#boundary-layer-growth-rate) | Growth rate for prismatic boundary layer elements | `advanced` |
| [**Volume edge growth rate**](#volume-edge-growth-rate) | Growth rate of the farfield (octree) volume cells away from the surface | `advanced`, beta mesher |
| [**Refinement factor**](#refinement-factor) | Global scaling factor for mesh refinement | `advanced` |
| [**Gap treatment strength**](#gap-treatment-strength) | Controls mesh behavior in narrow gaps | `advanced` |
| [**Number of boundary layers**](#number-of-boundary-layers) | Fixed number of boundary layer elements | `advanced`, beta mesher |
| [**Sliding interface tolerance**](#sliding-interface-tolerance) | Tolerance for sliding interface detection | `advanced` |
| [**Edge split layers at corners**](#edge-split-layers-at-corners) | Number of boundary layer edge-splitting layers at geometric corners | `advanced`, beta mesher |
| [**Octree base spacing**](#octree-base-spacing) | Base spacing for the octree volume mesher | `advanced`, beta mesher |

### Geometry

| *Option* | *Description* | *Applicable* |
|----------|---------------|--------------|
| [**Sealing size**](#sealing-size) | Threshold size below which geometry gaps are closed | `advanced`, GeometryAI |
| [**Preserve thin geometry**](#preserve-thin-geometry) | Whether thin geometry features should be resolved | `advanced`, GeometryAI |
| [**Remove hidden geometry**](#remove-hidden-geometry) | Removes internal geometry not visible to flow | `advanced`, GeometryAI |
| [**Min passage size**](#min-passage-size) | Minimum passage size that hidden geometry removal can resolve | `advanced`, GeometryAI, [**Remove hidden geometry**](#remove-hidden-geometry) is `On` |
| [**Baffle face treatment**](#baffle-face-treatment) | How baffle faces found during hidden geometry removal are handled | `advanced`, GeometryAI, [**Remove hidden geometry**](#remove-hidden-geometry) is `On` |
| [**Baffle thicken outward**](#baffle-face-treatment) | How far a thickened baffle shell extends past the original face on its more exposed side, x geometry accuracy | `advanced`, GeometryAI, [**Baffle face treatment**](#baffle-face-treatment) is `Thicken` |
| [**Baffle thicken inward**](#baffle-face-treatment) | How far a thickened baffle shell extends past the original face on its less exposed side, x geometry accuracy | `advanced`, GeometryAI, [**Baffle face treatment**](#baffle-face-treatment) is `Thicken` |
| [**Planar face tolerance**](#planar-face-tolerance) | Tolerance for detecting planar faces | `advanced` |

```{seealso}
For a deeper discussion of the meshing workflow and parameters, see {doc}`/user_guide/Meshing/Meshing`.
```


## Detailed Descriptions

### Surface mesh

#### Surface max edge length

*Defines the maximum allowable length for any mesh edge on surfaces.*

- **Required**
- **Units:** Length
>**Notes:**
>  - Can be overridden using [Surface Refinement](./06.refinements/02.surface-refinement.md)
>  - Should be chosen based on geometry scale and required resolution
>  - Affects overall mesh density and computational cost

#### Geometry accuracy

*The smallest length scale that will be resolved accurately by the surface meshing process.*

- **Required** (when using GeometryAI)
- **Units:** Length
>**Notes:**
>  - Only available when using GeometryAI
>  - Can be overridden with [Geometry Refinement](./06.refinements/07.geometry-refinement.md)
>  - A smaller value results in a finer mesh and higher cell count
>  - The GeometryAI mesher may stop early due to resource limits before fully achieving the requested accuracy; check the process log for an indication of early termination

```{important}
**Geometry accuracy warnings**

The meshing form evaluates your **Geometry accuracy** value against the largest dimension of the geometry bounding box (BBox), that is the largest of its extents along x, y and z, and displays a warning indicator on the field when the value falls outside the recommended range:

| Condition | Warning | Consequence |
|-----------|---------|-------------|
| Value **> 0.01 × largest BBox dimension** | *Geometry accuracy too coarse* | The mesher may fail to resolve small geometric features, causing it to "eat into" the underlying geometry. |
| Value **< 1e-5 × largest BBox dimension** | *Geometry accuracy too fine* | The resulting surface mesh will be unnecessarily large, significantly increasing cell count and meshing time. |

**These are warnings only** — the mesh may still complete successfully. However, values outside this range often lead to suboptimal results.

**How to resolve:**
- If the warning indicates the value is **too coarse**, reduce **Geometry accuracy** or, preferably, use a [Geometry Refinement](./06.refinements/07.geometry-refinement.md) to apply a finer accuracy locally on the specific faces or regions that require it, rather than lowering the global value.
- If the warning indicates the value is **too fine**, increase **Geometry accuracy** or use local [Geometry Refinement](./06.refinements/07.geometry-refinement.md) only on the faces that can have a coarser resolution.

Using local geometry refinements on specific faces is strongly recommended over adjusting the global **Geometry accuracy** value, as it gives you precise control without unnecessarily inflating the overall mesh size.
```

```{figure} ./Figures/geometry-accuracy-warnings.png
:alt: The Geometry accuracy field highlighted in yellow with a "Geometry accuracy too fine" tooltip visible above the input box in the Mesh parameters panel.
:align: center
:width: 80%

The **Geometry accuracy** field displays a yellow warning indicator when the value falls outside the recommended range relative to the geometry bounding box. The tooltip shown here reads *"Geometry accuracy too fine"*.
```

#### Curvature resolution angle

*Specifies the maximum angular deviation allowed in the surface mesh.*

- **Default:** `12 degrees`
- **Units:** Angle
>**Notes:**
>  - Controls both:
>    1. Angle between cell normal and underlying surface normal
>    2. Angle between line segment normal and underlying curve normal
>  - Can be overridden per face only when using GeometryAI
>  - Lower values capture curvature more accurately but increase mesh density

#### Target surface node count

*Target number of nodes for the surface mesh. When specified, the surface mesher scales the initial metric to achieve approximately this number of surface mesh nodes.*

- **Default:** `None`
- **Units:** Count
>**Notes:**
>  - Available with GeometryAI and beta surface meshers
>  - Cannot be overridden per face
>  - The specified parameters are not modified directly, the initial metric is scaled to achieve the target count, so resulting **Curvature resolution angle** may be different than specified. **Surface max edge length** is enforced regardless, which may lead to discrepancies between the target node count and the resulting node count.
>  - This setting does not affect the geometry-resolving behaviour of the mesher (controlled by parameters like **Geometry accuracy**).
>  - Useful for quickly controlling overall mesh density without manually tuning individual length-scale parameters

#### Surface edge growth rate

*Controls the size progression of mesh elements grown from edges, affecting the transition between regions of different refinement (anisotropic to isotropic).*

- **Default:** `1.2`
- **Units:** Dimensionless
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:** 
>  - Values must be greater than or equal to `1.0`, typically `1.1`–`1.25`
>  - Cannot be overridden per edge
>  - Higher values lead to faster mesh size growth but may reduce quality

#### Surface max aspect ratio

*Maximum aspect ratio allowed for surface mesh cells.*

- **Default:** `10`
- **Units:** Dimensionless
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:**
>  - Only available when using GeometryAI
>  - Cannot be overridden per face
>  - Lower values enforce more isotropic surface cells

#### Resolve face boundaries

*Toggle to specify whether boundaries between adjacent faces should be resolved accurately using anisotropic mesh refinement.*

- **Default:** `Off`
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:**
>  - Only applicable to GeometryAI
>  - Can be overridden per face with [Surface Refinement](./06.refinements/02.surface-refinement.md)
>  - Improves mesh quality at face intersections

#### Surface max adaptation iterations

*Maximum number of adaptation iterations for the surface mesher.*

- **Default:** `50`
- **Units:** Count
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:**
>  - Only available when using GeometryAI
>  - Higher values may improve mesh quality but increase meshing time

### Volume mesh

#### Boundary layer first layer thickness

*Specifies the height of the first prismatic layer adjacent to wall surfaces.*

- **Required**
- **Units:** Length
>**Notes:**
>  - Can be overridden using [Boundary Layer Refinement](./06.refinements/03.boundary-layer-refinement.md)
>  - Critical for achieving desired y+ values
>  - Should be calculated based on Reynolds number and desired y+ value

#### Boundary layer growth rate

*Defines the growth rate of prismatic layers in the boundary layer region.*

- **Default:** `1.2`
- **Units:** Dimensionless
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:**
>  - Controls thickness progression of successive boundary layer elements
>  - Values must be greater than or equal to `1.0`, typically `1.1`–`1.25`
>  - Lower values create more gradual growth but increase total element count
>  - Critical for accurate boundary layer resolution

#### Volume edge growth rate

*Controls how quickly the target cell size grows with distance from the surface as the farfield (octree) mesh expands away from it.*

- **Default:** `1.1`
- **Units:** Dimensionless
- **Advanced option** (found under the *Advanced* section in the UI)
>**Notes:**
>  - Only supported by the beta mesher; on other meshers a non-default value is ignored
>  - It sets the *target* cell size the mesher aims for at each distance from the surface, not the size ratio between neighbouring cells. The octree always changes cell size in `2:1` steps; the growth rate controls how far apart those steps fall
>  - Values must be greater than `1.0`, typically `1.05`–`1.3`
>  - Lower values keep the size steps closer together, giving smoother gradation (more cells); higher values let the mesh coarsen faster (fewer cells)
>  - Controls only the isotropic farfield growth; the prismatic boundary layer growth is set separately by **Boundary layer growth rate**

#### Refinement factor

*Global scaling factor that affects the overall mesh refinement level.*

- **Default:** `1`
- **Units:** Dimensionless
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:**
>  - Not supported with beta mesher
>  - Adjusts all spacings in refinement regions and first layer thickness to generate r-times finer mesh
>  - For example, if `refinement factor = 2`, all spacings will be divided by \( 2^{1/3} \), resulting in approximately 2× more nodes
>  - Useful for quick mesh resolution studies

#### Gap treatment strength

*Controls how the mesh transitions in narrow gaps between surfaces.*

- **Default:** `0` (beta mesher uses `1.0`)
- **Units:** Dimensionless (range: 0–1)
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:**
>  - `0` = no treatment, `1` = most conservative treatment
>  - Higher values dedicate more space to isotropic mesh in narrow gaps
>  - Critical for mesh quality in tight geometric spaces

#### Number of boundary layers

*Specifies a fixed number of volumetric anisotropic (boundary layer) elements.*

- **Default:** Automatic (mesher calculates required layers)
- **Units:** Count
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:**
>  - Only supported by the beta mesher
>  - Cannot be overridden per face
>  - When not specified, the volume mesher automatically calculates the required number of layers to grow boundary layer elements to isotropic size

#### Sliding interface tolerance

*Tolerance used for detecting or creating curves lying on sliding interfaces.*

- **Default:** `0.01`
- **Units:** Dimensionless (relative to smallest sliding interface radius defined within a case)
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:**
>  - Cannot be overridden per sliding interface
>  - Used when setting up rotating zones with sliding mesh interfaces
>  - Only affects mesh generation. It is unrelated to the solver's interface interpolation tolerance described in the [Rotation](../03.flow-solver/03.physics/03.rotation.md) guide.

#### Edge split layers at corners

*Number of layers in the boundary layer mesh that are considered for edge splitting at geometric corners.*

- **Default:** `1`
- **Units:** Count
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:**
>  - Only supported by the beta mesher
>  - Set to `0` to disable edge splitting at corners

#### Octree base spacing

*Sets the base cell size for the octree volume mesher, from which all element sizes in the volume mesh are derived.*

- **Default:**  `1 × project length unit`
- **Units:** Length
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:**
>  - Available with the beta mesher
>  - The octree mesher generates a hierarchy of cell sizes that are successive halves or doubles of the base spacing (e.g., `base/2`, `base/4`, … or `base*2`, `base*4`, …)
>  - To achieve the desired mesh resolution, set the base spacing so that the target refinement spacings align with values in this series

---

### Geometry

#### Sealing size

*Threshold size below which all geometry gaps are automatically closed.*

- **Default:** `0 m`
- **Units:** Length
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:**
>  - Only available when using GeometryAI
>  - Can be overridden with [Geometry Refinement](./06.refinements/07.geometry-refinement.md)
>  - Useful for closing small holes or gaps in imperfect CAD geometry
>  - Two mechanisms share this single value: one caps small planar openings on the imported geometry, the other closes openings while the surface is reconstructed. Which one applies to a given opening depends on the geometry, not on any extra setting. See {ref}`gai_sealing` for what each can and cannot close
>  - When set to a nonzero value, it must not be smaller than **Geometry accuracy**. A smaller value is rejected and meshing does not start

#### Preserve thin geometry

*Toggle to specify whether thin geometry features should be resolved accurately during the surface meshing process.*

- **Default:** `Off`
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:**
>  - Only available when using GeometryAI
>  - Resolves features with thickness roughly equal to **Geometry accuracy**
>  - Can be overridden with [Geometry Refinement](./06.refinements/07.geometry-refinement.md)
>  - May improve mesh quality but increase meshing time

#### Remove hidden geometry

*Toggle to specify whether internal geometry not visible to the flow (e.g., a steering wheel inside a car body) should be removed before meshing.*

- **Default:** `Off`
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:**
>  - Only available when using GeometryAI
>  - Removes enclosed geometry that has no influence on the external flow, reducing mesh complexity
>  - Use **Min passage size** to control the minimum passage size that the removal algorithm can resolve

#### Min passage size

*Minimum passage size that the hidden geometry removal algorithm can resolve.*

- **Default:** Derived automatically from **Geometry accuracy** and **Sealing size**
- **Units:** Length
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:**
>  - Only available when using GeometryAI
>  - Can only be specified when **Remove hidden geometry** is enabled
>  - Internal regions connected by passages smaller than this value may not be detected and removed
>  - If not specified, the value is derived from **Geometry accuracy** and **Sealing size**
>  - When specified, it must not be smaller than **Geometry accuracy**, nor smaller than **Sealing size** when that is nonzero. A smaller value is rejected and meshing does not start
>  - Can be overridden per face via [Geometry Refinement](./06.refinements/07.geometry-refinement.md)

#### Baffle face treatment

*Setting controlling how baffle faces are handled. A baffle face is an input face with both sides facing the exterior flow, detected during hidden geometry removal.*

**Possible selections:**
- `Default` - Baffle faces pass through this stage unchanged. No special baffle handling is applied here, but they can still be modified further downstream in the GeometryAI process, for example when **Sealing size** is nonzero and gap sealing closes the gap around a baffle
- `Remove` - Baffle faces are deleted
- `Thicken` - Each baffle is inflated into a thin closed shell so it survives as a manifold part of the mesh

- **Default:** `Default` (no special baffle handling at this stage)
- **Requires:** **Remove hidden geometry** set to `On`. Selecting `Remove` or `Thicken` without it is rejected at validation
- **Advanced option** (found under the *Advanced* section in the UI)

```{figure} ../../../user_guide/Meshing/Figures/gai_baffle_face_treatment.svg
:align: center
:width: 100%

The three selections applied to a baffle face. `Thicken` keeps the face's in-plane extent and only gains thickness; by default the shell is built symmetrically about the original face, while **Baffle thicken outward** / **Baffle thicken inward** allow for customization.
```

>**Notes:**
>  - Only available when using GeometryAI
>  - Baffle faces are detected as part of hidden geometry removal
>  - This is a meshing **preprocessing** step: with `Remove` or `Thicken`, a baffle face does not survive as a non-manifold face in the final mesh. It is not the same thing as a *sample surface* (see the note below)
>  - **Baffle thicken outward** and **Baffle thicken inward** each default to 2.0 x **Geometry accuracy**; their sum is the shell thickness and must be at least 4.0. Which side is "outward" is inferred from the surrounding geometry; where the two sides are equally exposed, the total is split evenly instead
>  - The treatment and both extents can also be set for individual face groups on a [Geometry Refinement](./06.refinements/07.geometry-refinement.md), added under **Refinements**, which overrides the global setting on the faces it lists

```{note}
**Baffle face vs. sample surface.** These two non-manifold-surface concepts are easy to confuse but serve opposite purposes:

| Concept | What it is | When it is used |
| --- | --- | --- |
| **Baffle face** | A non-manifold input face (both sides facing the exterior) that the mesher removes or thickens into a manifold mesh, controlled by **Baffle face treatment** above. A meshing preprocessing step (GeometryAI only). | Cleaning up CAD before meshing. The baffle does not survive as a non-manifold face in the final mesh. |
| **Sample surface** | A user-uploaded non-manifold surface used to monitor scalar quantities (e.g. mass flow rate) at internal locations such as an HVAC outlet. It is **not represented in the mesh**; the flow solution is sampled onto it. See [Sample Surfaces](../../04.entities-browser/10.sample-surfaces.md). | Post-run measurements at internal cross-sections of a manifold mesh. |
```

#### Planar face tolerance

*Tolerance used for detecting planar faces in the input geometry that need to be remeshed, such as symmetry planes.*

- **Default:** `1e-6`
- **Units:** Dimensionless (relative to largest bounding box dimension)
- **Advanced option** — found under the *Advanced* section in the UI
>**Notes:**
>  - Cannot be overridden per face
>  - Used to identify and preserve flat surfaces during meshing

---

<details>
<summary><h3 style="display:inline-block"> 💡 Tips</h3></summary>

- Set **Surface max edge length** based on the largest geometric features requiring resolution
- For GeometryAI workflows, start with a larger **Geometry accuracy** and decrease iteratively to find the optimal balance
- Calculate **Boundary layer first layer thickness** based on desired $y^+$ value using Reynolds number and flow conditions. Remember that $y^+$ changes dynamically with flow velocity and fluid properties, not just mesh size.
- Enable **Preserve thin geometry** when your model has thin features (e.g., trailing edges, fins) that must be captured
- Enable **Remove hidden geometry** when your geometry contains internal cavities or parts (e.g., engine compartments, interior trim) that are hidden from the flow and should not affect the mesh

</details>

---

<details>
<summary><h3 style="display:inline-block"> ❓ Frequently Asked Questions</h3></summary>

- **How do I determine the appropriate first layer thickness?**
  > Calculate based on desired y+ value using Reynolds number and flow conditions. For turbulent flow with wall functions, target y+ ≈ 30–100. For resolving the viscous sublayer, target y+ < 1.

- **What is Geometry accuracy and when do I need it?**
  > Geometry accuracy defines the smallest feature size the surface mesher will resolve. It is required when using GeometryAI and should be set based on the smallest important geometric features in your model.

- **When should I use Preserve thin geometry?**
  > Enable this when your geometry contains thin features (like trailing edges or cooling fins) with thickness close to the Geometry accuracy value that must be captured accurately.

- **What surface edge growth rate should I use?**
  > Start with the default of `1.2`. Use lower values (`1.1`–`1.15`) for more gradual transitions in critical regions, and higher values (up to `1.3`) where rapid growth is acceptable.

- **What is the difference between volume edge growth rate and boundary layer growth rate?**
  > **Boundary layer growth rate** controls the thickness progression of the prismatic layers grown normal to the wall. **Volume edge growth rate** (beta mesher only) controls how quickly the isotropic farfield (octree) cells grow as they move away from the surface. They govern different parts of the volume mesh and are set independently.

- **How does gap treatment strength affect my mesh?**
  > Higher values create more isotropic cells in narrow gaps, improving mesh quality but potentially increasing cell count. For automotive simulations, a value of `1.0` is recommended.

- **When should I use Remove hidden geometry?**
  > Enable this when your geometry contains internal parts that are enclosed and not exposed to the flow (e.g., a steering column inside a car cabin). Removing such geometry reduces mesh complexity and meshing time without affecting solution accuracy.

- **What should I set Min passage size to?**
  > In most cases, leaving it unset is sufficient — the mesher derives an appropriate value from **Geometry accuracy** and **Sealing size**. Set it explicitly only when internal cavities are connected by very thin passages that you need to ensure are detected.


</details>

---

<details>
<summary><h3 style="display:inline-block"> 🐍 Python Example Usage</h3></summary>

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

Example Library notebooks:
- {doc}`/python_api/example_library/notebooks/cube_snappy`
- {doc}`/python_api/example_library/notebooks/2D_CRM_airfoil`
```

```python
import flow360 as fl

# Basic meshing defaults
meshing_defaults = fl.MeshingDefaults(
    surface_edge_growth_rate=1.2,
    surface_max_edge_length=0.1 * fl.u.m,
    curvature_resolution_angle=12 * fl.u.deg,
    boundary_layer_growth_rate=1.2,
    boundary_layer_first_layer_thickness=0.01 * fl.u.mm,
    volume_edge_growth_rate=1.1,  # beta mesher only
    octree_spacing=fl.OctreeSpacing(base_spacing=0.1 * fl.u.m),
)

# With GeometryAI features
meshing_defaults_gai = fl.MeshingDefaults(
    geometry_accuracy=0.001 * fl.u.m,
    surface_edge_growth_rate=1.2,
    surface_max_edge_length=0.1 * fl.u.m,
    surface_max_aspect_ratio=10,
    curvature_resolution_angle=12 * fl.u.deg,
    boundary_layer_growth_rate=1.2,
    boundary_layer_first_layer_thickness=0.01 * fl.u.mm,
    octree_spacing=fl.OctreeSpacing(base_spacing=0.1 * fl.u.m),
    preserve_thin_geometry=True,
    sealing_size=0.0001 * fl.u.m,
    remove_hidden_geometry=True,
    min_passage_size=0.005 * fl.u.m,
    target_surface_node_count=500000,
)
```

</details>
