When compiled in parallel mode the edges in a parallel dune-uggrid are broken. More specifically: In a 3d grid obtained from successive local refinement of a simplex the leaf grid contains edges that have a non-trivial intersection. E.g. they intersect in a point that is neither a vertex of one or the other edge. When compiled in sequential mode this does not happen. Moreover, the number of total edges is larger in parallel mode while the number of elements, faces, and vertices is the same. One can also observe, that the centers of the elements are different.
The attached example demonstrates the issue: uggrid-failure.cc . It works nicely when dune is set to sequential mode and the edge count is different.
I was unsure if this should be files here or for dune-uggrid. Since I have a vague memory that UG does not provide edges by itself and that they are implemented in the dune bindings I picked dune-grid.
Designs
Child items 0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items 0
Link issues together to show that they're related.
Learn more.
Can you install a sequential and a parallel version, and step through the two side-by-side
with the debugger?
Both versions use the same code paths, only the parallel version has a few extra bits
guarded with #ifdef ModelP. It should be relatively easy to find the spot where the sequential
and parallel code deviates.
There is something really fishy going on here. The resulting grid contains vertices that are neither vertices nor edge midpoints of their father elements. That should not happen on a simplicial grid, right?
I feel really uncomfortable about staging/dune-uggrid@5f06ebe2 by now (I somehow cannot accept that the code would do anything remotely reasonable both before and after the change so while a bug report would have been a good idea my patch was overeager I'm afraid) and even though I'm pretty sure I was seeing this error already before the commit in question (unfortunately it seems I made the commit and the bug report the same day), I feel that I need to ask you to please make sure that the weird error you're seeing is in no way related to my commit (e.g. by reverting the commit in question at least locally and testing again). Sorry and thanks.
I can't find it in the code right now, but maybe UG does deliberately introduce element center vertices for tetrahedra under certain circumstances. I have a hard time believing that I really did find a bug in UG's refinement implementation for simplicial grids. I think I'll go back to Carsten's original testcase.
I did some more digging. In the file refine.cc there is the method RefineElementGreen which computes green closures. On line 4968 it says
#ifdef ModelP unsigned int maxid = 0; #else INT maxid = -1; #endif[snip] /* if (node0 == maxedge && ((SIDEPATTERN(theElement)&(1<<i)) == 0)) */ if (_ID_(theSideNodes[node0]) == maxid) {
Indeed, at the offending element, the sequential uggrid takes the 'if', but the parallel one takes the 'else', and that apparently leads to the observed symptoms.
Unfortunately, I have currently no idea what the code in [snip] does. It appears to be there for a reason. Simply removing the #ifdef ModelP doesn't help: it makes the code run into an assertion right away. And even if it did fix the issue I would not want to remove it without understanding what it does, for fear of regressions in parallel code.
Most likely I will not be able to spend more time on this in the nearer future. Feel free to pick it up from here if you are motivated.
I asked @peter about this, and he suggested that we should really run UGGrid with the TET_RULESET macro set. Doing so does indeed fix the problem. staging/dune-uggrid!75 (merged) introduces a CMake flag that lets the user set TET_RULESET. It seems to work okay, but I'd rather not enable it unconditionally without further tests. Also, it expects to read a list of refinement rules from a file, which is a bit inconvenient.
Not yet. I have added a build flag that allows to enable TET_RULE_SET which fixes the bug. In the long this should be the only way to use UGGrid, but getting there requires a bit of work. Leave it as it is for 2.6, and I'll prepare changelog / recent changes texts.