Skip to content

Commit 749f8d1

Browse files
fsimonisuekerman
andauthored
Add documentation on how to handle moving meshes (#381)
Co-authored-by: Benjamin Uekermann <benjamin.uekermann@gmail.com>
1 parent d926e2c commit 749f8d1

3 files changed

Lines changed: 85 additions & 10 deletions

File tree

_data/sidebars/docs_sidebar.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,8 @@ entries:
503503
url: /couple-your-code-existing-mpi-environment.html
504504
output: web, pdf
505505

506-
- title: Dealing with moving meshes
507-
url: /couple-your-code-moving-meshes.html
506+
- title: Moving or changing meshes
507+
url: /couple-your-code-moving-or-changing-meshes.html
508508
output: web, pdf
509509

510510
- title: Dealing with FEM meshes

pages/docs/couple-your-code/couple-your-code-moving-meshes.md

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
title: Moving or changing meshes
3+
permalink: couple-your-code-moving-or-changing-meshes.html
4+
keywords: api, adapter, ALE, geometries, CFD
5+
summary: "preCICE supports ALE-methods, direct-mesh-access, and pseudo-meshes to handle most scenarios of moving or changing meshes. A remeshing API is on the roadmap and being actively developped."
6+
---
7+
8+
## Static reference domain
9+
10+
preCICE supports static meshes, meaning moving geometries can still be emulated using node displacements as described by the Arbitrary-Lagrangian-Eulerian or ALE-methods.
11+
12+
Note that spatially aware mapping-schemes in preCICE work in the reference domain, not the physical domain.
13+
14+
Examples of this method are the [perpendicular flap tutorials](tutorials-perpendicular-flap) and the [Turek-Hron FSI3 benchmark](tutorials-turek-hron-fsi3).
15+
16+
## Mapping inside adapter
17+
18+
In some cases, the mesh of a participant may fluctuate extremely between time steps or it may be unclear, where exactly sampling points are needed for following time steps.
19+
This includes particle methods, such as the Discrete Element Method (DEM), where particle centers are often points of interest.
20+
Directly representing them as vertices in a preCICE mesh would lead to strongly fluctuating meshes.
21+
22+
Another common method are overset meshes, which require moving meshes in addition to advanced mapping logic in the adapter.
23+
24+
For such cases, it may be the best way forward to [directly access the mesh](couple-your-code-direct-access) of the remote participant.
25+
After defining a region of interest and initializing the participant, the adapter can receive vertex coordinates and ids included in said region.
26+
27+
This information gives the dynamic participant the option to manage its own mapping to/from internal solver meshes, or to generate an interpolant over the region of interest allowing to freely sample any coordinates.
28+
29+
See the documentation of [the direct-access feature](couple-your-code-direct-access) for more information.
30+
31+
## Pseudo reference domain
32+
33+
Under some circumstances, it may be useful to manage a pseudo-mesh in both adapters.
34+
35+
First, define matching meshes with a fixed amount of pseudo-coordinates $$ coord(i) = (i, 0, 0) $$ in both adapters and configure a nearest-neighbour mapping between them.
36+
37+
Various data types can then be converted to `double` and written as `scalar` and `vector` data to those nodes.
38+
This can include a boolean data which encodes if a node is active or not.
39+
The adapters can now dynamically use these nodes by writing `1.0` or `0.0` to the `active` data of the local mesh.
40+
41+
This method trades communication efficiency for flexibility, as data is always stored as doubles and will always be fully transferred.
42+
43+
```xml
44+
<data:scalar name="active" /> <!-- Boolean 0.0 for off, 1.0 for on -->
45+
<data:vector name="position" />
46+
<data:scalar name="..." /> <!-- define more properties as needed -->
47+
```
48+
49+
Note that inactive nodes can lead to numerical instabilities in some acceleration schemes.
50+
51+
## Remeshing using preCICE
52+
53+
{% important %}
54+
This feature is in active development and not yet released. This section is part of the roadmap!
55+
{% endimportant %}
56+
57+
**Goal** of the remeshing support in preCICE to allow resetting meshes at runtime.
58+
59+
To change a mesh dynamically at runtime:
60+
61+
```python
62+
if (my_solver_wants_to_remesh):
63+
# reset the mesh
64+
participant.reset_mesh(mesh)
65+
# redefine the mesh
66+
new_ids = participant.set_mesh_vertices(mesh, new_coordinates)
67+
# write data to the newly defined mesh
68+
participant.write_data(mesh, data, new_ids, new_values)
69+
70+
# preCICE automatically handles the mesh change
71+
participant.advance(dt)
72+
```
73+
74+
This feature comes with runtime implications.
75+
Changing a mesh changes data-mapping schemes on the local as well as the receiving participant.
76+
This change may impact the required communication network between ranks of parallel participants.
77+
Furthermore, the ownership of watchpoints may move between ranks of a participant.
78+
79+
Consequently, preCICE has to reset the majority of its internal data structures.
80+
The cost for this is similar to calling `initialize()` on top of the cost of calling `advance()`.
81+
82+
This is probably impractical for solvers with meshes changing every timestep.
83+
For such cases, [mapping inside the adapter](#mapping-inside-adapter) of the dynamic solver should the method of choice.

0 commit comments

Comments
 (0)