From: Wolfgang Bangerth Date: Sat, 8 Jul 2023 22:50:44 +0000 (-0600) Subject: Make sure we always generate consistently oriented meshes. X-Git-Tag: relicensing~714^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef62064a16a69e7e566207fa1f68e8d292663fc4;p=dealii.git Make sure we always generate consistently oriented meshes. --- diff --git a/examples/step-14/step-14.cc b/examples/step-14/step-14.cc index c717830bec..5df33680d3 100644 --- a/examples/step-14/step-14.cc +++ b/examples/step-14/step-14.cc @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -1293,10 +1294,23 @@ namespace Step14 } // Finally pass all this information to the library to generate a - // triangulation. The last parameter may be used to pass information - // about non-zero boundary indicators at certain faces of the - // triangulation to the library, but we don't want that here, so we give - // an empty object: + // triangulation. The right call for this is + // Triangulation::create_triangulation(), but that function wants + // its input in a format in which cells are consistently oriented + // in some way. It turns out that the mesh we describe with the + // `vertices` and `cells` objects above already is consistently + // oriented, but if you modify the code in some way it may not + // be any more, and so it is good practice to call a function + // that ensures it is -- GridTools::consistently_order_cells() + // does this. + // + // The last parameter of the call to Triangulation::create_triangulation() + // below describes what we want to do about boundary and manifold + // indicators on boundary faces. Here, we don't want to do anything + // specific (in particular, we are fine with labeling all boundaries + // with boundary indicator zero, and so we call the function with + // an empty object as the last argument: + GridTools::consistently_order_cells(cells); coarse_grid.create_triangulation(vertices, cells, SubCellData()); // And since we want that the evaluation point (3/4,3/4) in this example diff --git a/examples/step-19/step-19.cc b/examples/step-19/step-19.cc index 8e6f034e42..3a5e062e13 100644 --- a/examples/step-19/step-19.cc +++ b/examples/step-19/step-19.cc @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -291,7 +292,10 @@ namespace Step19 // // This information is then handed to the // Triangulation::create_triangulation() function, and the mesh is twice - // globally refined. + // globally refined. As discussed in the corresponding place in step-14, + // the inputs to Triangulation::create_triangulation() need to be + // consistently oriented, which a function in namespace GridTools + // does for us. std::vector> cells((nx - 1) * (ny - 1), CellData()); for (unsigned int i = 0; i < cells.size(); ++i) { @@ -299,6 +303,7 @@ namespace Step19 cells[i].material_id = 0; } + GridTools::consistently_order_cells(cells); triangulation.create_triangulation( vertices, cells, diff --git a/examples/step-49/doc/results.dox b/examples/step-49/doc/results.dox index e14b2c5dae..2bf4594659 100644 --- a/examples/step-49/doc/results.dox +++ b/examples/step-49/doc/results.dox @@ -80,7 +80,7 @@ the techniques previously described: @code // Given a list of points and how vertices connect to cells, create a -// mesh. This is in the same way as we do in step 14. +// mesh. This is in the same way as we do in step-14. void create_2d_grid( const std::vector> &vertices, const std::vector< @@ -95,6 +95,7 @@ void create_2d_grid( cells[i].vertices[j] = vertex_indices[i][j]; } + GridTools::consistently_order_cells(cells); coarse_grid.create_triangulation(vertices, cells, SubCellData()); }