From 173d02582f7c003575feadbaba6f7ad42570e94f Mon Sep 17 00:00:00 2001 From: heister Date: Wed, 22 Aug 2012 19:42:45 +0000 Subject: [PATCH] add new test for trilinos git-svn-id: https://svn.dealii.org/trunk@26084 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/mpi/trilinos_02.cc | 95 +++++++++++++++++++++++ tests/mpi/trilinos_02/ncpu_10/cmp/generic | 3 + tests/mpi/trilinos_02/ncpu_4/cmp/generic | 3 + 3 files changed, 101 insertions(+) create mode 100644 tests/mpi/trilinos_02.cc create mode 100644 tests/mpi/trilinos_02/ncpu_10/cmp/generic create mode 100644 tests/mpi/trilinos_02/ncpu_4/cmp/generic diff --git a/tests/mpi/trilinos_02.cc b/tests/mpi/trilinos_02.cc new file mode 100644 index 0000000000..55b0679bfb --- /dev/null +++ b/tests/mpi/trilinos_02.cc @@ -0,0 +1,95 @@ +//---------------------------- trilinos_vector_equality_4.cc --------------------------- +// $Id: trilinos_ghost_01.cc 24924 2012-01-25 12:35:17Z kormann $ +// Version: $Name$ +// +// Copyright (C) 2004, 2005, 2008, 2010 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_equality_4.cc --------------------------- + + +// check Trilinos has_ghost_elements() + +#include "../tests.h" +#include +#include +#include +#include +#include +#include + +void check(TrilinosWrappers::MPI::Vector & v, bool ghost) +{ + Assert(v.has_ghost_elements()==ghost, ExcMessage("wrong ghost elements")); +} + +void test () +{ + unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); + unsigned int numproc = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD); + + if (myid==0) deallog << "numproc=" << numproc << std::endl; + + // each processor owns 2 indices and all + // are ghosting element 1 (the second) + IndexSet local_active(numproc*2); + local_active.add_range(myid*2,myid*2+2); + IndexSet local_relevant(numproc*2); + local_relevant = local_active; + local_relevant.add_range(1,2); + + TrilinosWrappers::MPI::Vector v(local_active, MPI_COMM_WORLD); + check(v, false); + + TrilinosWrappers::MPI::Vector v2(local_relevant, MPI_COMM_WORLD); + check(v2, true); + + TrilinosWrappers::MPI::Vector v3=v; + check(v3, false); + + v3.reinit(v2); + check(v3, true); + + v3.reinit(local_active); + check(v3, false); + + v3.reinit(local_relevant); + check(v3, true); + + TrilinosWrappers::MPI::Vector v4=v2; + check(v4, true); + + TrilinosWrappers::MPI::Vector v5(v2); + check(v5, true); + + if (myid==0) + deallog << "OK" << std::endl; +} + + + +int main (int argc, char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv); + + unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); + deallog.push(Utilities::int_to_string(myid)); + + if (myid == 0) + { + std::ofstream logfile(output_file_for_mpi("trilinos_02").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_02/ncpu_10/cmp/generic b/tests/mpi/trilinos_02/ncpu_10/cmp/generic new file mode 100644 index 0000000000..999baf1a98 --- /dev/null +++ b/tests/mpi/trilinos_02/ncpu_10/cmp/generic @@ -0,0 +1,3 @@ + +DEAL:0::numproc=10 +DEAL:0::OK diff --git a/tests/mpi/trilinos_02/ncpu_4/cmp/generic b/tests/mpi/trilinos_02/ncpu_4/cmp/generic new file mode 100644 index 0000000000..6f5d2775d9 --- /dev/null +++ b/tests/mpi/trilinos_02/ncpu_4/cmp/generic @@ -0,0 +1,3 @@ + +DEAL:0::numproc=4 +DEAL:0::OK -- 2.39.5