From 1ef9e9c406e532252b11dfbbf27debba11f22f63 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 19 Jul 2024 15:13:54 -0600 Subject: [PATCH] Add a test for shared::Triangulation. --- tests/sharedtria/boundary_dofs_01.cc | 100 ++++++++++++++++++ ...ry_dofs_01.with_metis=true.mpirun=1.output | 6 ++ ...ry_dofs_01.with_metis=true.mpirun=2.output | 13 +++ ...ry_dofs_01.with_metis=true.mpirun=4.output | 27 +++++ 4 files changed, 146 insertions(+) create mode 100644 tests/sharedtria/boundary_dofs_01.cc create mode 100644 tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=1.output create mode 100644 tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=2.output create mode 100644 tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=4.output diff --git a/tests/sharedtria/boundary_dofs_01.cc b/tests/sharedtria/boundary_dofs_01.cc new file mode 100644 index 0000000000..f800cc6ceb --- /dev/null +++ b/tests/sharedtria/boundary_dofs_01.cc @@ -0,0 +1,100 @@ +// ------------------------------------------------------------------------ +// +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (C) 2017 - 2022 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 DoFTools::extract_boundary_dofs() with shared triangulations. + +#include + +#include +#include + +#include + +#include + +#include "../tests.h" + + + +template +void +test() +{ + const MPI_Comm mpi_communicator = MPI_COMM_WORLD; + parallel::shared::Triangulation triangulation(mpi_communicator); + + GridGenerator::hyper_cube(triangulation, 0, 1); + triangulation.refine_global(4); + + FE_Q fe(1); + DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs(fe); + + deallog << "On process " << Utilities::MPI::this_mpi_process(mpi_communicator) + << std::endl; + deallog << " centers of locally owned cells="; + for (const auto &cell : triangulation.active_cell_iterators()) + if (cell->is_locally_owned()) + deallog << cell->center() << ' '; + deallog << "\n locally_owned_dofs="; + for (const auto i : dof_handler.locally_owned_dofs()) + deallog << i << ' '; + deallog << "\n boundary_dofs="; + for (const auto i : DoFTools::extract_boundary_dofs(dof_handler)) + deallog << i << ' '; + deallog << std::endl; + deallog << std::endl; +} + + +int +main(int argc, char **argv) +{ + try + { + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + + MPILogInitAll all; + + test<1>(); + } + catch (std::exception &exc) + { + std::cerr << std::endl + << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl + << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + } + + return 0; +} diff --git a/tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=1.output b/tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=1.output new file mode 100644 index 0000000000..4e1e9fbada --- /dev/null +++ b/tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=1.output @@ -0,0 +1,6 @@ + +DEAL:0::On process 0 +DEAL:0:: centers of locally owned cells=0.0312500 0.0937500 0.156250 0.218750 0.281250 0.343750 0.406250 0.468750 0.531250 0.593750 0.656250 0.718750 0.781250 0.843750 0.906250 0.968750 + locally_owned_dofs=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 + boundary_dofs=0 16 +DEAL:0:: diff --git a/tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=2.output b/tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=2.output new file mode 100644 index 0000000000..c058e7e95a --- /dev/null +++ b/tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=2.output @@ -0,0 +1,13 @@ + +DEAL:0::On process 0 +DEAL:0:: centers of locally owned cells=0.531250 0.593750 0.656250 0.718750 0.781250 0.843750 0.906250 0.968750 + locally_owned_dofs=0 1 2 3 4 5 6 7 8 + boundary_dofs=8 9 +DEAL:0:: + +DEAL:1::On process 1 +DEAL:1:: centers of locally owned cells=0.0312500 0.0937500 0.156250 0.218750 0.281250 0.343750 0.406250 0.468750 + locally_owned_dofs=9 10 11 12 13 14 15 16 + boundary_dofs=8 9 +DEAL:1:: + diff --git a/tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=4.output b/tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=4.output new file mode 100644 index 0000000000..8beb2620c7 --- /dev/null +++ b/tests/sharedtria/boundary_dofs_01.with_metis=true.mpirun=4.output @@ -0,0 +1,27 @@ + +DEAL:0::On process 0 +DEAL:0:: centers of locally owned cells=0.781250 0.843750 0.906250 0.968750 + locally_owned_dofs=0 1 2 3 4 + boundary_dofs=4 13 +DEAL:0:: + +DEAL:1::On process 1 +DEAL:1:: centers of locally owned cells=0.531250 0.593750 0.656250 0.718750 + locally_owned_dofs=5 6 7 8 + boundary_dofs=4 13 +DEAL:1:: + + +DEAL:2::On process 2 +DEAL:2:: centers of locally owned cells=0.281250 0.343750 0.406250 0.468750 + locally_owned_dofs=9 10 11 12 + boundary_dofs=4 13 +DEAL:2:: + + +DEAL:3::On process 3 +DEAL:3:: centers of locally owned cells=0.0312500 0.0937500 0.156250 0.218750 + locally_owned_dofs=13 14 15 16 + boundary_dofs=4 13 +DEAL:3:: + -- 2.39.5