From: Peter Munch Date: Wed, 23 Jun 2021 21:00:44 +0000 (+0200) Subject: Add CellAccessor::is_ghost_on_level() X-Git-Tag: v9.4.0-rc1~1192^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc58cab2941c014207e2274f97a3ec0781fc3f39;p=dealii.git Add CellAccessor::is_ghost_on_level() --- diff --git a/doc/news/changes/minor/20210623Munch b/doc/news/changes/minor/20210623Munch new file mode 100644 index 0000000000..374b899c69 --- /dev/null +++ b/doc/news/changes/minor/20210623Munch @@ -0,0 +1,4 @@ +New: The new function CellAccessor::is_ghost_on_level() allows to +check if a cell is a ghost cell on a multigrid level. +
+(Peter Munch, 2021/06/23) diff --git a/include/deal.II/grid/tria_accessor.h b/include/deal.II/grid/tria_accessor.h index ece9c4c881..e2a2a1dd37 100644 --- a/include/deal.II/grid/tria_accessor.h +++ b/include/deal.II/grid/tria_accessor.h @@ -3703,6 +3703,14 @@ public: bool is_ghost() const; + /** + * Return true if either the Triangulation is not distributed or if the + * cell is not artificial and the level_subdomain_id() is not equal to the id + * of the current processor. + */ + bool + is_ghost_on_level() const; + /** * Return whether this cell is artificial, i.e. it isn't one of the cells * owned by the current processor, and it also doesn't border on one. As a diff --git a/include/deal.II/grid/tria_accessor.templates.h b/include/deal.II/grid/tria_accessor.templates.h index d857cc3984..8f263b9870 100644 --- a/include/deal.II/grid/tria_accessor.templates.h +++ b/include/deal.II/grid/tria_accessor.templates.h @@ -3737,6 +3737,27 @@ CellAccessor::is_ghost() const } +template +inline bool +CellAccessor::is_ghost_on_level() const +{ +#ifndef DEAL_II_WITH_MPI + return true; +#else + + // Serial triangulations report invalid_subdomain_id as their locally owned + // subdomain, so the first condition checks whether we have a serial + // triangulation, in which case all cells are locally owned. The second + // condition compares the subdomain id in the parallel case. + return ( + this->tria->locally_owned_subdomain() == numbers::invalid_subdomain_id || + (this->level_subdomain_id() != this->tria->locally_owned_subdomain() && + this->level_subdomain_id() != numbers::artificial_subdomain_id)); + +#endif +} + + template inline bool