From 5ae6fed11f113709cf46a6be878887e6895623de Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 27 Dec 2021 22:22:19 -0700 Subject: [PATCH] Add test. --- tests/grid/flatten_grid_03.cc | 92 ++++++++++++++ tests/grid/flatten_grid_03.output | 199 ++++++++++++++++++++++++++++++ 2 files changed, 291 insertions(+) create mode 100644 tests/grid/flatten_grid_03.cc create mode 100644 tests/grid/flatten_grid_03.output diff --git a/tests/grid/flatten_grid_03.cc b/tests/grid/flatten_grid_03.cc new file mode 100644 index 0000000000..d71fb09b5a --- /dev/null +++ b/tests/grid/flatten_grid_03.cc @@ -0,0 +1,92 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2004 - 2018 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + +// Generate a grid, refine it once, flatten it and output the result. +// +// This test checks that we are also copying the manifold +// ids of internal faces + +#include +#include +#include + +#include "../tests.h" + +template +void +test() +{ + deallog << dim << 'd' << std::endl; + + // Create a triangulation, then set the manifold ids of + // non-boundary faces and, in 3d, of non-boundary edges + Triangulation tria1; + GridGenerator::hyper_cube(tria1); + tria1.refine_global(1); + + for (const auto &cell : tria1.active_cell_iterators()) + for (const auto &face : cell->face_iterators()) + if (face->at_boundary() == false) + { + face->set_manifold_id(102); + + if (dim == 3) + for (unsigned int l = 0; l < face->n_lines(); ++l) + if (face->line(l)->at_boundary() == false) + { + face->line(l)->set_manifold_id(202); + } + } + + + // Then flatten the triangulation, and output the boundary and + // manifold ids of all objects on the boundary + Triangulation tria2; + GridGenerator::flatten_triangulation(tria1, tria2); + + for (const auto &cell : tria2.active_cell_iterators()) + for (const auto &face : cell->face_iterators()) + if (face->at_boundary() == false) + { + Assert(face->boundary_id() == numbers::internal_face_boundary_id, + ExcInternalError()); + deallog << "Face " << face << std::endl; + deallog << " center = " << face->center() << std::endl; + deallog << " manifold id = " << face->manifold_id() << std::endl; + + if (dim == 3) + for (unsigned int l = 0; l < face->n_lines(); ++l) + if (face->line(l)->at_boundary() == false) + { + Assert(face->line(l)->boundary_id() == + numbers::internal_face_boundary_id, + ExcInternalError()); + deallog << " Edge " << face->line(l) << std::endl; + deallog << " manifold id = " + << face->line(l)->manifold_id() << std::endl; + } + } + + deallog << std::endl << std::endl; +} + +int +main() +{ + initlog(); + + test<2>(); + test<3>(); +} diff --git a/tests/grid/flatten_grid_03.output b/tests/grid/flatten_grid_03.output new file mode 100644 index 0000000000..67ed1b5fb4 --- /dev/null +++ b/tests/grid/flatten_grid_03.output @@ -0,0 +1,199 @@ + +DEAL::2d +DEAL::Face 5 +DEAL:: center = 0.500000 0.250000 +DEAL:: manifold id = 102 +DEAL::Face 7 +DEAL:: center = 0.250000 0.500000 +DEAL:: manifold id = 102 +DEAL::Face 5 +DEAL:: center = 0.500000 0.250000 +DEAL:: manifold id = 102 +DEAL::Face 10 +DEAL:: center = 0.750000 0.500000 +DEAL:: manifold id = 102 +DEAL::Face 11 +DEAL:: center = 0.500000 0.750000 +DEAL:: manifold id = 102 +DEAL::Face 7 +DEAL:: center = 0.250000 0.500000 +DEAL:: manifold id = 102 +DEAL::Face 11 +DEAL:: center = 0.500000 0.750000 +DEAL:: manifold id = 102 +DEAL::Face 10 +DEAL:: center = 0.750000 0.500000 +DEAL:: manifold id = 102 +DEAL:: +DEAL:: +DEAL::3d +DEAL::Face 7 +DEAL:: center = 0.500000 0.250000 0.250000 +DEAL:: manifold id = 102 +DEAL:: Edge 41 +DEAL:: manifold id = 202 +DEAL:: Edge 38 +DEAL:: manifold id = 202 +DEAL::Face 10 +DEAL:: center = 0.250000 0.500000 0.250000 +DEAL:: manifold id = 102 +DEAL:: Edge 44 +DEAL:: manifold id = 202 +DEAL:: Edge 41 +DEAL:: manifold id = 202 +DEAL::Face 14 +DEAL:: center = 0.250000 0.250000 0.500000 +DEAL:: manifold id = 102 +DEAL:: Edge 38 +DEAL:: manifold id = 202 +DEAL:: Edge 44 +DEAL:: manifold id = 202 +DEAL::Face 7 +DEAL:: center = 0.500000 0.250000 0.250000 +DEAL:: manifold id = 102 +DEAL:: Edge 41 +DEAL:: manifold id = 202 +DEAL:: Edge 38 +DEAL:: manifold id = 202 +DEAL::Face 24 +DEAL:: center = 0.750000 0.500000 0.250000 +DEAL:: manifold id = 102 +DEAL:: Edge 51 +DEAL:: manifold id = 202 +DEAL:: Edge 41 +DEAL:: manifold id = 202 +DEAL::Face 23 +DEAL:: center = 0.750000 0.250000 0.500000 +DEAL:: manifold id = 102 +DEAL:: Edge 38 +DEAL:: manifold id = 202 +DEAL:: Edge 51 +DEAL:: manifold id = 202 +DEAL::Face 26 +DEAL:: center = 0.500000 0.750000 0.250000 +DEAL:: manifold id = 102 +DEAL:: Edge 41 +DEAL:: manifold id = 202 +DEAL:: Edge 52 +DEAL:: manifold id = 202 +DEAL::Face 10 +DEAL:: center = 0.250000 0.500000 0.250000 +DEAL:: manifold id = 102 +DEAL:: Edge 44 +DEAL:: manifold id = 202 +DEAL:: Edge 41 +DEAL:: manifold id = 202 +DEAL::Face 27 +DEAL:: center = 0.250000 0.750000 0.500000 +DEAL:: manifold id = 102 +DEAL:: Edge 52 +DEAL:: manifold id = 202 +DEAL:: Edge 44 +DEAL:: manifold id = 202 +DEAL::Face 26 +DEAL:: center = 0.500000 0.750000 0.250000 +DEAL:: manifold id = 102 +DEAL:: Edge 41 +DEAL:: manifold id = 202 +DEAL:: Edge 52 +DEAL:: manifold id = 202 +DEAL::Face 24 +DEAL:: center = 0.750000 0.500000 0.250000 +DEAL:: manifold id = 102 +DEAL:: Edge 51 +DEAL:: manifold id = 202 +DEAL:: Edge 41 +DEAL:: manifold id = 202 +DEAL::Face 34 +DEAL:: center = 0.750000 0.750000 0.500000 +DEAL:: manifold id = 102 +DEAL:: Edge 52 +DEAL:: manifold id = 202 +DEAL:: Edge 51 +DEAL:: manifold id = 202 +DEAL::Face 22 +DEAL:: center = 0.500000 0.250000 0.750000 +DEAL:: manifold id = 102 +DEAL:: Edge 53 +DEAL:: manifold id = 202 +DEAL:: Edge 38 +DEAL:: manifold id = 202 +DEAL::Face 29 +DEAL:: center = 0.250000 0.500000 0.750000 +DEAL:: manifold id = 102 +DEAL:: Edge 44 +DEAL:: manifold id = 202 +DEAL:: Edge 53 +DEAL:: manifold id = 202 +DEAL::Face 14 +DEAL:: center = 0.250000 0.250000 0.500000 +DEAL:: manifold id = 102 +DEAL:: Edge 38 +DEAL:: manifold id = 202 +DEAL:: Edge 44 +DEAL:: manifold id = 202 +DEAL::Face 22 +DEAL:: center = 0.500000 0.250000 0.750000 +DEAL:: manifold id = 102 +DEAL:: Edge 53 +DEAL:: manifold id = 202 +DEAL:: Edge 38 +DEAL:: manifold id = 202 +DEAL::Face 33 +DEAL:: center = 0.750000 0.500000 0.750000 +DEAL:: manifold id = 102 +DEAL:: Edge 51 +DEAL:: manifold id = 202 +DEAL:: Edge 53 +DEAL:: manifold id = 202 +DEAL::Face 23 +DEAL:: center = 0.750000 0.250000 0.500000 +DEAL:: manifold id = 102 +DEAL:: Edge 38 +DEAL:: manifold id = 202 +DEAL:: Edge 51 +DEAL:: manifold id = 202 +DEAL::Face 35 +DEAL:: center = 0.500000 0.750000 0.750000 +DEAL:: manifold id = 102 +DEAL:: Edge 53 +DEAL:: manifold id = 202 +DEAL:: Edge 52 +DEAL:: manifold id = 202 +DEAL::Face 29 +DEAL:: center = 0.250000 0.500000 0.750000 +DEAL:: manifold id = 102 +DEAL:: Edge 44 +DEAL:: manifold id = 202 +DEAL:: Edge 53 +DEAL:: manifold id = 202 +DEAL::Face 27 +DEAL:: center = 0.250000 0.750000 0.500000 +DEAL:: manifold id = 102 +DEAL:: Edge 52 +DEAL:: manifold id = 202 +DEAL:: Edge 44 +DEAL:: manifold id = 202 +DEAL::Face 35 +DEAL:: center = 0.500000 0.750000 0.750000 +DEAL:: manifold id = 102 +DEAL:: Edge 53 +DEAL:: manifold id = 202 +DEAL:: Edge 52 +DEAL:: manifold id = 202 +DEAL::Face 33 +DEAL:: center = 0.750000 0.500000 0.750000 +DEAL:: manifold id = 102 +DEAL:: Edge 51 +DEAL:: manifold id = 202 +DEAL:: Edge 53 +DEAL:: manifold id = 202 +DEAL::Face 34 +DEAL:: center = 0.750000 0.750000 0.500000 +DEAL:: manifold id = 102 +DEAL:: Edge 52 +DEAL:: manifold id = 202 +DEAL:: Edge 51 +DEAL:: manifold id = 202 +DEAL:: +DEAL:: -- 2.39.5