From 7baadcf5c9e82cb88f5a1637fd4f41e04742f4d9 Mon Sep 17 00:00:00 2001 From: Johannes Heinz Date: Sat, 9 Dec 2023 09:34:40 +0100 Subject: [PATCH] Add test to check MatrixFree::reinit() works for multiple ranks and threads --- .../reinit_matrix_free_threading.cc | 81 +++++++++++++++++++ ..._threading.with_p4est=true.mpirun=2.output | 16 ++++ 2 files changed, 97 insertions(+) create mode 100644 tests/matrix_free/reinit_matrix_free_threading.cc create mode 100644 tests/matrix_free/reinit_matrix_free_threading.with_p4est=true.mpirun=2.output diff --git a/tests/matrix_free/reinit_matrix_free_threading.cc b/tests/matrix_free/reinit_matrix_free_threading.cc new file mode 100644 index 0000000000..89b422578f --- /dev/null +++ b/tests/matrix_free/reinit_matrix_free_threading.cc @@ -0,0 +1,81 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2023 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. +// +// --------------------------------------------------------------------- + +// Verify that MatrixFree::reinit() works without errors if run with +// multithreadingf and multiple ranks. + + +#include + +#include +#include + +#include + +#include + +#include + +#include + +#include "../tests.h" + +using namespace dealii; + +template +void +do_test(const unsigned int degree, const unsigned int n_refinements) +{ + deallog << "Create Triangulation with " << n_refinements << " refinements..." + << std::endl; + parallel::distributed::Triangulation tria(MPI_COMM_WORLD); + GridGenerator::hyper_cube(tria); + tria.refine_global(n_refinements); + + + deallog << "Create DoFHandler..." << std::endl; + DoFHandler dof_handler(tria); + dof_handler.distribute_dofs(FE_DGQ(degree)); + + deallog << "Setup AffineConstraints..." << std::endl; + AffineConstraints constraints; + constraints.close(); + + deallog << "Set MatrixFree AdditionalData..." << std::endl; + typename MatrixFree::AdditionalData data; + data.mapping_update_flags_inner_faces = update_values; + + deallog << "Reinit MatrixFree..." << std::endl; + MatrixFree matrix_free; + matrix_free.reinit( + MappingQ1(), dof_handler, constraints, QGauss(degree + 1), data); + + deallog << "OK" << std::endl << std::endl; +} + + + +int +main(int argc, char **argv) +{ + // Init with threading enabled + Utilities::MPI::MPI_InitFinalize mpi_init(argc, argv); + mpi_initlog(); + + do_test<2, double>(3, 3); + do_test<3, double>(2, 2); + + deallog << std::endl; +} diff --git a/tests/matrix_free/reinit_matrix_free_threading.with_p4est=true.mpirun=2.output b/tests/matrix_free/reinit_matrix_free_threading.with_p4est=true.mpirun=2.output new file mode 100644 index 0000000000..9865db4f48 --- /dev/null +++ b/tests/matrix_free/reinit_matrix_free_threading.with_p4est=true.mpirun=2.output @@ -0,0 +1,16 @@ + +DEAL::Create Triangulation with 3 refinements... +DEAL::Create DoFHandler... +DEAL::Setup AffineConstraints... +DEAL::Set MatrixFree AdditionalData... +DEAL::Reinit MatrixFree... +DEAL::OK +DEAL:: +DEAL::Create Triangulation with 2 refinements... +DEAL::Create DoFHandler... +DEAL::Setup AffineConstraints... +DEAL::Set MatrixFree AdditionalData... +DEAL::Reinit MatrixFree... +DEAL::OK +DEAL:: +DEAL:: -- 2.39.5