From 66ffe677c949916ed379aa640019f5602ecbe9ae Mon Sep 17 00:00:00 2001 From: bangerth Date: Wed, 5 Mar 2014 01:52:29 +0000 Subject: [PATCH] Add new but failing test. git-svn-id: https://svn.dealii.org/trunk@32611 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/mpi/trilinos_sadd_01.cc | 106 +++++++++++++++++++++ tests/mpi/trilinos_sadd_01.mpirun=2.output | 33 +++++++ 2 files changed, 139 insertions(+) create mode 100644 tests/mpi/trilinos_sadd_01.cc create mode 100644 tests/mpi/trilinos_sadd_01.mpirun=2.output diff --git a/tests/mpi/trilinos_sadd_01.cc b/tests/mpi/trilinos_sadd_01.cc new file mode 100644 index 0000000000..61b4cd46fa --- /dev/null +++ b/tests/mpi/trilinos_sadd_01.cc @@ -0,0 +1,106 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2014 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 behavior of sadd of Trilinos vectors +// if they have different Epetra maps + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +void test () +{ + const int n_proc = Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD); + const int my_id = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); + + //All processes should own 10 entries + const int entries_per_process = 10; + + IndexSet locally_owned(entries_per_process*n_proc); + const int begin_index = my_id*entries_per_process; + const int end_index = (my_id+1)*entries_per_process; + locally_owned.add_range(begin_index, end_index); + + IndexSet locally_relevant(entries_per_process*n_proc); + const int local_begin = std::max(0, begin_index-entries_per_process/2); + const int local_end = entries_per_process*n_proc; + locally_relevant.add_range (local_begin, local_end); + + TrilinosWrappers::MPI::Vector ghosted, distributed; + distributed.reinit(locally_owned, MPI_COMM_WORLD); + ghosted.reinit (locally_owned, locally_relevant, MPI_COMM_WORLD); + + // set the 'distributed' vector to all ones and store its results in + // 'ghosted' + distributed=1.; + ghosted=distributed; + + // then multiply 'distributed' by two and add 'ghosted' to it again + distributed*=2; + distributed.add(ghosted, true); + + // assign the result, which should contain all 3s to 'ghosted' + ghosted = distributed; + + if (my_id==0) + { + deallog << "Distributed:" << std::endl; + for (unsigned int i=begin_index; i