From: Martin Kronbichler Date: Thu, 19 Sep 2019 11:06:39 +0000 (+0200) Subject: Avoid dynamic_cast in ghost/artificial cell queries X-Git-Tag: v9.2.0-rc1~1026^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c0894d561deff3d4192687adc17db786472359c;p=dealii.git Avoid dynamic_cast in ghost/artificial cell queries --- diff --git a/include/deal.II/grid/tria_accessor.templates.h b/include/deal.II/grid/tria_accessor.templates.h index 59cdaf16da..fe9e0e9c0d 100644 --- a/include/deal.II/grid/tria_accessor.templates.h +++ b/include/deal.II/grid/tria_accessor.templates.h @@ -3566,17 +3566,10 @@ CellAccessor::is_locally_owned() const #ifndef DEAL_II_WITH_MPI return true; #else - if (is_artificial()) - return false; - - const parallel::TriangulationBase *pt = - dynamic_cast *>( - this->tria); - if (pt == nullptr) - return true; - else - return (this->subdomain_id() == pt->locally_owned_subdomain()); + return (this->tria->locally_owned_subdomain() == + numbers::invalid_subdomain_id || + this->subdomain_id() == this->tria->locally_owned_subdomain()); #endif } @@ -3590,14 +3583,9 @@ CellAccessor::is_locally_owned_on_level() const return true; #else - const parallel::TriangulationBase *pt = - dynamic_cast *>( - this->tria); - - if (pt == nullptr) - return true; - else - return (this->level_subdomain_id() == pt->locally_owned_subdomain()); + return (this->tria->locally_owned_subdomain() == + numbers::invalid_subdomain_id || + this->level_subdomain_id() == this->tria->locally_owned_subdomain()); #endif } @@ -3609,21 +3597,17 @@ CellAccessor::is_ghost() const { Assert(this->active(), ExcMessage("is_ghost() can only be called on active cells!")); - if (is_artificial() || this->has_children()) + if (this->has_children()) return false; #ifndef DEAL_II_WITH_MPI return false; #else - const parallel::TriangulationBase *pt = - dynamic_cast *>( - this->tria); - - if (pt == nullptr) - return false; - else - return (this->subdomain_id() != pt->locally_owned_subdomain()); + return (this->tria->locally_owned_subdomain() != + numbers::invalid_subdomain_id && + this->subdomain_id() != this->tria->locally_owned_subdomain() && + this->subdomain_id() != numbers::artificial_subdomain_id); #endif } @@ -3640,14 +3624,9 @@ CellAccessor::is_artificial() const return false; #else - const parallel::TriangulationBase *pt = - dynamic_cast *>( - this->tria); - - if (pt == nullptr) - return false; - else - return this->subdomain_id() == numbers::artificial_subdomain_id; + return (this->tria->locally_owned_subdomain() != + numbers::invalid_subdomain_id && + this->subdomain_id() == numbers::artificial_subdomain_id); #endif }