From: heister Date: Wed, 3 Aug 2011 03:36:32 +0000 (+0000) Subject: add test for a parallel trilinos bug when calling compress() X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa2c572c02b51a81cfcf9a3f797226fab94c1564;p=dealii-svn.git add test for a parallel trilinos bug when calling compress() git-svn-id: https://svn.dealii.org/trunk@24000 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/mpi/trilinos_compress_bug.cc b/tests/mpi/trilinos_compress_bug.cc new file mode 100644 index 0000000000..da708c5712 --- /dev/null +++ b/tests/mpi/trilinos_compress_bug.cc @@ -0,0 +1,104 @@ +//---------------------------- trilinos_vector_reinit.cc --------------------------- +// $Id: trilinos_vector_reinit.cc 23710 2011-05-17 04:50:10Z bangerth $ +// 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 --------------------------- + + +// document a bug in Trilinos regarding compress() + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include "../../deal.II/include/deal.II/base/index_set.h" +#include "../../deal.II/include/deal.II/lac/trilinos_vector.h" + + +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; + + IndexSet locally_owned(21); + if (myid==0) + locally_owned.add_range(0,9); + else + locally_owned.add_range(9,21); + + TrilinosWrappers::MPI::Vector test1(locally_owned); + if (myid==0) + { + unsigned int idx[]={0,1,2,3,4,5,6,7,8}; + double val[]={0,1,2,3,4,5,6,7,8}; + test1.add(9,idx,val); + } + else + { + { + unsigned int idx[]={1,9,3,10,5,11,12,13,14}; + double val[]={1,9,3,10,5,11,12,13,14}; + test1.add(9,idx,val); + } + } + + test1.compress(Add); + TrilinosWrappers::MPI::Vector test(locally_owned); + // TrilinosWrappers::MPI::Vector test(test1); + + test = 0; + + if (myid==0) + test(locally_owned.nth_index_in_set(5))=7; + + if (myid==0) + deallog << "before compress: " << test(locally_owned.nth_index_in_set(5)) << endl; + + test.compress(Insert); + if (myid==0) + deallog << "after compress: " << test(locally_owned.nth_index_in_set(5)) << endl; + + + // Trilinos produces a 0 instead of a 7 here. Why? + Assert(test(locally_owned.nth_index_in_set(5)) == 7, 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_compress_bug").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_compress_bug/ncpu_2/cmp/generic b/tests/mpi/trilinos_compress_bug/ncpu_2/cmp/generic new file mode 100644 index 0000000000..1cf39ab251 --- /dev/null +++ b/tests/mpi/trilinos_compress_bug/ncpu_2/cmp/generic @@ -0,0 +1,3 @@ + +DEAL:0::numproc=2 +DEAL:0::OK