From: bangerth Date: Sat, 25 May 2013 13:02:30 +0000 (+0000) Subject: New test. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a9ababf95eeff9c98d6fc3062661069585ee2a9;p=dealii-svn.git New test. git-svn-id: https://svn.dealii.org/trunk@29595 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/mpi/petsc_locally_owned_elements.cc b/tests/mpi/petsc_locally_owned_elements.cc new file mode 100644 index 0000000000..a56304aec0 --- /dev/null +++ b/tests/mpi/petsc_locally_owned_elements.cc @@ -0,0 +1,81 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2009, 2010, 2012, 2013 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. +// +//--------------------------------------------------------------------------- + + +// check ConstraintMatrix.distribute() for a petsc vector +// +// like _01, but for a block vector. this has the additional complication that +// (at a global level) the set of indices owned by this processor is not +// contiguous + +#include "../tests.h" +#include +#include +#include + +#include +#include + + + +void test() +{ + const unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); + const unsigned int n_processes = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD); + + // create a vector that consists of elements indexed from 0 to n + PETScWrappers::MPI::BlockVector vec(2, MPI_COMM_WORLD, 100 * n_processes, 100); + vec.block(0).reinit(MPI_COMM_WORLD, 100 * n_processes, 100); + vec.block(1).reinit(MPI_COMM_WORLD, 100 * n_processes, 100); + vec.collect_sizes(); + Assert (vec.block(0).local_size() == 100, ExcInternalError()); + Assert (vec.block(0).local_range().first == 100*myid, ExcInternalError()); + Assert (vec.block(0).local_range().second == 100*myid+100, ExcInternalError()); + Assert (vec.block(1).local_size() == 100, ExcInternalError()); + Assert (vec.block(1).local_range().first == 100*myid, ExcInternalError()); + Assert (vec.block(1).local_range().second == 100*myid+100, ExcInternalError()); + + IndexSet locally_owned (vec.size()); + locally_owned.add_range (100*myid, 100*myid+100); + locally_owned.add_range (vec.block(0).size()+100*myid, + vec.block(0).size()+100*myid+100); + Assert (vec.locally_owned_elements() == locally_owned, + ExcInternalError()); + + if (myid == 0) + deallog << "OK" << std::endl; +} + + +int main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + + 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("petsc_locally_owned_elements").c_str()); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test(); + } + else + test(); + +} diff --git a/tests/mpi/petsc_locally_owned_elements/ncpu_1/cmp/generic b/tests/mpi/petsc_locally_owned_elements/ncpu_1/cmp/generic new file mode 100644 index 0000000000..be8d055f86 --- /dev/null +++ b/tests/mpi/petsc_locally_owned_elements/ncpu_1/cmp/generic @@ -0,0 +1,2 @@ + +DEAL:0::OK diff --git a/tests/mpi/petsc_locally_owned_elements/ncpu_10/cmp/generic b/tests/mpi/petsc_locally_owned_elements/ncpu_10/cmp/generic new file mode 100644 index 0000000000..be8d055f86 --- /dev/null +++ b/tests/mpi/petsc_locally_owned_elements/ncpu_10/cmp/generic @@ -0,0 +1,2 @@ + +DEAL:0::OK diff --git a/tests/mpi/petsc_locally_owned_elements/ncpu_2/cmp/generic b/tests/mpi/petsc_locally_owned_elements/ncpu_2/cmp/generic new file mode 100644 index 0000000000..be8d055f86 --- /dev/null +++ b/tests/mpi/petsc_locally_owned_elements/ncpu_2/cmp/generic @@ -0,0 +1,2 @@ + +DEAL:0::OK diff --git a/tests/mpi/petsc_locally_owned_elements/ncpu_4/cmp/generic b/tests/mpi/petsc_locally_owned_elements/ncpu_4/cmp/generic new file mode 100644 index 0000000000..be8d055f86 --- /dev/null +++ b/tests/mpi/petsc_locally_owned_elements/ncpu_4/cmp/generic @@ -0,0 +1,2 @@ + +DEAL:0::OK