From: bangerth Date: Sun, 15 Jun 2014 13:31:56 +0000 (+0000) Subject: Patch by Denis Davydov: Triangulation::has_hanging_nodes() and similar in parallel... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca777004a5880e23fdb0118f69d2c67626da4668;p=dealii-svn.git Patch by Denis Davydov: Triangulation::has_hanging_nodes() and similar in parallel::distributed::Triangulation. git-svn-id: https://svn.dealii.org/trunk@33043 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/mpi/has_hanging_nodes.cc b/tests/mpi/has_hanging_nodes.cc new file mode 100644 index 0000000000..8245a01381 --- /dev/null +++ b/tests/mpi/has_hanging_nodes.cc @@ -0,0 +1,156 @@ +// --------------------------------------------------------------------- +// $Id: p4est_2d_coarse_01.cc 31349 2013-10-20 19:07:06Z maier $ +// +// Copyright (C) 2014 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// Test has_hanging_nodes() in sequential and parallel triangulations + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + +#include + + +#include +#include + +using namespace dealii; + +//#define DISTRIBUTED + +template +void test_int(const unsigned int n_global = 0, + const unsigned int n_local = 0) +{ + + MPI_Comm mpi_communicator (MPI_COMM_WORLD); + const unsigned int n_mpi_processes (Utilities::MPI::n_mpi_processes(mpi_communicator)); + const unsigned int this_mpi_process (Utilities::MPI::this_mpi_process(mpi_communicator)); + + ConditionalOStream pcout (std::cout, + (Utilities::MPI::this_mpi_process(mpi_communicator) + == 0)); + + + parallel::distributed::Triangulation tria_distrib(mpi_communicator); + + Triangulation tria_sequential; + + + { + Triangulation triangulation1; + Triangulation triangulation2; + GridGenerator::hyper_cube (triangulation1, -1,0); //create a square [-1,0]^d domain + GridGenerator::hyper_cube (triangulation2, -1,0); //create a square [-1,0]^d domain + Point shift_vector; + shift_vector[0] = 1.0; + GridTools::shift(shift_vector,triangulation2); + GridGenerator::merge_triangulations (triangulation1, triangulation2, tria_distrib); + GridGenerator::merge_triangulations (triangulation1, triangulation2, tria_sequential); + } + + tria_distrib.refine_global (n_global); + tria_sequential.refine_global(n_global); + + for (unsigned int i = 0; i < n_local; i++) + { + // refine both the distributed and the sequential triangulation. the + // following relies on the fact that the first cell of the "global" + // triangulation happens to be on processor 0 + if (this_mpi_process == 0) + { + for (typename Triangulation::active_cell_iterator + cell = tria_distrib.begin_active(); + cell != tria_distrib.end(); ++cell) + if (cell->is_locally_owned()) + { + cell->set_refine_flag (); + break; + } + } + + + tria_sequential.begin_active()->set_refine_flag (); + + + tria_distrib.prepare_coarsening_and_refinement (); + tria_distrib.execute_coarsening_and_refinement (); + + tria_sequential.prepare_coarsening_and_refinement (); + tria_sequential.execute_coarsening_and_refinement (); + } + + deallog << n_global << " " << n_local + << " distrib=" << tria_distrib.has_hanging_nodes() + << "; shared=" << tria_sequential.has_hanging_nodes() + << std::endl; +} + + +int main (int argc, char *argv[]) +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv); + test_int<2>(0,0); + test_int<2>(2,0); + test_int<2>(3,1); + + test_int<3>(0,0); + test_int<3>(2,0); + test_int<3>(3,1); +} diff --git a/tests/mpi/has_hanging_nodes.mpirun=3.output b/tests/mpi/has_hanging_nodes.mpirun=3.output new file mode 100644 index 0000000000..b6944adcca --- /dev/null +++ b/tests/mpi/has_hanging_nodes.mpirun=3.output @@ -0,0 +1,7 @@ + +DEAL::0 0 distrib=0; shared=0 +DEAL::2 0 distrib=0; shared=0 +DEAL::3 1 distrib=1; shared=1 +DEAL::0 0 distrib=0; shared=0 +DEAL::2 0 distrib=0; shared=0 +DEAL::3 1 distrib=1; shared=1 diff --git a/tests/mpi/has_hanging_nodes.mpirun=7.output b/tests/mpi/has_hanging_nodes.mpirun=7.output new file mode 100644 index 0000000000..b6944adcca --- /dev/null +++ b/tests/mpi/has_hanging_nodes.mpirun=7.output @@ -0,0 +1,7 @@ + +DEAL::0 0 distrib=0; shared=0 +DEAL::2 0 distrib=0; shared=0 +DEAL::3 1 distrib=1; shared=1 +DEAL::0 0 distrib=0; shared=0 +DEAL::2 0 distrib=0; shared=0 +DEAL::3 1 distrib=1; shared=1