#include <deal.II/lac/affine_constraints.h>
#include <deal.II/grid/tria.h>
#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_tools.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/grid_refinement.h>
#include <deal.II/dofs/dof_handler.h>
}
// 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
#include <deal.II/grid/tria.h>
#include <deal.II/grid/grid_refinement.h>
+#include <deal.II/grid/grid_tools.h>
#include <deal.II/fe/mapping_q.h>
#include <deal.II/matrix_free/fe_point_evaluation.h>
//
// 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<CellData<dim>> cells((nx - 1) * (ny - 1), CellData<dim>());
for (unsigned int i = 0; i < cells.size(); ++i)
{
cells[i].material_id = 0;
}
+ GridTools::consistently_order_cells(cells);
triangulation.create_triangulation(
vertices,
cells,
@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<Point<2>> &vertices,
const std::vector<
cells[i].vertices[j] = vertex_indices[i][j];
}
+ GridTools::consistently_order_cells(cells);
coarse_grid.create_triangulation(vertices, cells, SubCellData());
}