From: heister Date: Wed, 12 Oct 2011 18:54:35 +0000 (+0000) Subject: add tests for distributed::Triangulation::load()/save() X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=744c8962b332a5173a707ef5cca37559f23a2398;p=dealii-svn.git add tests for distributed::Triangulation::load()/save() git-svn-id: https://svn.dealii.org/trunk@24596 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/mpi/p4est_save_01.cc b/tests/mpi/p4est_save_01.cc new file mode 100644 index 0000000000..5885e4fd71 --- /dev/null +++ b/tests/mpi/p4est_save_01.cc @@ -0,0 +1,140 @@ +//--------------------------------------------------------------------------- +// $Id: p4est_2d_refine_02.cc 23906 2011-07-01 14:59:13Z bangerth $ +// 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. +// +//--------------------------------------------------------------------------- + + +// save and load a triangulation + +#include "../tests.h" +#include "coarse_grid_common.h" +#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); + + if (Utilities::System::get_this_mpi_process (MPI_COMM_WORLD) == 0) + deallog << "hyper_cube" << std::endl; + + std::string filename = + (std::string("p4est_save_01/ncpu_") + Utilities::int_to_string(Utilities::System::get_n_mpi_processes (MPI_COMM_WORLD)) + "/dat"); + { + parallel::distributed::Triangulation tr(MPI_COMM_WORLD); + + GridGenerator::hyper_cube(tr); + + tr.refine_global(2); + for (typename Triangulation::active_cell_iterator + cell = tr.begin_active(); + cell != tr.end(); ++cell) + if (!cell->is_ghost() && !cell->is_artificial()) + if (cell->center().norm() < 0.3) + { + cell->set_refine_flag(); + } + + tr.execute_coarsening_and_refinement (); + + tr.save(filename.c_str()); + + if (myid == 0) + { + deallog << "#cells = " << tr.n_global_active_cells() << std::endl; + deallog << "cells(0) = " << tr.n_active_cells() << std::endl; + } + deallog << "Checksum: " + << tr.get_checksum () + << std::endl; + + } + MPI_Barrier(MPI_COMM_WORLD); + + { + parallel::distributed::Triangulation tr(MPI_COMM_WORLD); + + GridGenerator::hyper_cube(tr); + tr.load(filename.c_str()); + + if (myid == 0) + { + deallog << "#cells = " << tr.n_global_active_cells() << std::endl; + deallog << "cells(0) = " << tr.n_active_cells() << std::endl; + } + deallog << "Checksum: " + << tr.get_checksum () + << std::endl; + } + + if (Utilities::System::get_this_mpi_process (MPI_COMM_WORLD) == 0) + deallog << "OK" << std::endl; +} + + +int main(int argc, char *argv[]) +{ +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI + PetscInitialize(&argc,&argv,0,0); + +// 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("p4est_save_01").c_str()); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + deallog.push("2d"); + test<2>(); + deallog.pop(); + } + else + test<2>(); + + +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI + //MPI_Finalize(); + PetscFinalize(); + +#endif +} diff --git a/tests/mpi/p4est_save_01/ncpu_10/cmp/generic b/tests/mpi/p4est_save_01/ncpu_10/cmp/generic new file mode 100644 index 0000000000..b6840363c4 --- /dev/null +++ b/tests/mpi/p4est_save_01/ncpu_10/cmp/generic @@ -0,0 +1,5 @@ + +DEAL:0:2d::hyper_cube +DEAL:0:2d::#cells = 7 +DEAL:0:2d::Checksum: 426967244 +DEAL:0:2d::OK diff --git a/tests/mpi/p4est_save_01/ncpu_4/cmp/generic b/tests/mpi/p4est_save_01/ncpu_4/cmp/generic new file mode 100644 index 0000000000..b6840363c4 --- /dev/null +++ b/tests/mpi/p4est_save_01/ncpu_4/cmp/generic @@ -0,0 +1,5 @@ + +DEAL:0:2d::hyper_cube +DEAL:0:2d::#cells = 7 +DEAL:0:2d::Checksum: 426967244 +DEAL:0:2d::OK diff --git a/tests/mpi/p4est_save_02.cc b/tests/mpi/p4est_save_02.cc new file mode 100644 index 0000000000..c7bea53065 --- /dev/null +++ b/tests/mpi/p4est_save_02.cc @@ -0,0 +1,194 @@ +//--------------------------------------------------------------------------- +// $Id: p4est_2d_refine_02.cc 23906 2011-07-01 14:59:13Z bangerth $ +// 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. +// +//--------------------------------------------------------------------------- + + +// save and load a triangulation with one solution vector + +#include "../tests.h" +#include "coarse_grid_common.h" +#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); + + if (Utilities::System::get_this_mpi_process (MPI_COMM_WORLD) == 0) + deallog << "hyper_cube" << std::endl; + + std::string filename = + (std::string("p4est_save_02/ncpu_") + Utilities::int_to_string(Utilities::System::get_n_mpi_processes (MPI_COMM_WORLD)) + "/dat"); + { + parallel::distributed::Triangulation tr(MPI_COMM_WORLD); + + GridGenerator::hyper_cube(tr); + + tr.refine_global(2); + for (typename Triangulation::active_cell_iterator + cell = tr.begin_active(); + cell != tr.end(); ++cell) + if (!cell->is_ghost() && !cell->is_artificial()) + if (cell->center().norm() < 0.3) + { + cell->set_refine_flag(); + } + + tr.execute_coarsening_and_refinement (); + + FE_Q fe(1); + DoFHandler dh(tr); + + dh.distribute_dofs(fe); + + IndexSet locally_owned_dofs = dh.locally_owned_dofs (); + IndexSet locally_relevant_dofs; + + DoFTools::extract_locally_relevant_dofs (dh,locally_relevant_dofs); + + PETScWrappers::MPI::Vector solution(MPI_COMM_WORLD,locally_owned_dofs,locally_relevant_dofs); + + parallel::distributed::SolutionTransfer soltrans(dh); + + for (unsigned int i=0;i tr(MPI_COMM_WORLD); + + GridGenerator::hyper_cube(tr); + tr.load(filename.c_str()); + FE_Q fe(1); + DoFHandler dh(tr); + + dh.distribute_dofs(fe); + + IndexSet locally_owned_dofs = dh.locally_owned_dofs (); + IndexSet locally_relevant_dofs; + + DoFTools::extract_locally_relevant_dofs (dh,locally_relevant_dofs); + + PETScWrappers::MPI::Vector solution(MPI_COMM_WORLD,locally_owned_dofs); + parallel::distributed::SolutionTransfer soltrans(dh); + solution = 2; + soltrans.deserialize(solution); + + for (unsigned int i=0;i(); + deallog.pop(); + } + else + test<2>(); + + +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI + //MPI_Finalize(); + PetscFinalize(); + +#endif +} diff --git a/tests/mpi/p4est_save_02/ncpu_10/cmp/generic b/tests/mpi/p4est_save_02/ncpu_10/cmp/generic new file mode 100644 index 0000000000..48ad8a8ba4 --- /dev/null +++ b/tests/mpi/p4est_save_02/ncpu_10/cmp/generic @@ -0,0 +1,40 @@ + +DEAL:0:2d::hyper_cube +**** proc 0 +**** + +**** proc 1 + 5 4: 0.5 + 5 8: 0.5 + 7 6: 0.5 + 7 8: 0.5 +**** + 5 4: 0.5 + 5 8: 0.5 + 7 6: 0.5 + 7 8: 0.5 + +**** proc 2 +**** + +**** proc 3 +**** + +**** proc 4 +**** + +**** proc 5 +**** + +**** proc 6 +**** + +**** proc 7 +**** + +**** proc 8 +**** + +**** proc 9 +**** + diff --git a/tests/mpi/p4est_save_02/ncpu_4/cmp/generic b/tests/mpi/p4est_save_02/ncpu_4/cmp/generic new file mode 100644 index 0000000000..b52b8b28fc --- /dev/null +++ b/tests/mpi/p4est_save_02/ncpu_4/cmp/generic @@ -0,0 +1,22 @@ + +DEAL:0:2d::hyper_cube +**** proc 0 +**** + +**** proc 1 + 5 4: 0.5 + 5 8: 0.5 + 7 6: 0.5 + 7 8: 0.5 +**** + 5 4: 0.5 + 5 8: 0.5 + 7 6: 0.5 + 7 8: 0.5 + +**** proc 2 +**** + +**** proc 3 +**** +