From: bangerth Date: Sun, 15 Jun 2014 13:31:37 +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=1c9dd25ce8838fe1e074207f5176f5f2b9b2b1a2;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@33042 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index de4f3e3f36..9cbe16bcdd 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -148,6 +148,12 @@ inconvenience this causes.

Specific improvements

    +
  1. New: There are now functions Triangulation::has_hanging_nodes() + and parallel::distributed::Triangulation::has_hanging_nodes(). +
    + (Denis Davydov, 2014/06/15) +
  2. +
  3. New: There is now a class FEEvaluationQ_DG0 that does optimized matrix-free evaluation for FE_Q_DG0 elements.
    diff --git a/deal.II/include/deal.II/distributed/tria.h b/deal.II/include/deal.II/distributed/tria.h index e48384738c..f2c696d740 100644 --- a/deal.II/include/deal.II/distributed/tria.h +++ b/deal.II/include/deal.II/distributed/tria.h @@ -1,7 +1,7 @@ // --------------------------------------------------------------------- // $Id$ // -// Copyright (C) 2008 - 2013 by the deal.II authors +// Copyright (C) 2008 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -499,6 +499,25 @@ namespace parallel */ virtual unsigned int n_global_levels () const; + /** + * Returns true if the triangulation has hanging nodes. + * + * In the context of parallel distributed triangulations, every + * processor stores only that part of the triangulation it + * locally owns. However, it also stores the entire coarse + * mesh, and to guarantee the 2:1 relationship between cells, + * this may mean that there are hanging nodes between cells that + * are not locally owned or ghost cells (i.e., between ghost cells + * and artificial cells, or between artificial and artificial cells; + * see @ref GlossArtificialCell "the glossary"). + * One is not typically interested in this case, so the function + * returns whether there are hanging nodes between any two cells + * of the "global" mesh, i.e., the union of locally owned cells + * on all processors. + */ + virtual + bool has_hanging_nodes() const; + /** * Return the number of active cells owned by each of the MPI * processes that contribute to this triangulation. The element diff --git a/deal.II/include/deal.II/grid/tria.h b/deal.II/include/deal.II/grid/tria.h index 8828bfe184..86d7789683 100644 --- a/deal.II/include/deal.II/grid/tria.h +++ b/deal.II/include/deal.II/grid/tria.h @@ -1,7 +1,7 @@ // --------------------------------------------------------------------- // $Id$ // -// Copyright (C) 1998 - 2013 by the deal.II authors +// Copyright (C) 1998 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -2896,7 +2896,20 @@ public: * n_levels() over all processors for a parallel::distributed::Triangulation * and therefore can be larger than n_levels(). */ - virtual unsigned int n_global_levels () const; + virtual + unsigned int n_global_levels () const; + + /** + * Return true if the triangulation has hanging nodes. + * + * The function is made virtual since the result can be interpreted in different + * ways, depending on whether the triangulation lives only on a single processor, + * or may be distributed as done in the parallel::distributed::Triangulation + * class (see there for a description of what the function is supposed to do in the + * parallel context). + */ + virtual + bool has_hanging_nodes() const; /** * Return the total number of diff --git a/deal.II/source/distributed/tria.cc b/deal.II/source/distributed/tria.cc index dd92694d7f..c1ec69b62e 100644 --- a/deal.II/source/distributed/tria.cc +++ b/deal.II/source/distributed/tria.cc @@ -1,7 +1,7 @@ // --------------------------------------------------------------------- // $Id$ // -// Copyright (C) 2008 - 2013 by the deal.II authors +// Copyright (C) 2008 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -2133,6 +2133,32 @@ namespace parallel update_number_cache (); } + template + bool + Triangulation::has_hanging_nodes () const + { + // if there are any active cells with level less than n_global_levels()-1, then + // there is obviously also one with level n_global_levels()-1, and + // consequently there must be a hanging node somewhere. + // + // the problem is that we cannot just ask for the first active cell, but + // instead need to filter over locally owned cells + bool res_local = false; + for (typename Triangulation::active_cell_iterator cell = this->begin_active(); + (cell != this->end()) && (cell->level() < (int)(n_global_levels()-1)); + cell++) + if (cell->is_locally_owned()) + { + res_local = true; + break; + } + + // reduce over MPI + bool res; + MPI_Allreduce(&res_local, &res, 1, MPI::BOOL, MPI_LOR, mpi_communicator); + return res; + } + template diff --git a/deal.II/source/grid/tria.cc b/deal.II/source/grid/tria.cc index 4decbf7886..2193762bea 100644 --- a/deal.II/source/grid/tria.cc +++ b/deal.II/source/grid/tria.cc @@ -11571,6 +11571,16 @@ unsigned int Triangulation::n_active_cells (const unsigned int le } +template +bool Triangulation::has_hanging_nodes () const +{ + for (unsigned int lvl = 0; lvl unsigned int Triangulation::n_lines () const