From 0c0894d561deff3d4192687adc17db786472359c Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Thu, 19 Sep 2019 13:06:39 +0200 Subject: [PATCH] Avoid dynamic_cast in ghost/artificial cell queries --- .../deal.II/grid/tria_accessor.templates.h | 49 ++++++------------- 1 file changed, 14 insertions(+), 35 deletions(-) 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 } -- 2.39.5