Hi, I’m working on developing a preCICE adapter for coupling two different parallel fluid codes in 3D. I’m using fortran with MPI for domain decomposition. I’d like to use the linear-cell-interpolation mapping method of preCICE, and as such I need to define tetrahedra between vertices.
Because of MPI + tetrahdra decomposition, I’m somewhat close to the case Use a single mesh and duplicate copied vertices in https://precice.org/couple-your-code-distributed-meshes.html
In other words, let’s say that I have a mesh defined by
and the domain is split along x across multiple MPI tasks.
On the sender and receiver I have two different resolutions, i.e. different \Delta x and \Delta y, and the domain is periodic along y.
Because of periodicity (and more generally, if I’d like to use MPI also along y, which is the case), I thought creating two meshes, one on the sender, and one on the receiver. On the sender, I extend y to go from -\Delta y/2 to L_y+\Delta y/2 (for MPI decomposition along y, this would mean adding ghost cells at both ends). On the receiver, I keep y as given above. This way, I can put the periodic values var(x,-\Delta y/2)=var(x,L_y-\Delta y/2) and var(x,L_y+\Delta y/2)=var(x,\Delta y/2) into the send variable and, when performing the preCICE interpolation from one mesh to the other, ensure that the receive domain is fully contained into the domain of the sender (which is good for linear interpolations).
Now, I have the following problem: when I split x across MPI tasks, I will have the right boundary of rank-1 to be exactly the same as the left boundary of rank. For example, if L_x=1 and I use 2 MPI tasks, I will have x=0,dx,...,0.5 on rank 0 and x=0.5,0.5+dx,...,1.0 on rank 1. And therefore, I will have duplicated vertices among different MPI tasks. According to Use a single mesh and duplicate copied vertices, this doesn’t seem to be a major issue. However, when implementing it in a test code, it doesn’t work as expected.
I created an example, which I attach to this message (main.f90, inside the zip folder), together with the preCICE configure file I used. In short: I have one single program, which acts both as the sender and as the receiver. If it is invoked with the flag “0”, it acts as sender, if invoked with flag “1”, acts as receiver.
It then creates the 3D mesh (one for the sender and one for the receiver), as discussed above. Given that it is a structured cartesian grid with uniform \Delta x, \Delta y, and \Delta z, I use the standard Freudenthal method to decompose each hexaedron into thetrahedra.
I then create a 3D variable (varying only along z) and communicate via preCICE.
Everything runs fine when using 1 MPI task. On the other hand, when running with multiple processes, the program reports some filtering and missing thetraerda. As an example, I attach the output of the receiver for a run with
mpiexec -np 2 ../a.out 0
mpiexec -np 4 ../a.out 1
on two different terminals (the first command for the sender, the second for the receiver).
As can be seen in the out file inside files.zip, one of the receiver tasks report:
preCICE:WARNING: 1 of 2340 vertices of mesh meshSend have been filtered out since they have no influence on the mapping.
This is quite strange in my opinion, because if the problem are the duplicate vertices, I would expect more than one vertex to be filtered out. But, because of this filtering, I then see a bit below
preCICE: Linear Cell Interpolation is used, but some points from meshSend don't lie in the domain defined by the tetrahedra. These points have been projected on the domain boundary. This could come from non-matching discrete geometries or erroneous connectivity information. If distances seem too large, please check your mesh. The fallback statistics are: min:0.00349386 max:0.00349386 avg: 0.00349386 var: 0 cnt: 1
which is my main problem: the original send mesh fully contained the receive mesh, but because of the filtering of one vertex, I now have some missing tetrahedra.
This has further implications, as lower down I get the wrong result:
# 2 : recv: 0.12000000000000002 0.20000000000000001
Here, I’d like to note that the wrong result 0.1200000, rather than 0.2000000, doesn’t appear at each run, but only sometimes (not always reproducible, even if I use preCICE compiled in debug mode, and I compile my code with the -O1 flag).
I don’t understand if I’m doing something wrong, or if this setup is simply not supported by preCICE. Any help on this issue would be greatly appreciated.
Best,
Fabio
precice-config.xml (1.3 KB)
files.zip (3.6 KB)