From: heister Date: Tue, 19 Feb 2013 23:02:36 +0000 (+0000) Subject: add test X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73112342ebfd9695ca1d4f34c45824cfc5a697bf;p=dealii-svn.git add test git-svn-id: https://svn.dealii.org/trunk@28485 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/mpi/blockvec_01.cc b/tests/mpi/blockvec_01.cc new file mode 100644 index 0000000000..9e24142129 --- /dev/null +++ b/tests/mpi/blockvec_01.cc @@ -0,0 +1,123 @@ +//--------------------------------------------------------------------------- +// $Id: ghost_01.cc 28403 2013-02-15 05:23:40Z 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. +// +//--------------------------------------------------------------------------- + + +// Test constructor/reinit of BlockVector with IndexSets + +#include "../tests.h" +#include "coarse_grid_common.h" +#include +#include +#include +#include +#include +#include +#include + + +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; + + std::vector local_active(2); + + // block 0: + local_active[0].set_size(numproc); + local_active[0].add_range(myid,myid+1); + + local_active[1].set_size(2*numproc); + local_active[1].add_range(myid*2,myid*2+2); + + BLOCKVEC v(local_active, MPI_COMM_WORLD); + + v(myid) = 100.0 + myid; + + v.block(1)(myid*2)=myid*2.0; + v.block(1)(myid*2+1)=myid*2.0+1.0; + + v.compress(VectorOperation::insert); + + //Assert(!v.has_ghost_elements(), ExcInternalError()); + + deallog << "size: " << v.size() << std::endl; + deallog << "size[0]: " << v.block(0).size() << std::endl; + deallog << "size[1]: " << v.block(1).size() << std::endl; + + { + std::ofstream file((JobIdentifier::base_name(__FILE__)+"/ncpu_" + Utilities::int_to_string(Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD)) + "/dat." + Utilities::int_to_string(myid)).c_str()); + + file << "**** proc " << myid << std::endl; + v.print(file); + } + + MPI_Barrier(MPI_COMM_WORLD); + + if (myid==0) + { + for (unsigned int i=0;i(); + //test(); + } + else + { + test(); + //test(); + } + +}