From 4e77a29555e6bb3e80c0d71b92040e44699269cf Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Fri, 22 Sep 2023 16:35:16 -0400 Subject: [PATCH] add test --- ...ix_crash_01.cc => constraints_crash_01.cc} | 0 ...t => constraints_crash_01.mpirun=1.output} | 0 tests/mpi/constraints_crash_02.cc | 72 +++++++++++++++++++ .../mpi/constraints_crash_02.mpirun=2.output | 5 ++ 4 files changed, 77 insertions(+) rename tests/mpi/{constraint_matrix_crash_01.cc => constraints_crash_01.cc} (100%) rename tests/mpi/{constraint_matrix_crash_01.mpirun=1.output => constraints_crash_01.mpirun=1.output} (100%) create mode 100644 tests/mpi/constraints_crash_02.cc create mode 100644 tests/mpi/constraints_crash_02.mpirun=2.output diff --git a/tests/mpi/constraint_matrix_crash_01.cc b/tests/mpi/constraints_crash_01.cc similarity index 100% rename from tests/mpi/constraint_matrix_crash_01.cc rename to tests/mpi/constraints_crash_01.cc diff --git a/tests/mpi/constraint_matrix_crash_01.mpirun=1.output b/tests/mpi/constraints_crash_01.mpirun=1.output similarity index 100% rename from tests/mpi/constraint_matrix_crash_01.mpirun=1.output rename to tests/mpi/constraints_crash_01.mpirun=1.output diff --git a/tests/mpi/constraints_crash_02.cc b/tests/mpi/constraints_crash_02.cc new file mode 100644 index 0000000000..69be471812 --- /dev/null +++ b/tests/mpi/constraints_crash_02.cc @@ -0,0 +1,72 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2013 - 2018 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. +// +// --------------------------------------------------------------------- + + + +// AffineConstraints::distribute() crashes because copy_from() is +// incomplete: + +/** +An error occurred in line <2679> of file + in function + void dealii::AffineConstraints::distribute(VectorType&) const [with +VectorType = dealii::LinearAlgebra::distributed::Vector; number = +double] The violated condition was: needed_elements_for_distribute != IndexSet() +*/ + +#include + +#include +#include + +#include "../tests.h" + + + +void +test() +{ + unsigned int myid = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); + unsigned int numproc = Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD); + + IndexSet owned(numproc); + owned.add_range(myid, myid + 1); + IndexSet relevant = complete_index_set(numproc); + + + AffineConstraints cm(owned, relevant); + cm.add_line(0); + cm.close(); + + AffineConstraints cm2; + cm2.copy_from(cm); + + LinearAlgebra::distributed::Vector x(owned, relevant, MPI_COMM_WORLD); + + cm.distribute(x); // this works + cm2.distribute(x); // this used to fail + deallog << "OK" << std::endl; +} + + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll log; + + test(); + return 0; +} diff --git a/tests/mpi/constraints_crash_02.mpirun=2.output b/tests/mpi/constraints_crash_02.mpirun=2.output new file mode 100644 index 0000000000..52103938b0 --- /dev/null +++ b/tests/mpi/constraints_crash_02.mpirun=2.output @@ -0,0 +1,5 @@ + +DEAL:0::OK + +DEAL:1::OK + -- 2.39.5