# Surface Refinement

*Surface refinement provides direct control over the maximum permissible size of surface mesh elements, ensuring adequate resolution of geometric features and maintaining mesh quality across surfaces.*

---

## Available Options

| *Option* | *Description* |
|------------|-----------------|
| **Max edge length** | Maximum allowed length of surface mesh edges |
| **Assigned surfaces** | Target surfaces for refinement application |

---

## Detailed Descriptions

### Max Edge Length

*Defines the upper bound for surface mesh element size.*

- **Required**
- **Example:** `0.05 m`
>**Note:** Should be chosen based on smallest geometric feature requiring resolution.

### Assigned surfaces

*Specifies the geometric surfaces where refinement will be applied.*

- **Required**
>**Notes:** 
>  - Must reference valid surface entities in the geometry. 
>  - Assign the boundaries by selecting from the list using the + button or select graphically in the viewer region.

---

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

- **What happens if surface refinements overlap?**  
  > The finest (smallest) edge length will be applied in overlapping regions.

</details>

---

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

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

```python
import flow360 as fl

# Surface refinement for wing
surface_ref = fl.SurfaceRefinement(
    name="wing_surface",
    faces=[wing_surface],
    max_edge_length=0.05 * fl.u.m
)

# Surface refinement for complex geometry
complex_surface_ref = fl.SurfaceRefinement(
    name="complex_surface",
    faces=[complex_surface],
    max_edge_length=0.02 * fl.u.m  # Smaller value for complex features
)
```
</details> 