# Is local remeshing possible with fenicsx?

**URL:** <https://fenicsproject.discourse.group/t/is-local-remeshing-possible-with-fenicsx/15870>\
**Category:** General\
**Tags:** mesh\
**Created:** [September 23, 2024, 9:36am UTC](https://fenicsproject.discourse.group/t/is-local-remeshing-possible-with-fenicsx/15870 "2024-09-23T09:36:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmpi](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@mmpi](https://fenicsproject.discourse.group/u/mmpi)\
**Post date:** [September 23, 2024, 9:36am UTC](https://fenicsproject.discourse.group/t/is-local-remeshing-possible-with-fenicsx/15870/1 "2024-09-23T09:36:45Z")

</div>

Hi all, I want to use fenicsx to solve fluid dynamics problems, and I am quite new to it.

I want to let a triangular mesh advect with the flows (Lagrangian approach). However, this means that I will have to remesh from time to time to prevent triangles to become too elongated. I want to try an approach of local remeshing where I replace just two adjacent very elongated triangles by two other triangles. Does a function already exist that does this in fenicsx? If not, does fenicsx give me sufficiently fine-grained access to the implementation that I can carry out this topology change (and the corresponding local interpolation of all functions) in python by hand, or would I need to talk to the cpp interface?

Thanks in advance for the help!

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [September 23, 2024, 2:11pm UTC](https://fenicsproject.discourse.group/t/is-local-remeshing-possible-with-fenicsx/15870/2 "2024-09-23T14:11:39Z")

</div>

You can access all the functionality in topology to do some local refinement.  
The functions are exposed in Python through:

> <https://github.com/FEniCS/dolfinx/blob/main/python/dolfinx/wrappers/mesh.cpp#L613-L653>

Especially:

> <https://github.com/FEniCS/dolfinx/blob/main/python/dolfinx/wrappers/mesh.cpp#L619-L623>

Set connectivity, which you should set between (tdim, 0).

For interpolation from one Mesh to a modified one, I would probably use `interpolate_nonmatching`, as you will have to re-create the function space and dofmap once the topology has been modified (The dofmap depends on the topology).
