From af010371696b4f8cc40493dc89de48d27e2fd988 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Thu, 5 Feb 2015 11:58:50 +0100 Subject: [PATCH] Add test for sadd with partly empty Trilinos vectors --- tests/mpi/trilinos_sadd_03.cc | 163 +++++++++++++++++ ...sadd_03.with_trilinos=true.mpirun=3.output | 169 ++++++++++++++++++ 2 files changed, 332 insertions(+) create mode 100644 tests/mpi/trilinos_sadd_03.cc create mode 100644 tests/mpi/trilinos_sadd_03.with_trilinos=true.mpirun=3.output diff --git a/tests/mpi/trilinos_sadd_03.cc b/tests/mpi/trilinos_sadd_03.cc new file mode 100644 index 0000000000..f1387f9b0a --- /dev/null +++ b/tests/mpi/trilinos_sadd_03.cc @@ -0,0 +1,163 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2011 - 2013 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 at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// check correct behaviour of sadd of Trilinos vectors +// if there are processes that doesn't own anything + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +void test () +{ + TrilinosWrappers::MPI::Vector ghosted, ghosted2, distributed, distributed2; + const unsigned int my_id = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); + const unsigned int n_proc = Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD); + //All processes except for the last one own elements + const int entries_per_process = (my_id==n_proc-1)?0:10; + IndexSet locally_owned(entries_per_process*(n_proc-1)); + IndexSet locally_relevant(entries_per_process*(n_proc-1)); + const int begin_index = my_id*entries_per_process; + const unsigned int end_index = (my_id+1)*entries_per_process; + const unsigned int local_begin = std::max(0, begin_index-entries_per_process/2); + const unsigned int local_end = entries_per_process*(n_proc-1); + + if (my_id != n_proc-1) + { + locally_owned.add_range(begin_index, end_index); + locally_relevant.add_range(local_begin, local_end); + } + + distributed.reinit(locally_owned, MPI_COMM_WORLD); + distributed2.reinit(locally_owned, MPI_COMM_WORLD); + ghosted.reinit (locally_owned, locally_relevant, MPI_COMM_WORLD); + ghosted2.reinit (locally_owned, locally_relevant, MPI_COMM_WORLD); + + //sadd(s,v) with ghosted vector + distributed=1.; + ghosted=distributed; + ghosted *= 1.6; + distributed.sadd (2., ghosted); + ghosted = distributed; + deallog << "sadd (s, v) ghosted" <