precice / precice

A coupling library for partitioned multi-physics simulations, including, but not restricted to fluid-structure interaction and conjugate heat transfer simulations.
https://precice.org/
GNU Lesser General Public License v3.0
733 stars 178 forks source link

Check for duplicate vertices #998

Open fsimonis opened 3 years ago

fsimonis commented 3 years ago

Please describe the problem you are trying to solve.

Having duplicate vertices in a mesh is a common issue for users of the RBF mappings. Currently, preCICE does not have very descriptive error messages as there are many things that could go wrong with RBF.

Describe the solution you propose.

We could use the index trees to efficiently check for duplications and stop preCICE with an error message listing the repeated coordinates.

A possible configuration could look like this:

<mapping:rbf-thin-plate-splines direction="read" from="MyMesh2" to="MyMesh1" constraint="consistent" check-duplicates="1"/>

This could be the resulting error message:

ERROR: Mesh "MyMesh1" uses RBF but has vertices with duplicate coordinates, which is not allowed. Please use a different mapping or remove duplicates at these coordinates: [(0,0,0), (1,2,3)]

Open questions:

Describe alternatives you've considered

Provide scripts to check input meshes. This however does not help if the adapter creates duplicate vertices.

Additional context

nothing yet

BenjaminRodenberg commented 3 years ago

Depending on what you are doing you might even want duplicate vertices. See https://precice.org/couple-your-code-distributed-meshes.html. Therefore I think it's a good idea to make this check configurable.

Does it suffice to check the local partitions in case of a parallel solver?

Yes. Looking at the link above I think this is what we want. We allow having duplicates globally, but not locally.

davidscn commented 3 years ago

This is a very good idea and we should definitely add it. In my opinion it should be a debug feature though.

Should this be turned on by default?

Enabled if NDEBUG is defined.

Should this be configured in the RBF mapping tag or globally?

Enable it independent of the employed mapping since it is still a relevant debug message. (My) adapter development always starts with NN mapping.

Does it suffice to check the local partitions in case of a parallel solver?

I think the check becomes in parallel cases even more relevant. However, I would still see it as a debug feature and disable it in case too many ranks (say >10) are involved.

Do we need to check both input and output mesh?

Input meshes should be enough and we should have internal checks in case things might go wrong during the partitioning.

uekerman commented 3 years ago

Provide scripts to check input meshes. This however does not help if the adapter creates duplicate vertices.

In the long run, we want to reload preCICE vtks with ASTE. Then, we could check meshes of users by compiling preCICE in DEBUG mode and using them with ASTE.

oguzziya commented 3 years ago

I am not sure but it might be important for #986 #962 and #963. For connectivity-based mappings, we need to preserve the connectivity elements by defining vertices (and edges) globally multiple times. Otherwise, it will lead to wrong results, even worse broken simulations since scaled-consistent mapping cannot be executed if we do not have any connectivity element on a non-empty partition.

fsimonis commented 3 years ago

So we converge towards:

Be aware that limiting this check to debug builds means that it will never be "fast". This was my idea of adding a configuration option somewhere so that we could use it in release builds.

We could add further checks similar to the <export:vtk /> tags. Like this:

<participant name="..." />
   <check:vertex-duplication />
</participant>