From: Timo Heister Date: Tue, 14 Oct 2014 19:53:10 +0000 (-0400) Subject: add failing test for ghosted vectors X-Git-Tag: v8.2.0-rc1~106^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4072d94883a66d3c460191ea297f55f8908049ac;p=dealii.git add failing test for ghosted vectors --- diff --git a/tests/gla/vec_07.cc b/tests/gla/vec_07.cc new file mode 100644 index 0000000000..4dfaccb11e --- /dev/null +++ b/tests/gla/vec_07.cc @@ -0,0 +1,88 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2004 - 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. +// +// --------------------------------------------------------------------- + + + +// test v=0 for ghost vectors + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +#include "gla.h" + +template +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.add_range(1,2); + + typename LA::MPI::Vector vb(local_active, MPI_COMM_WORLD); + typename LA::MPI::Vector v(local_active, local_relevant, MPI_COMM_WORLD); + + vb = 1.0; + + // set local values + vb(myid*2)=myid*2.0; + vb(myid*2+1)=myid*2.0+1.0; + + vb.compress(VectorOperation::insert); + vb*=2.0; + v=vb; + Assert(v.has_ghost_elements(), ExcInternalError()); + + deallog << "ghosted value: " << v(1) << " (should be 2.0)" << std::endl; + v=0; + deallog << "ghosted value: " << v(1) << " (should be 0.0)" << std::endl; + v=42.1; + deallog << "ghosted value: " << v(1) << " (should be 42.1)" << std::endl; + + // done + if (myid==0) + deallog << "OK" << std::endl; +} + + + +int main (int argc, char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll log; + { + deallog.push("PETSc"); + test(); + deallog.pop(); + deallog.push("Trilinos"); + test(); + deallog.pop(); + } + +} diff --git a/tests/gla/vec_07.mpirun=4.output b/tests/gla/vec_07.mpirun=4.output new file mode 100644 index 0000000000..01b78d053e --- /dev/null +++ b/tests/gla/vec_07.mpirun=4.output @@ -0,0 +1,35 @@ + +DEAL:0:PETSc::numproc=4 +DEAL:0:PETSc::ghosted value: 2.00000 (should be 2.0) +DEAL:0:PETSc::ghosted value: 0.00000 (should be 0.0) +DEAL:0:PETSc::ghosted value: 42.1000 (should be 42.1) +DEAL:0:PETSc::OK +DEAL:0:Trilinos::numproc=4 +DEAL:0:Trilinos::ghosted value: 2.00000 (should be 2.0) +DEAL:0:Trilinos::ghosted value: 0.00000 (should be 0.0) +DEAL:0:Trilinos::ghosted value: 42.1000 (should be 42.1) +DEAL:0:Trilinos::OK + +DEAL:1:PETSc::ghosted value: 2.00000 (should be 2.0) +DEAL:1:PETSc::ghosted value: 0.00000 (should be 0.0) +DEAL:1:PETSc::ghosted value: 42.1000 (should be 42.1) +DEAL:1:Trilinos::ghosted value: 2.00000 (should be 2.0) +DEAL:1:Trilinos::ghosted value: 0.00000 (should be 0.0) +DEAL:1:Trilinos::ghosted value: 42.1000 (should be 42.1) + + +DEAL:2:PETSc::ghosted value: 2.00000 (should be 2.0) +DEAL:2:PETSc::ghosted value: 0.00000 (should be 0.0) +DEAL:2:PETSc::ghosted value: 42.1000 (should be 42.1) +DEAL:2:Trilinos::ghosted value: 2.00000 (should be 2.0) +DEAL:2:Trilinos::ghosted value: 0.00000 (should be 0.0) +DEAL:2:Trilinos::ghosted value: 42.1000 (should be 42.1) + + +DEAL:3:PETSc::ghosted value: 2.00000 (should be 2.0) +DEAL:3:PETSc::ghosted value: 0.00000 (should be 0.0) +DEAL:3:PETSc::ghosted value: 42.1000 (should be 42.1) +DEAL:3:Trilinos::ghosted value: 2.00000 (should be 2.0) +DEAL:3:Trilinos::ghosted value: 0.00000 (should be 0.0) +DEAL:3:Trilinos::ghosted value: 42.1000 (should be 42.1) +