From 751e99bf8b87b046bf066b50016265380f199ef1 Mon Sep 17 00:00:00 2001 From: David Wells Date: Thu, 15 Apr 2021 09:12:54 -0400 Subject: [PATCH] Get rid of create_triangulation_compatibility in the XDA reader. --- source/grid/grid_in.cc | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/source/grid/grid_in.cc b/source/grid/grid_in.cc index 8ac1ef56b1..56f2ef865f 100644 --- a/source/grid/grid_in.cc +++ b/source/grid/grid_in.cc @@ -1381,6 +1381,8 @@ GridIn<2>::read_xda(std::istream &in) Assert(tria != nullptr, ExcNoTriangulationSelected()); AssertThrow(in, ExcIO()); + const auto reference_cell = ReferenceCells::get_hypercube<2>(); + std::string line; // skip comments at start of file getline(in, line); @@ -1412,10 +1414,11 @@ GridIn<2>::read_xda(std::istream &in) // should still be input here, // so check this: AssertThrow(in, ExcIO()); - Assert(GeometryInfo<2>::vertices_per_cell == 4, ExcInternalError()); - for (unsigned int &vertex : cells[cell].vertices) - in >> vertex; + // XDA happens to use ExodusII's numbering because XDA/XDR is libMesh's + // native format, and libMesh's node numberings come from ExodusII: + for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; i++) + in >> cells[cell].vertices[reference_cell.exodusii_vertex_to_deal_vertex(i)]; } @@ -1438,9 +1441,9 @@ GridIn<2>::read_xda(std::istream &in) // do some clean-up on vertices... GridTools::delete_unused_vertices(vertices, cells, subcelldata); // ... and cells - GridReordering<2>::invert_all_cells_of_negative_grid(vertices, cells); - GridReordering<2>::reorder_cells(cells); - tria->create_triangulation_compatibility(vertices, cells, subcelldata); + GridReordering<2>::invert_all_cells_of_negative_grid(vertices, cells, true); + GridReordering<2>::reorder_cells(cells, true); + tria->create_triangulation(vertices, cells, subcelldata); } @@ -1452,13 +1455,12 @@ GridIn<3>::read_xda(std::istream &in) Assert(tria != nullptr, ExcNoTriangulationSelected()); AssertThrow(in, ExcIO()); - static const unsigned int xda_to_dealII_map[] = {0, 1, 5, 4, 3, 2, 6, 7}; + const auto reference_cell = ReferenceCells::get_hypercube<3>(); std::string line; // skip comments at start of file getline(in, line); - unsigned int n_vertices; unsigned int n_cells; @@ -1485,19 +1487,13 @@ GridIn<3>::read_xda(std::istream &in) // should still be input here, // so check this: AssertThrow(in, ExcIO()); - Assert(GeometryInfo<3>::vertices_per_cell == 8, ExcInternalError()); - - unsigned int xda_ordered_nodes[8]; - for (unsigned int &xda_ordered_node : xda_ordered_nodes) - in >> xda_ordered_node; - - for (unsigned int i = 0; i < 8; i++) - cells[cell].vertices[i] = xda_ordered_nodes[xda_to_dealII_map[i]]; + // XDA happens to use ExodusII's numbering because XDA/XDR is libMesh's + // native format, and libMesh's node numberings come from ExodusII: + for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; i++) + in >> cells[cell].vertices[reference_cell.exodusii_vertex_to_deal_vertex(i)]; } - - // set up array of vertices std::vector> vertices(n_vertices); for (unsigned int vertex = 0; vertex < n_vertices; ++vertex) @@ -1516,9 +1512,9 @@ GridIn<3>::read_xda(std::istream &in) // do some clean-up on vertices... GridTools::delete_unused_vertices(vertices, cells, subcelldata); // ... and cells - GridReordering<3>::invert_all_cells_of_negative_grid(vertices, cells); - GridReordering<3>::reorder_cells(cells); - tria->create_triangulation_compatibility(vertices, cells, subcelldata); + GridReordering<3>::invert_all_cells_of_negative_grid(vertices, cells, true); + GridReordering<3>::reorder_cells(cells, true); + tria->create_triangulation(vertices, cells, subcelldata); } -- 2.39.5