From eb627d8b0077b6ac1aa54bcc1e790aed179465bd Mon Sep 17 00:00:00 2001 From: Sebastian Proell Date: Thu, 12 May 2022 10:44:41 +0200 Subject: [PATCH] New test for MatrixFree::reinit with empty procs --- tests/matrix_free/fe_nothing_01.cc | 91 +++++++++++++++++++ ...nothing_01.with_p4est=true.mpirun=3.output | 41 +++++++++ 2 files changed, 132 insertions(+) create mode 100644 tests/matrix_free/fe_nothing_01.cc create mode 100644 tests/matrix_free/fe_nothing_01.with_p4est=true.mpirun=3.output diff --git a/tests/matrix_free/fe_nothing_01.cc b/tests/matrix_free/fe_nothing_01.cc new file mode 100644 index 0000000000..c821d858ec --- /dev/null +++ b/tests/matrix_free/fe_nothing_01.cc @@ -0,0 +1,91 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2022 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. +// +// --------------------------------------------------------------------- + + + +// test MatrixFree::reinit when some procs have only FE_Nothing and thus zero +// dofs + +#include +#include + +#include + +#include + +#include "../tests.h" + + +template +void +test() +{ + parallel::distributed::Triangulation tria(MPI_COMM_WORLD); + GridGenerator::subdivided_hyper_cube(tria, 2); + + DoFHandler dof(tria); + { + std::vector active_indices(tria.n_active_cells()); + for (unsigned i = 0; i < tria.n_active_cells() / 2; ++i) + active_indices[i] = 1; + dof.set_active_fe_indices(active_indices); + + hp::FECollection fe{FE_Q(fe_degree), FE_Nothing(1)}; + dof.distribute_dofs(fe); + } + + AffineConstraints constraints; + constraints.close(); + + deallog << "Testing reinit for FE_Nothing + " << dof.get_fe().get_name() + << std::endl; + deallog << "# local dofs: " << dof.n_locally_owned_dofs() << std::endl; + + using number = double; + MatrixFree mf_data; + { + const QGauss<1> quad(fe_degree + 1); + typename MatrixFree::AdditionalData data; + data.tasks_parallel_scheme = MatrixFree::AdditionalData::none; + data.mapping_update_flags = + (dealii::update_values | dealii::update_gradients | + dealii::update_JxW_values | dealii::update_quadrature_points); + mf_data.reinit(MappingQ(fe_degree), + dof, + constraints, + hp::QCollection(quad, quad), + data); + } +} + +int +main(int argc, char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi(argc, argv, 1); + MPILogInitAll log; + + { + deallog.push("2d"); + test<2, 1>(); + test<2, 2>(); + test<2, 3>(); + test<2, 4>(); + deallog.pop(); + deallog.push("3d"); + test<3, 1>(); + test<3, 2>(); + deallog.pop(); + } +} diff --git a/tests/matrix_free/fe_nothing_01.with_p4est=true.mpirun=3.output b/tests/matrix_free/fe_nothing_01.with_p4est=true.mpirun=3.output new file mode 100644 index 0000000000..734ed4f564 --- /dev/null +++ b/tests/matrix_free/fe_nothing_01.with_p4est=true.mpirun=3.output @@ -0,0 +1,41 @@ + +DEAL:0:2d::Testing reinit for FE_Nothing + FE_Q<2>(1) +DEAL:0:2d::# local dofs: 0 +DEAL:0:2d::Testing reinit for FE_Nothing + FE_Q<2>(2) +DEAL:0:2d::# local dofs: 0 +DEAL:0:2d::Testing reinit for FE_Nothing + FE_Q<2>(3) +DEAL:0:2d::# local dofs: 0 +DEAL:0:2d::Testing reinit for FE_Nothing + FE_Q<2>(4) +DEAL:0:2d::# local dofs: 0 +DEAL:0:3d::Testing reinit for FE_Nothing + FE_Q<3>(1) +DEAL:0:3d::# local dofs: 0 +DEAL:0:3d::Testing reinit for FE_Nothing + FE_Q<3>(2) +DEAL:0:3d::# local dofs: 0 + +DEAL:1:2d::Testing reinit for FE_Nothing + FE_Q<2>(1) +DEAL:1:2d::# local dofs: 0 +DEAL:1:2d::Testing reinit for FE_Nothing + FE_Q<2>(2) +DEAL:1:2d::# local dofs: 0 +DEAL:1:2d::Testing reinit for FE_Nothing + FE_Q<2>(3) +DEAL:1:2d::# local dofs: 0 +DEAL:1:2d::Testing reinit for FE_Nothing + FE_Q<2>(4) +DEAL:1:2d::# local dofs: 0 +DEAL:1:3d::Testing reinit for FE_Nothing + FE_Q<3>(1) +DEAL:1:3d::# local dofs: 8 +DEAL:1:3d::Testing reinit for FE_Nothing + FE_Q<3>(2) +DEAL:1:3d::# local dofs: 27 + + +DEAL:2:2d::Testing reinit for FE_Nothing + FE_Q<2>(1) +DEAL:2:2d::# local dofs: 6 +DEAL:2:2d::Testing reinit for FE_Nothing + FE_Q<2>(2) +DEAL:2:2d::# local dofs: 15 +DEAL:2:2d::Testing reinit for FE_Nothing + FE_Q<2>(3) +DEAL:2:2d::# local dofs: 28 +DEAL:2:2d::Testing reinit for FE_Nothing + FE_Q<2>(4) +DEAL:2:2d::# local dofs: 45 +DEAL:2:3d::Testing reinit for FE_Nothing + FE_Q<3>(1) +DEAL:2:3d::# local dofs: 10 +DEAL:2:3d::Testing reinit for FE_Nothing + FE_Q<3>(2) +DEAL:2:3d::# local dofs: 48 + -- 2.39.5