From 85af51007f6a5746edc8237696ba23d2e9381631 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Wed, 3 Feb 2021 15:30:18 +0100 Subject: [PATCH] Make sure we return all manifold ids. --- doc/news/changes/minor/20210203LucaHeltai | 3 + source/grid/tria.cc | 13 +- tests/manifold/manifold_id_08.cc | 75 +++++++++ tests/manifold/manifold_id_08.output | 176 ++++++++++++++++++++++ 4 files changed, 260 insertions(+), 7 deletions(-) create mode 100644 doc/news/changes/minor/20210203LucaHeltai create mode 100644 tests/manifold/manifold_id_08.cc create mode 100644 tests/manifold/manifold_id_08.output diff --git a/doc/news/changes/minor/20210203LucaHeltai b/doc/news/changes/minor/20210203LucaHeltai new file mode 100644 index 0000000000..d6bd20481f --- /dev/null +++ b/doc/news/changes/minor/20210203LucaHeltai @@ -0,0 +1,3 @@ +Fixed: Triangulation::get_manifold_ids() was not returning all ids correctly. +
+(Luca Heltai, 2021/02/03) diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 955b9131ab..5981f8d29c 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -10379,14 +10379,13 @@ Triangulation::get_manifold_ids() const if (cell->is_locally_owned()) { m_ids.insert(cell->manifold_id()); - if (dim > 1) - for (const unsigned int face : GeometryInfo::face_indices()) - if (cell->at_boundary(face)) - m_ids.insert(cell->face(face)->manifold_id()); + for (const auto &face : cell->face_iterators()) + m_ids.insert(face->manifold_id()); + if (dim == 3) + for (const unsigned int l : cell->line_indices()) + m_ids.insert(cell->line(l)->manifold_id()); } - std::vector manifold_indicators(m_ids.begin(), - m_ids.end()); - return manifold_indicators; + return {m_ids.begin(), m_ids.end()}; } /*-----------------------------------------------------------------*/ diff --git a/tests/manifold/manifold_id_08.cc b/tests/manifold/manifold_id_08.cc new file mode 100644 index 0000000000..6b300feebc --- /dev/null +++ b/tests/manifold/manifold_id_08.cc @@ -0,0 +1,75 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2021 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. +// +// --------------------------------------------------------------------- + +// Make sure that Triangulation::get_manifold_ids() work correctly + +#include +#include + +#include "../tests.h" + +template +void +test(unsigned int ref = 1) +{ + deallog << "Testing dim=" << dim << ", spacedim=" << spacedim << std::endl; + + Triangulation tria; + GridGenerator::hyper_cube(tria); + + typename Triangulation::active_cell_iterator cell; + + tria.begin_active()->set_manifold_id(1); + for (const unsigned int f : tria.begin_active()->face_indices()) + tria.begin_active()->face(f)->set_manifold_id(2); + + tria.begin_active()->line(0)->set_manifold_id(3); + + tria.refine_global(ref); + + for (cell = tria.begin_active(); cell != tria.end(); ++cell) + { + deallog << "C: " << cell << ", manifold_id: " << (int)cell->manifold_id() + << std::endl; + for (const unsigned int f : cell->face_indices()) + deallog << "f: " << cell->face(f) + << ", manifold_id: " << (int)cell->face(f)->manifold_id() + << std::endl; + if (dim == 3) + for (const unsigned int l : cell->line_indices()) + deallog << "line: " << cell->line(l) + << ", manifold_id: " << (int)cell->line(l)->manifold_id() + << std::endl; + } + + const auto manifold_ids = tria.get_manifold_ids(); + deallog << "All manifold ids: "; + std::string sep = ""; + for (const auto &mid : manifold_ids) + { + deallog << sep << (int)mid; + sep = ", "; + } + deallog << std::endl; +} + +int +main() +{ + initlog(); + + test<3, 3>(0); + test<3, 3>(1); +} diff --git a/tests/manifold/manifold_id_08.output b/tests/manifold/manifold_id_08.output new file mode 100644 index 0000000000..20248ecac6 --- /dev/null +++ b/tests/manifold/manifold_id_08.output @@ -0,0 +1,176 @@ + +DEAL::Testing dim=3, spacedim=3 +DEAL::C: 0.0, manifold_id: 1 +DEAL::f: 2, manifold_id: 2 +DEAL::f: 3, manifold_id: 2 +DEAL::f: 0, manifold_id: 2 +DEAL::f: 4, manifold_id: 2 +DEAL::f: 1, manifold_id: 2 +DEAL::f: 5, manifold_id: 2 +DEAL::line: 1, manifold_id: 3 +DEAL::line: 3, manifold_id: -1 +DEAL::line: 0, manifold_id: -1 +DEAL::line: 5, manifold_id: -1 +DEAL::line: 9, manifold_id: -1 +DEAL::line: 10, manifold_id: -1 +DEAL::line: 8, manifold_id: -1 +DEAL::line: 11, manifold_id: -1 +DEAL::line: 2, manifold_id: -1 +DEAL::line: 4, manifold_id: -1 +DEAL::line: 6, manifold_id: -1 +DEAL::line: 7, manifold_id: -1 +DEAL::All manifold ids: 1, 2, 3, -1 +DEAL::Testing dim=3, spacedim=3 +DEAL::C: 1.0, manifold_id: 1 +DEAL::f: 14, manifold_id: 2 +DEAL::f: 41, manifold_id: 1 +DEAL::f: 6, manifold_id: 2 +DEAL::f: 37, manifold_id: 1 +DEAL::f: 10, manifold_id: 2 +DEAL::f: 33, manifold_id: 1 +DEAL::line: 14, manifold_id: 3 +DEAL::line: 40, manifold_id: 2 +DEAL::line: 12, manifold_id: -1 +DEAL::line: 42, manifold_id: 2 +DEAL::line: 46, manifold_id: 2 +DEAL::line: 65, manifold_id: 1 +DEAL::line: 36, manifold_id: 2 +DEAL::line: 63, manifold_id: 1 +DEAL::line: 16, manifold_id: -1 +DEAL::line: 38, manifold_id: 2 +DEAL::line: 44, manifold_id: 2 +DEAL::line: 61, manifold_id: 1 +DEAL::C: 1.1, manifold_id: 1 +DEAL::f: 41, manifold_id: 1 +DEAL::f: 18, manifold_id: 2 +DEAL::f: 8, manifold_id: 2 +DEAL::f: 35, manifold_id: 1 +DEAL::f: 11, manifold_id: 2 +DEAL::f: 32, manifold_id: 1 +DEAL::line: 40, manifold_id: 2 +DEAL::line: 18, manifold_id: -1 +DEAL::line: 13, manifold_id: -1 +DEAL::line: 43, manifold_id: 2 +DEAL::line: 65, manifold_id: 1 +DEAL::line: 50, manifold_id: 2 +DEAL::line: 37, manifold_id: 2 +DEAL::line: 62, manifold_id: 1 +DEAL::line: 38, manifold_id: 2 +DEAL::line: 20, manifold_id: -1 +DEAL::line: 61, manifold_id: 1 +DEAL::line: 48, manifold_id: 2 +DEAL::C: 1.2, manifold_id: 1 +DEAL::f: 15, manifold_id: 2 +DEAL::f: 40, manifold_id: 1 +DEAL::f: 37, manifold_id: 1 +DEAL::f: 22, manifold_id: 2 +DEAL::f: 12, manifold_id: 2 +DEAL::f: 31, manifold_id: 1 +DEAL::line: 15, manifold_id: 3 +DEAL::line: 41, manifold_id: 2 +DEAL::line: 42, manifold_id: 2 +DEAL::line: 22, manifold_id: -1 +DEAL::line: 47, manifold_id: 2 +DEAL::line: 64, manifold_id: 1 +DEAL::line: 63, manifold_id: 1 +DEAL::line: 52, manifold_id: 2 +DEAL::line: 44, manifold_id: 2 +DEAL::line: 61, manifold_id: 1 +DEAL::line: 24, manifold_id: -1 +DEAL::line: 54, manifold_id: 2 +DEAL::C: 1.3, manifold_id: 1 +DEAL::f: 40, manifold_id: 1 +DEAL::f: 19, manifold_id: 2 +DEAL::f: 35, manifold_id: 1 +DEAL::f: 24, manifold_id: 2 +DEAL::f: 13, manifold_id: 2 +DEAL::f: 30, manifold_id: 1 +DEAL::line: 41, manifold_id: 2 +DEAL::line: 19, manifold_id: -1 +DEAL::line: 43, manifold_id: 2 +DEAL::line: 23, manifold_id: -1 +DEAL::line: 64, manifold_id: 1 +DEAL::line: 51, manifold_id: 2 +DEAL::line: 62, manifold_id: 1 +DEAL::line: 53, manifold_id: 2 +DEAL::line: 61, manifold_id: 1 +DEAL::line: 48, manifold_id: 2 +DEAL::line: 54, manifold_id: 2 +DEAL::line: 26, manifold_id: -1 +DEAL::C: 1.4, manifold_id: 1 +DEAL::f: 16, manifold_id: 2 +DEAL::f: 39, manifold_id: 1 +DEAL::f: 7, manifold_id: 2 +DEAL::f: 36, manifold_id: 1 +DEAL::f: 33, manifold_id: 1 +DEAL::f: 26, manifold_id: 2 +DEAL::line: 46, manifold_id: 2 +DEAL::line: 65, manifold_id: 1 +DEAL::line: 36, manifold_id: 2 +DEAL::line: 63, manifold_id: 1 +DEAL::line: 30, manifold_id: -1 +DEAL::line: 56, manifold_id: 2 +DEAL::line: 28, manifold_id: -1 +DEAL::line: 58, manifold_id: 2 +DEAL::line: 17, manifold_id: -1 +DEAL::line: 39, manifold_id: 2 +DEAL::line: 45, manifold_id: 2 +DEAL::line: 60, manifold_id: 1 +DEAL::C: 1.5, manifold_id: 1 +DEAL::f: 39, manifold_id: 1 +DEAL::f: 20, manifold_id: 2 +DEAL::f: 9, manifold_id: 2 +DEAL::f: 34, manifold_id: 1 +DEAL::f: 32, manifold_id: 1 +DEAL::f: 27, manifold_id: 2 +DEAL::line: 65, manifold_id: 1 +DEAL::line: 50, manifold_id: 2 +DEAL::line: 37, manifold_id: 2 +DEAL::line: 62, manifold_id: 1 +DEAL::line: 56, manifold_id: 2 +DEAL::line: 32, manifold_id: -1 +DEAL::line: 29, manifold_id: -1 +DEAL::line: 59, manifold_id: 2 +DEAL::line: 39, manifold_id: 2 +DEAL::line: 21, manifold_id: -1 +DEAL::line: 60, manifold_id: 1 +DEAL::line: 49, manifold_id: 2 +DEAL::C: 1.6, manifold_id: 1 +DEAL::f: 17, manifold_id: 2 +DEAL::f: 38, manifold_id: 1 +DEAL::f: 36, manifold_id: 1 +DEAL::f: 23, manifold_id: 2 +DEAL::f: 31, manifold_id: 1 +DEAL::f: 28, manifold_id: 2 +DEAL::line: 47, manifold_id: 2 +DEAL::line: 64, manifold_id: 1 +DEAL::line: 63, manifold_id: 1 +DEAL::line: 52, manifold_id: 2 +DEAL::line: 31, manifold_id: -1 +DEAL::line: 57, manifold_id: 2 +DEAL::line: 58, manifold_id: 2 +DEAL::line: 34, manifold_id: -1 +DEAL::line: 45, manifold_id: 2 +DEAL::line: 60, manifold_id: 1 +DEAL::line: 25, manifold_id: -1 +DEAL::line: 55, manifold_id: 2 +DEAL::C: 1.7, manifold_id: 1 +DEAL::f: 38, manifold_id: 1 +DEAL::f: 21, manifold_id: 2 +DEAL::f: 34, manifold_id: 1 +DEAL::f: 25, manifold_id: 2 +DEAL::f: 30, manifold_id: 1 +DEAL::f: 29, manifold_id: 2 +DEAL::line: 64, manifold_id: 1 +DEAL::line: 51, manifold_id: 2 +DEAL::line: 62, manifold_id: 1 +DEAL::line: 53, manifold_id: 2 +DEAL::line: 57, manifold_id: 2 +DEAL::line: 33, manifold_id: -1 +DEAL::line: 59, manifold_id: 2 +DEAL::line: 35, manifold_id: -1 +DEAL::line: 60, manifold_id: 1 +DEAL::line: 49, manifold_id: 2 +DEAL::line: 55, manifold_id: 2 +DEAL::line: 27, manifold_id: -1 +DEAL::All manifold ids: 1, 2, 3, -1 -- 2.39.5