From 0096280440b5ec48af25f810d0c405a94aa4703f Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 3 Jul 2023 19:26:51 -0400 Subject: [PATCH] Mov reorder_old_to_new_style to tests/test_grids.h --- tests/bits/q_points.cc | 43 +----------------------------------- tests/grid/grid_invert.cc | 43 +----------------------------------- tests/grid/mesh_3d.h | 33 +--------------------------- tests/grid/subcelldata.cc | 46 +-------------------------------------- tests/lac/constraints.cc | 43 +----------------------------------- tests/test_grids.h | 29 ++++++++++++++++++++++++ 6 files changed, 34 insertions(+), 203 deletions(-) diff --git a/tests/bits/q_points.cc b/tests/bits/q_points.cc index 377856ea09..c4623fa595 100644 --- a/tests/bits/q_points.cc +++ b/tests/bits/q_points.cc @@ -36,48 +36,7 @@ #include "../tests.h" -namespace -{ - /** - * This file uses a different ordering for the vertices in a hex - * cell than we usually do in deal.II. The different convention used - * here originates in what we believed the ordering to be in UCD - * format, until it was discovered in 2022 that UCD will interpret - * this ordering to correspond to inverted cells -- as a - * consequence, the UCD ordering was fixed, but the current file is - * stuck on the old ordering. - */ - constexpr std::array local_vertex_numbering{ - {0, 1, 5, 4, 2, 3, 7, 6}}; - - /** - * Following is a set of functions that reorder the data from the - * "current" to the "classic" format of vertex numbering of cells - * and faces. These functions do the reordering of their arguments - * in-place. - */ - void - reorder_old_to_new_style(std::vector> &cells) - { - for (auto &cell : cells) - std::swap(cell.vertices[2], cell.vertices[3]); - } - - - void - reorder_old_to_new_style(std::vector> &cells) - { - // undo the ordering above - unsigned int tmp[GeometryInfo<3>::vertices_per_cell]; - for (auto &cell : cells) - { - for (const unsigned int i : GeometryInfo<3>::vertex_indices()) - tmp[i] = cell.vertices[i]; - for (const unsigned int i : GeometryInfo<3>::vertex_indices()) - cell.vertices[local_vertex_numbering[i]] = tmp[i]; - } - } -} // namespace +#include "../tests/test_grids.h" void create_two_cubes(Triangulation<3> &coarse_grid) diff --git a/tests/grid/grid_invert.cc b/tests/grid/grid_invert.cc index d55dfb56d4..1e3876a2f2 100644 --- a/tests/grid/grid_invert.cc +++ b/tests/grid/grid_invert.cc @@ -24,48 +24,7 @@ #include "../tests.h" -namespace -{ - /** - * This file uses a different ordering for the vertices in a hex - * cell than we usually do in deal.II. The different convention used - * here originates in what we believed the ordering to be in UCD - * format, until it was discovered in 2022 that UCD will interpret - * this ordering to correspond to inverted cells -- as a - * consequence, the UCD ordering was fixed, but the current file is - * stuck on the old ordering. - */ - constexpr std::array local_vertex_numbering{ - {0, 1, 5, 4, 2, 3, 7, 6}}; - - /** - * Following is a set of functions that reorder the data from the - * "current" to the "classic" format of vertex numbering of cells - * and faces. These functions do the reordering of their arguments - * in-place. - */ - void - reorder_old_to_new_style(std::vector> &cells) - { - for (auto &cell : cells) - std::swap(cell.vertices[2], cell.vertices[3]); - } - - - void - reorder_old_to_new_style(std::vector> &cells) - { - // undo the ordering above - unsigned int tmp[GeometryInfo<3>::vertices_per_cell]; - for (auto &cell : cells) - { - for (const unsigned int i : GeometryInfo<3>::vertex_indices()) - tmp[i] = cell.vertices[i]; - for (const unsigned int i : GeometryInfo<3>::vertex_indices()) - cell.vertices[local_vertex_numbering[i]] = tmp[i]; - } - } -} // namespace +#include "../tests/test_grids.h" template void diff --git a/tests/grid/mesh_3d.h b/tests/grid/mesh_3d.h index f4564b3c8a..513eb8a10c 100644 --- a/tests/grid/mesh_3d.h +++ b/tests/grid/mesh_3d.h @@ -20,44 +20,13 @@ #include "../tests.h" +#include "../tests/test_grids.h" // generate two cubes that are attached to each other in a way so that // the edges are all ok, but the normals of the common face don't // match up for the standard orientation of the normals. we thus have // to store the face orientation in each cell -namespace -{ - /** - * This file uses a different ordering for the vertices in a hex - * cell than we usually do in deal.II. The different convention used - * here originates in what we believed the ordering to be in UCD - * format, until it was discovered in 2022 that UCD will interpret - * this ordering to correspond to inverted cells -- as a - * consequence, the UCD ordering was fixed, but the current file is - * stuck on the old ordering. - */ - constexpr std::array local_vertex_numbering{ - {0, 1, 5, 4, 2, 3, 7, 6}}; - - /** - * And now also in the opposite direction. - */ - void - reorder_old_to_new_style(std::vector> &cells) - { - // undo the ordering above - unsigned int tmp[GeometryInfo<3>::vertices_per_cell]; - for (auto &cell : cells) - { - for (const unsigned int i : GeometryInfo<3>::vertex_indices()) - tmp[i] = cell.vertices[i]; - for (const unsigned int i : GeometryInfo<3>::vertex_indices()) - cell.vertices[local_vertex_numbering[i]] = tmp[i]; - } - } -} // namespace - void create_two_cubes(Triangulation<3> &coarse_grid) { diff --git a/tests/grid/subcelldata.cc b/tests/grid/subcelldata.cc index cc26ed861e..adbc0936dd 100644 --- a/tests/grid/subcelldata.cc +++ b/tests/grid/subcelldata.cc @@ -22,51 +22,7 @@ #include "../tests.h" - -namespace -{ - /** - * This file uses a different ordering for the vertices in a hex - * cell than we usually do in deal.II. The different convention used - * here originates in what we believed the ordering to be in UCD - * format, until it was discovered in 2022 that UCD will interpret - * this ordering to correspond to inverted cells -- as a - * consequence, the UCD ordering was fixed, but the current file is - * stuck on the old ordering. - */ - constexpr std::array local_vertex_numbering{ - {0, 1, 5, 4, 2, 3, 7, 6}}; - - /** - * And now also in the opposite direction. - */ - void - reorder_old_to_new_style(std::vector> &cells) - { - // undo the ordering above - unsigned int tmp[GeometryInfo<3>::vertices_per_cell]; - for (auto &cell : cells) - { - for (const unsigned int i : GeometryInfo<3>::vertex_indices()) - tmp[i] = cell.vertices[i]; - for (const unsigned int i : GeometryInfo<3>::vertex_indices()) - cell.vertices[local_vertex_numbering[i]] = tmp[i]; - } - } - - /** - * Following is a set of functions that reorder the data from the - * "current" to the "classic" format of vertex numbering of cells - * and faces. These functions do the reordering of their arguments - * in-place. - */ - void - reorder_old_to_new_style(std::vector> &cells) - { - for (auto &cell : cells) - std::swap(cell.vertices[2], cell.vertices[3]); - } -} // namespace +#include "../tests/test_grids.h" static unsigned subcells[6][4] = {{0, 1, 2, 3}, diff --git a/tests/lac/constraints.cc b/tests/lac/constraints.cc index c9324b5b20..8caeab4995 100644 --- a/tests/lac/constraints.cc +++ b/tests/lac/constraints.cc @@ -36,49 +36,8 @@ #include "../tests.h" +#include "../tests/test_grids.h" -namespace -{ - /** - * This file uses a different ordering for the vertices in a hex - * cell than we usually do in deal.II. The different convention used - * here originates in what we believed the ordering to be in UCD - * format, until it was discovered in 2022 that UCD will interpret - * this ordering to correspond to inverted cells -- as a - * consequence, the UCD ordering was fixed, but the current file is - * stuck on the old ordering. - */ - constexpr std::array local_vertex_numbering{ - {0, 1, 5, 4, 2, 3, 7, 6}}; - - /** - * Following is a set of functions that reorder the data from the - * "current" to the "classic" format of vertex numbering of cells - * and faces. These functions do the reordering of their arguments - * in-place. - */ - void - reorder_old_to_new_style(std::vector> &cells) - { - for (auto &cell : cells) - std::swap(cell.vertices[2], cell.vertices[3]); - } - - - void - reorder_old_to_new_style(std::vector> &cells) - { - // undo the ordering above - unsigned int tmp[GeometryInfo<3>::vertices_per_cell]; - for (auto &cell : cells) - { - for (const unsigned int i : GeometryInfo<3>::vertex_indices()) - tmp[i] = cell.vertices[i]; - for (const unsigned int i : GeometryInfo<3>::vertex_indices()) - cell.vertices[local_vertex_numbering[i]] = tmp[i]; - } - } -} // namespace void diff --git a/tests/test_grids.h b/tests/test_grids.h index dea33ba257..ed560bf00c 100644 --- a/tests/test_grids.h +++ b/tests/test_grids.h @@ -157,4 +157,33 @@ namespace TestGrids GridGenerator::subdivided_hyper_rectangle(tr, repetitions, p1, p2); Assert(tr.n_global_active_cells() == n_cells, ExcInternalError()); } + + /** + * In the past, we used a different ordering for the vertices in a hex + * cell than we do now. We provide a conversion function to facilitate + * updating tests that are using the old ordering. + */ + constexpr std::array local_vertex_numbering{ + {0, 1, 5, 4, 2, 3, 7, 6}}; + + inline void + reorder_old_to_new_style(std::vector> &cells) + { + // undo the ordering above + unsigned int tmp[GeometryInfo<3>::vertices_per_cell]; + for (auto &cell : cells) + { + for (const unsigned int i : GeometryInfo<3>::vertex_indices()) + tmp[i] = cell.vertices[i]; + for (const unsigned int i : GeometryInfo<3>::vertex_indices()) + cell.vertices[local_vertex_numbering[i]] = tmp[i]; + } + } + + inline void + reorder_old_to_new_style(std::vector> &cells) + { + for (auto &cell : cells) + std::swap(cell.vertices[2], cell.vertices[3]); + } } // namespace TestGrids -- 2.39.5