From 1754441a2692b75cc2d697e92dac11d844dc0866 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Wed, 30 Mar 2011 14:32:01 +0000 Subject: [PATCH] Test vector reinitialization. git-svn-id: https://svn.dealii.org/trunk@23547 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/mpi/trilinos_vector_reinit.cc | 79 +++++++++++++++++++ .../trilinos_vector_reinit/ncpu_2/cmp/generic | 3 + 2 files changed, 82 insertions(+) create mode 100644 tests/mpi/trilinos_vector_reinit.cc create mode 100644 tests/mpi/trilinos_vector_reinit/ncpu_2/cmp/generic diff --git a/tests/mpi/trilinos_vector_reinit.cc b/tests/mpi/trilinos_vector_reinit.cc new file mode 100644 index 0000000000..7258afc133 --- /dev/null +++ b/tests/mpi/trilinos_vector_reinit.cc @@ -0,0 +1,79 @@ +//---------------------------- trilinos_vector_reinit.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2011 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//---------------------------- trilinos_vector_reinit.cc --------------------------- + + +// check correct behaviour of reinit of Trilinos vectors + +#include "../tests.h" +#include +#include +#include +#include +#include +#include + + +void test () +{ + unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD); + unsigned int numproc = Utilities::System::get_n_mpi_processes (MPI_COMM_WORLD); + + if (myid==0) deallog << "numproc=" << numproc << std::endl; + + + TrilinosWrappers::MPI::Vector test1, test2; + + Assert (test1.vector_partitioner().SameAs(test2.vector_partitioner()), + ExcInternalError()); + + // first processor owns 2 indices, second + // processor owns none + IndexSet local_owned(2); + if (myid == 0) + local_owned.add_range (0,2); + + test1.reinit (local_owned, MPI_COMM_WORLD); + + // reinit Trilinos vector from other vector + test2.reinit (test1, true); + + Assert (test1.vector_partitioner().SameAs(test2.vector_partitioner()), + ExcInternalError()); + + if (Utilities::System::get_this_mpi_process (MPI_COMM_WORLD) == 0) + deallog << "OK" << std::endl; +} + + + +int main (int argc, char **argv) +{ + Utilities::System::MPI_InitFinalize mpi_initialization(argc, argv); + + unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD); + deallog.push(Utilities::int_to_string(myid)); + + if (myid == 0) + { + std::ofstream logfile(output_file_for_mpi("trilinos_vector_reinit").c_str()); + deallog.attach(logfile); + deallog << std::setprecision(4); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test(); + } + else + test(); + +} diff --git a/tests/mpi/trilinos_vector_reinit/ncpu_2/cmp/generic b/tests/mpi/trilinos_vector_reinit/ncpu_2/cmp/generic new file mode 100644 index 0000000000..1cf39ab251 --- /dev/null +++ b/tests/mpi/trilinos_vector_reinit/ncpu_2/cmp/generic @@ -0,0 +1,3 @@ + +DEAL:0::numproc=2 +DEAL:0::OK -- 2.39.5