From 9ac9ee7f0a71f8c0fa6f51913573adf401316885 Mon Sep 17 00:00:00 2001 From: David Wells Date: Tue, 13 Apr 2021 23:39:29 -0400 Subject: [PATCH] Get rid of create_triangulation_compatibility in the UCD reader. To keep reading input consistently this also requires that we slightly modify the cell inversion algorithm. This is backwards-compatible since the option to use the new style ordering was added in 7f9c1023b61. --- source/grid/grid_in.cc | 16 ++++++++-------- source/grid/grid_reordering.cc | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/source/grid/grid_in.cc b/source/grid/grid_in.cc index 66cbae62dd..8eae912d79 100644 --- a/source/grid/grid_in.cc +++ b/source/grid/grid_in.cc @@ -946,7 +946,7 @@ GridIn::read_ucd(std::istream &in, // allocate and read indices cells.emplace_back(); for (const unsigned int i : GeometryInfo::vertex_indices()) - in >> cells.back().vertices[i]; + in >> cells.back().vertices[GeometryInfo::ucd_to_deal[i]]; // to make sure that the cast won't fail Assert(material_id <= std::numeric_limits::max(), @@ -1033,10 +1033,9 @@ GridIn::read_ucd(std::istream &in, // boundary info { subcelldata.boundary_quads.emplace_back(); - in >> subcelldata.boundary_quads.back().vertices[0] >> - subcelldata.boundary_quads.back().vertices[1] >> - subcelldata.boundary_quads.back().vertices[2] >> - subcelldata.boundary_quads.back().vertices[3]; + for (const unsigned int i : GeometryInfo<2>::vertex_indices()) + in >> subcelldata.boundary_quads.back() + .vertices[GeometryInfo<2>::ucd_to_deal[i]]; // to make sure that the cast won't fail Assert(material_id <= std::numeric_limits::max(), @@ -1096,9 +1095,10 @@ GridIn::read_ucd(std::istream &in, // ... and cells if (dim == spacedim) GridReordering::invert_all_cells_of_negative_grid(vertices, - cells); - GridReordering::reorder_cells(cells); - tria->create_triangulation_compatibility(vertices, cells, subcelldata); + cells, + true); + GridReordering::reorder_cells(cells, true); + tria->create_triangulation(vertices, cells, subcelldata); } namespace diff --git a/source/grid/grid_reordering.cc b/source/grid/grid_reordering.cc index 5a034b1d1f..90f93551c6 100644 --- a/source/grid/grid_reordering.cc +++ b/source/grid/grid_reordering.cc @@ -1260,8 +1260,18 @@ GridReordering<3>::invert_all_cells_of_negative_grid( { ++n_negative_cells; // reorder vertices: swap front and back face - for (unsigned int i = 0; i < 4; ++i) - std::swap(cell.vertices[i], cell.vertices[i + 4]); + if (use_new_style_ordering) + { + std::swap(cell.vertices[0], cell.vertices[2]); + std::swap(cell.vertices[1], cell.vertices[3]); + std::swap(cell.vertices[4], cell.vertices[6]); + std::swap(cell.vertices[5], cell.vertices[7]); + } + else + { + for (unsigned int i = 0; i < 4; ++i) + std::swap(cell.vertices[i], cell.vertices[i + 4]); + } copy_vertices_to_temp(cell); // Check whether the resulting cell is now ok. -- 2.39.5