From: bangerth Date: Sun, 26 Jun 2011 03:18:01 +0000 (+0000) Subject: One more test. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=341571a372bdae9c34088efb8969303b4b8846ff;p=dealii-svn.git One more test. git-svn-id: https://svn.dealii.org/trunk@23863 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/mpi/interpolate_02.cc b/tests/mpi/interpolate_02.cc new file mode 100644 index 0000000000..925be13188 --- /dev/null +++ b/tests/mpi/interpolate_02.cc @@ -0,0 +1,113 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2009, 2010, 2011 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. +// +//--------------------------------------------------------------------------- + + +// Like _01 but with PETSc vectors + +#include "../tests.h" +#include "coarse_grid_common.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + + +template +void test() +{ + unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD); + unsigned int numproc = Utilities::System::get_n_mpi_processes (MPI_COMM_WORLD); + + // create a mesh so that all but one + // processor are empty + parallel::distributed::Triangulation tr(MPI_COMM_WORLD); + GridGenerator::hyper_cube (tr); + FE_Q fe (1); + DoFHandler dofh(tr); + dofh.distribute_dofs (fe); + + IndexSet owned_set = dofh.locally_owned_dofs(); + PETScWrappers::MPI::Vector x (MPI_COMM_WORLD,dof.n_dofs(),owned_set.size()); + + VectorTools::interpolate(dofh, + ConstantFunction(1), + x); + x.compress (); + const double norm = x.l2_norm(); + if (myid == 0) + deallog << dofh.n_locally_owned_dofs() << ' ' << dofh.n_dofs() + << std::endl + << norm + << std::endl; +} + + +int main(int argc, char *argv[]) +{ +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI + MPI_Init (&argc,&argv); +#else + (void)argc; + (void)argv; +#endif + + unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD); + + + deallog.push(Utilities::int_to_string(myid)); + + if (myid == 0) + { + std::ofstream logfile(output_file_for_mpi("interpolate_02").c_str()); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + deallog.push("2d"); + test<2>(); + deallog.pop(); + deallog.push("3d"); + test<3>(); + deallog.pop(); + } + else + { + test<2>(); + test<3>(); + } + +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI + MPI_Finalize(); +#endif +} diff --git a/tests/mpi/interpolate_02/ncpu_10/cmp/generic b/tests/mpi/interpolate_02/ncpu_10/cmp/generic new file mode 100644 index 0000000000..801195966b --- /dev/null +++ b/tests/mpi/interpolate_02/ncpu_10/cmp/generic @@ -0,0 +1,5 @@ + +DEAL:0:2d::0 4 +DEAL:0:2d::2.00000 +DEAL:0:3d::0 8 +DEAL:0:3d::2.82843 diff --git a/tests/mpi/interpolate_02/ncpu_4/cmp/generic b/tests/mpi/interpolate_02/ncpu_4/cmp/generic new file mode 100644 index 0000000000..801195966b --- /dev/null +++ b/tests/mpi/interpolate_02/ncpu_4/cmp/generic @@ -0,0 +1,5 @@ + +DEAL:0:2d::0 4 +DEAL:0:2d::2.00000 +DEAL:0:3d::0 8 +DEAL:0:3d::2.82843