From a7ce13cd166f54c27a00cf100b919d76bc35c172 Mon Sep 17 00:00:00 2001 From: heister Date: Thu, 6 Jun 2013 21:59:58 +0000 Subject: [PATCH] add failing test git-svn-id: https://svn.dealii.org/branches/branch_unify_linear_algebra@29791 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/gla/block_vec_02.cc | 105 ++++++++++++++++++++++ tests/gla/block_vec_02/ncpu_2/cmp/generic | 11 +++ tests/gla/block_vec_02/ncpu_4/cmp/generic | 31 +++++++ 3 files changed, 147 insertions(+) create mode 100644 tests/gla/block_vec_02.cc create mode 100644 tests/gla/block_vec_02/ncpu_2/cmp/generic create mode 100644 tests/gla/block_vec_02/ncpu_4/cmp/generic diff --git a/tests/gla/block_vec_02.cc b/tests/gla/block_vec_02.cc new file mode 100644 index 0000000000..f0940188e5 --- /dev/null +++ b/tests/gla/block_vec_02.cc @@ -0,0 +1,105 @@ +//--------------------------------------------------------------------------- +// $Id: ghost_01.cc 28440 2013-02-17 14:35:08Z heister $ +// Version: $Name$ +// +// Copyright (C) 2004, 2005, 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. +// +//--------------------------------------------------------------------------- + + +// block vectors: test ConstraintMatrix::distribute (fails currently) + +#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; + + IndexSet block1(10); + if (numproc==1) + block1.add_range(0,10); + + if (myid==0) + block1.add_range(0,7); + if (myid==1) + block1.add_range(7,10); + + IndexSet block2(6); + if (numproc==1) + block2.add_range(0,6); + + if (myid==0) + block2.add_range(0,2); + if (myid==1) + block2.add_range(2,6); + + std::vector partitioning; + partitioning.push_back(block1); + partitioning.push_back(block2); + + typename LA::MPI::BlockVector v(partitioning, MPI_COMM_WORLD); + v = 0.1; + + deallog << v.l2_norm() << std::endl; + + v(myid) = myid; + v.compress(VectorOperation::insert); + + deallog << "size: " << v.size() << std::endl; + deallog << "block(0).size: " << v.block(0).size() << std::endl; + deallog << "block(1).size: " << v.block(1).size() << std::endl; + if (block1.n_elements()>0) + deallog << "my first entry: " << v(block1.nth_index_in_set(0)) << std::endl; + + + ConstraintMatrix cm; + cm.add_line(1); + cm.add_entry(1 ,2, 3.0); + cm.close(); + + if (myid==0) + deallog << "before: " << v(1) << std::endl; + cm.distribute(v); // this should set x(1)= 3.0 * x(2) = 12.0 + if (myid==0) + deallog << "after: " << v(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(__FILE__); + { + deallog.push("PETSc"); + test(); + deallog.pop(); + deallog.push("Trilinos"); + test(); + deallog.pop(); + } + +} diff --git a/tests/gla/block_vec_02/ncpu_2/cmp/generic b/tests/gla/block_vec_02/ncpu_2/cmp/generic new file mode 100644 index 0000000000..eb8100b379 --- /dev/null +++ b/tests/gla/block_vec_02/ncpu_2/cmp/generic @@ -0,0 +1,11 @@ + +DEAL:0:PETSc::numproc=10 +DEAL:0:PETSc::0:0.000 +DEAL:0:PETSc::1:2.000 +DEAL:0:PETSc::ghost: 2.000 +DEAL:0:PETSc::OK +DEAL:0:Trilinos::numproc=10 +DEAL:0:Trilinos::0:0.000 +DEAL:0:Trilinos::1:2.000 +DEAL:0:Trilinos::ghost: 2.000 +DEAL:0:Trilinos::OK diff --git a/tests/gla/block_vec_02/ncpu_4/cmp/generic b/tests/gla/block_vec_02/ncpu_4/cmp/generic new file mode 100644 index 0000000000..17a7739b76 --- /dev/null +++ b/tests/gla/block_vec_02/ncpu_4/cmp/generic @@ -0,0 +1,31 @@ + +DEAL:0:PETSc::numproc=4 +DEAL:0:PETSc::0: 0.00000 +DEAL:0:PETSc::1: 2.00000 +DEAL:0:PETSc::before: 2.00000 +DEAL:0:PETSc::after: 12.0000 +DEAL:0:PETSc::OK +DEAL:0:Trilinos::numproc=4 +DEAL:0:Trilinos::0: 0.00000 +DEAL:0:Trilinos::1: 2.00000 +DEAL:0:Trilinos::before: 2.00000 +DEAL:0:Trilinos::after: 12.0000 +DEAL:0:Trilinos::OK + +DEAL:1:PETSc::2: 4.00000 +DEAL:1:PETSc::3: 6.00000 +DEAL:1:Trilinos::2: 4.00000 +DEAL:1:Trilinos::3: 6.00000 + + +DEAL:2:PETSc::4: 8.00000 +DEAL:2:PETSc::5: 10.0000 +DEAL:2:Trilinos::4: 8.00000 +DEAL:2:Trilinos::5: 10.0000 + + +DEAL:3:PETSc::6: 12.0000 +DEAL:3:PETSc::7: 14.0000 +DEAL:3:Trilinos::6: 12.0000 +DEAL:3:Trilinos::7: 14.0000 + -- 2.39.5