From 7f33a242908142a0068f404dfaff63b3cdd1f060 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 27 Aug 2024 21:15:05 -0600 Subject: [PATCH] Add another test. --- ...straints_make_consistent_in_parallel_05.cc | 60 +++++++++++++++++++ ..._consistent_in_parallel_05.mpirun=3.output | 16 +++++ ..._consistent_in_parallel_05.mpirun=5.output | 33 ++++++++++ ..._consistent_in_parallel_05.mpirun=7.output | 54 +++++++++++++++++ 4 files changed, 163 insertions(+) create mode 100644 tests/lac/constraints_make_consistent_in_parallel_05.cc create mode 100644 tests/lac/constraints_make_consistent_in_parallel_05.mpirun=3.output create mode 100644 tests/lac/constraints_make_consistent_in_parallel_05.mpirun=5.output create mode 100644 tests/lac/constraints_make_consistent_in_parallel_05.mpirun=7.output diff --git a/tests/lac/constraints_make_consistent_in_parallel_05.cc b/tests/lac/constraints_make_consistent_in_parallel_05.cc new file mode 100644 index 0000000000..aa5436041d --- /dev/null +++ b/tests/lac/constraints_make_consistent_in_parallel_05.cc @@ -0,0 +1,60 @@ +// ------------------------------------------------------------------------ +// +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (C) 2018 - 2023 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. +// +// ------------------------------------------------------------------------ + + + +// test AffineConstraints::make_consistent_in_parallel for a +// case where each process owns one DoF and on each process p>0 we +// know about one constraint that constrains X_p=0.5*X_{p-1}. After making +// things consistent in parallel, this needs to all reduce to X_p=factor*X1. + +#include + +#include + +#include "../tests.h" + +int +main(int argc, char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_init(argc, argv); + MPILogInitAll all; + + const unsigned int my_proc = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); + const unsigned int n_procs = Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD); + + const unsigned int n_indices = n_procs; + IndexSet owned_elements(n_indices); + owned_elements.add_index(my_proc); + IndexSet relevant_elements(n_indices); + relevant_elements.add_index(my_proc); + if (my_proc > 0) + relevant_elements.add_index(my_proc - 1); + AffineConstraints constraints(owned_elements, relevant_elements); + + if (my_proc > 0) + constraints.add_constraint(my_proc, {{my_proc - 1, 0.5}}); + + deallog << "Constraints as created:" << std::endl; + constraints.print(deallog.get_file_stream()); + + constraints.make_consistent_in_parallel(owned_elements, + relevant_elements, + MPI_COMM_WORLD); + + deallog << "Constraints as made consistent:" << std::endl; + constraints.print(deallog.get_file_stream()); + + return 0; +} diff --git a/tests/lac/constraints_make_consistent_in_parallel_05.mpirun=3.output b/tests/lac/constraints_make_consistent_in_parallel_05.mpirun=3.output new file mode 100644 index 0000000000..73133ffc37 --- /dev/null +++ b/tests/lac/constraints_make_consistent_in_parallel_05.mpirun=3.output @@ -0,0 +1,16 @@ + +DEAL:0::Constraints as created: +DEAL:0::Constraints as made consistent: + +DEAL:1::Constraints as created: + 1 0: 0.500000 +DEAL:1::Constraints as made consistent: + 1 0: 0.500000 + + +DEAL:2::Constraints as created: + 2 1: 0.500000 +DEAL:2::Constraints as made consistent: + 1 0: 0.500000 + 2 0: 0.250000 + diff --git a/tests/lac/constraints_make_consistent_in_parallel_05.mpirun=5.output b/tests/lac/constraints_make_consistent_in_parallel_05.mpirun=5.output new file mode 100644 index 0000000000..1abe499ae5 --- /dev/null +++ b/tests/lac/constraints_make_consistent_in_parallel_05.mpirun=5.output @@ -0,0 +1,33 @@ + +DEAL:0::Constraints as created: +DEAL:0::Constraints as made consistent: + +DEAL:1::Constraints as created: + 1 0: 0.500000 +DEAL:1::Constraints as made consistent: + 1 0: 0.500000 + + +DEAL:2::Constraints as created: + 2 1: 0.500000 +DEAL:2::Constraints as made consistent: + 1 0: 0.500000 + 2 0: 0.250000 + + +DEAL:3::Constraints as created: + 3 2: 0.500000 +DEAL:3::Constraints as made consistent: + 1 0: 0.500000 + 2 0: 0.250000 + 3 0: 0.125000 + + +DEAL:4::Constraints as created: + 4 3: 0.500000 +DEAL:4::Constraints as made consistent: + 1 0: 0.500000 + 2 0: 0.250000 + 3 0: 0.125000 + 4 0: 0.0625000 + diff --git a/tests/lac/constraints_make_consistent_in_parallel_05.mpirun=7.output b/tests/lac/constraints_make_consistent_in_parallel_05.mpirun=7.output new file mode 100644 index 0000000000..a7eabd69b5 --- /dev/null +++ b/tests/lac/constraints_make_consistent_in_parallel_05.mpirun=7.output @@ -0,0 +1,54 @@ + +DEAL:0::Constraints as created: +DEAL:0::Constraints as made consistent: + +DEAL:1::Constraints as created: + 1 0: 0.500000 +DEAL:1::Constraints as made consistent: + 1 0: 0.500000 + + +DEAL:2::Constraints as created: + 2 1: 0.500000 +DEAL:2::Constraints as made consistent: + 1 0: 0.500000 + 2 0: 0.250000 + + +DEAL:3::Constraints as created: + 3 2: 0.500000 +DEAL:3::Constraints as made consistent: + 1 0: 0.500000 + 2 0: 0.250000 + 3 0: 0.125000 + + +DEAL:4::Constraints as created: + 4 3: 0.500000 +DEAL:4::Constraints as made consistent: + 1 0: 0.500000 + 2 0: 0.250000 + 3 0: 0.125000 + 4 0: 0.0625000 + + +DEAL:5::Constraints as created: + 5 4: 0.500000 +DEAL:5::Constraints as made consistent: + 1 0: 0.500000 + 2 0: 0.250000 + 3 0: 0.125000 + 4 0: 0.0625000 + 5 0: 0.0312500 + + +DEAL:6::Constraints as created: + 6 5: 0.500000 +DEAL:6::Constraints as made consistent: + 1 0: 0.500000 + 2 0: 0.250000 + 3 0: 0.125000 + 4 0: 0.0625000 + 5 0: 0.0312500 + 6 0: 0.0156250 + -- 2.39.5