# 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"> 💡 Tips</h3></summary>

- Set max edge length to 1-10% of characteristic length
- Use smaller values in regions of high curvature
- Ensure smooth transition to neighboring regions
- Consider geometric complexity when setting edge length
- Balance resolution requirements with computational cost

<details style="padding-left:20px">
<summary><h4 style="display:inline-block"> Characteristic Length Guidelines</h4></summary>

- For wings: Use mean aerodynamic chord
- For fuselages: Use maximum diameter
- For complex geometries: Use smallest significant feature size
- For general cases: Use overall model length

</details>
</details>

---

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

- **How do I determine appropriate edge length?**  
  > Consider the smallest geometric feature requiring resolution and typical values (1-10% of characteristic length).

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

```python
from flow360 import SurfaceRefinement, u

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

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