From 96a6e70eeee0fabdda127dfb76ab2bca46ada4b6 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Thu, 6 Jun 2024 11:28:48 +0200 Subject: [PATCH] merge_triangulations: Make sure to not copy any manifold ids --- source/grid/grid_generator.cc | 3 + tests/grid/merge_triangulations_08.cc | 111 ++++++++++++++++++++++ tests/grid/merge_triangulations_08.output | 49 ++++++++++ 3 files changed, 163 insertions(+) create mode 100644 tests/grid/merge_triangulations_08.cc create mode 100644 tests/grid/merge_triangulations_08.output diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index dbd0b28e4f..61eb2566dd 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -6639,6 +6639,9 @@ namespace GridGenerator result.clear(); result.create_triangulation(vertices, cells, subcell_data); + if (!copy_manifold_ids) + result.set_all_manifold_ids(numbers::flat_manifold_id); + if (copy_boundary_ids) { auto result_cell = result.begin(); diff --git a/tests/grid/merge_triangulations_08.cc b/tests/grid/merge_triangulations_08.cc new file mode 100644 index 0000000000..72b92e8f17 --- /dev/null +++ b/tests/grid/merge_triangulations_08.cc @@ -0,0 +1,111 @@ +// ------------------------------------------------------------------------ +// +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (C) 2024 by the deal.II authors +// +// This file is part of the deal.II library. +// +// Part of the source code is dual licensed under Apache-2.0 WITH +// LLVM-exception OR LGPL-2.1-or-later. Detailed license information +// governing the source code and code contributions can be found in +// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. +// +// ------------------------------------------------------------------------ + +// Check that GridGenerator::merge_triangulations does not apply any manifold +// unless it is told to do so. Test case adapted from merge_triangulations_03 + + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "../tests.h" + + +template +void +manifold_info(const Triangulation &tria, const std::string &case_name) +{ + deallog << "Manifold info for " << case_name << ':' << std::endl + << " dimension: " << dim << std::endl + << " no. of cells: " << tria.n_active_cells() << std::endl; + + deallog << "Cell manifolds: "; + for (const auto &cell : tria.active_cell_iterators()) + { + deallog << cell->manifold_id() << " "; + // also check that the manifold can be queried + (void)cell->get_manifold(); + } + deallog << std::endl; + + deallog << "Face manifolds: "; + for (const auto &cell : tria.active_cell_iterators()) + for (const auto face : cell->face_iterators()) + deallog << face->manifold_id() << " "; + deallog << std::endl << std::endl; +} + + +template +void +test() +{ + Point center; + + Triangulation ball; + Triangulation shell; + Triangulation tria_out; + + // create the two meshes + GridGenerator::hyper_ball(ball, center, 0.5); + GridGenerator::hyper_shell( + shell, + center, + 0.5, + 1, + 2 * dim, + true); // colorize flag set to true so outer bnd is 1 and inner is 0 + + // set boundaries + static const SphericalManifold boundary(center); + + ball.set_manifold(0, boundary); + shell.set_manifold(0, boundary); + shell.set_manifold(1, boundary); + + manifold_info(shell, "shell"); + manifold_info(ball, "ball"); + + GridGenerator::merge_triangulations(ball, shell, tria_out); + manifold_info(tria_out, "merged_without_manifold"); + + tria_out.clear(); + GridGenerator::merge_triangulations(ball, shell, tria_out, 1e-12, true); + for (const auto tria : {&ball, &shell}) + for (const auto &cell : tria->active_cell_iterators()) + if (cell->manifold_id() != numbers::flat_manifold_id) + tria_out.set_manifold(cell->manifold_id(), cell->get_manifold()); + manifold_info(tria_out, "merged_with_manifold"); +} + + +int +main() +{ + initlog(); + test<2>(); + test<3>(); + + return 0; +} diff --git a/tests/grid/merge_triangulations_08.output b/tests/grid/merge_triangulations_08.output new file mode 100644 index 0000000000..262bc4f63b --- /dev/null +++ b/tests/grid/merge_triangulations_08.output @@ -0,0 +1,49 @@ + +DEAL::Manifold info for shell: +DEAL:: dimension: 2 +DEAL:: no. of cells: 4 +DEAL::Cell manifolds: 0 0 0 0 +DEAL::Face manifolds: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +DEAL:: +DEAL::Manifold info for ball: +DEAL:: dimension: 2 +DEAL:: no. of cells: 5 +DEAL::Cell manifolds: 1 1 4294967295 1 1 +DEAL::Face manifolds: 4294967295 4294967295 0 4294967295 0 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 0 4294967295 0 4294967295 4294967295 4294967295 +DEAL:: +DEAL::Manifold info for merged_without_manifold: +DEAL:: dimension: 2 +DEAL:: no. of cells: 9 +DEAL::Cell manifolds: 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 +DEAL::Face manifolds: 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 +DEAL:: +DEAL::Manifold info for merged_with_manifold: +DEAL:: dimension: 2 +DEAL:: no. of cells: 9 +DEAL::Cell manifolds: 1 1 4294967295 1 1 0 0 0 0 +DEAL::Face manifolds: 4294967295 4294967295 0 4294967295 0 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 0 4294967295 0 4294967295 4294967295 4294967295 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +DEAL:: +DEAL::Manifold info for shell: +DEAL:: dimension: 3 +DEAL:: no. of cells: 6 +DEAL::Cell manifolds: 0 0 0 0 0 0 +DEAL::Face manifolds: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +DEAL:: +DEAL::Manifold info for ball: +DEAL:: dimension: 3 +DEAL:: no. of cells: 7 +DEAL::Cell manifolds: 4294967295 1 1 1 1 1 1 +DEAL::Face manifolds: 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 0 4294967295 4294967295 4294967295 0 4294967295 4294967295 4294967295 4294967295 4294967295 0 4294967295 4294967295 4294967295 0 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 0 4294967295 4294967295 4294967295 0 4294967295 4294967295 4294967295 4294967295 4294967295 +DEAL:: +DEAL::Manifold info for merged_without_manifold: +DEAL:: dimension: 3 +DEAL:: no. of cells: 13 +DEAL::Cell manifolds: 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 +DEAL::Face manifolds: 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 +DEAL:: +DEAL::Manifold info for merged_with_manifold: +DEAL:: dimension: 3 +DEAL:: no. of cells: 13 +DEAL::Cell manifolds: 4294967295 1 1 1 1 1 1 0 0 0 0 0 0 +DEAL::Face manifolds: 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 0 4294967295 4294967295 4294967295 0 4294967295 4294967295 4294967295 4294967295 4294967295 0 4294967295 4294967295 4294967295 0 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 0 4294967295 4294967295 4294967295 0 4294967295 4294967295 4294967295 4294967295 4294967295 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +DEAL:: -- 2.39.5