Bug in init() of default halfedge implementation
Something is going wrong with the init()
function.
The cause is most likely located in reorient()
.
Simple example
Halfedge grid created from simple grid
using WorldVector = Dune::FieldVector<float_type, dow>;
WorldVector x0 = { 0.0, 0.0, 0.0 };
WorldVector x1 = { 1.0, 0.0, 0.0 };
WorldVector x2 = { 0.0, 1.0, 0.0 };
WorldVector x3 = { 0.0, 0.0, 1.0 };
std::vector<std::vector<index_type>> cells = { {0, 1, 2}
, {0, 3, 1}
, {1, 3, 2}
// , {0, 2, 3} }; // same orientation
, {0, 3, 2} }; // different orientation
std::vector<WorldVector> coords = { x0, x1, x2, x3 };
GridBase base_grid {cells, coords};
Grid grid {base_grid};
The grid grid
has correct incidences of edges to vertices/faces and of faces to vertices/edges.
However, the incidences of vertices to edges and faces are wrong:
Query incidences of vertices
for (auto const& vertex : vertices(grid.gridView())) {
msg_("vertex[", vertex.index(), "]:");
msg_("\nvertices: ");
for (auto const& v : vertices(vertex))
msg_(v.index(), " ");
msg_("\nedges: ");
for (auto const& e : edges(vertex))
msg_(e.index(), " ");
msg_("\nfaces: ");
for (auto const& f : faces(vertex))
msg_(f.index(), " ");
msg();
}
Output
vertex[0]:
vertices: 0
edges: 1 3 4 5 1 2 4 0
faces: 3 1 2 3 0 2 1 0
vertex[1]:
vertices: 1
edges: 2 4 0 1 3 4 5 1
faces: 2 1 0 3 1 2 3 0
vertex[2]:
vertices: 2
edges: 5 1 2 4 0 1 3 4
faces: 3 0 2 1 0 3 1 2
vertex[3]:
vertices: 3
edges: 3 5 2 0
faces: 3 2 0 1