From f73e497830cf559bc703729e873b1268529e88cc Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 6 Jul 2017 13:38:11 -0600 Subject: [PATCH] Simplify logic a bit. In particular, do not follow an if-statement that tests '!=null_ptr' by one that tests '==null_ptr' since this is almost impossible to understand at a short glance. --- source/dofs/dof_handler.cc | 16 +++++----------- source/hp/dof_handler.cc | 24 +++++++++--------------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/source/dofs/dof_handler.cc b/source/dofs/dof_handler.cc index cea077c60b..f4d3a20b26 100644 --- a/source/dofs/dof_handler.cc +++ b/source/dofs/dof_handler.cc @@ -699,19 +699,13 @@ initialize(const Triangulation &t, faces = nullptr; number_cache.n_global_dofs = 0; - // decide whether we need a - // sequential or a parallel - // distributed policy - if (dynamic_cast*> - (&t) - != nullptr) + // decide whether we need a sequential or a parallel distributed policy + if (dynamic_cast*> (&t) != nullptr) policy.reset (new internal::DoFHandler::Policy::ParallelShared >(*this)); - else if (dynamic_cast*> - (&t) - == nullptr) - policy.reset (new internal::DoFHandler::Policy::Sequential >(*this)); - else + else if (dynamic_cast*> (&t) != nullptr) policy.reset (new internal::DoFHandler::Policy::ParallelDistributed(*this)); + else + policy.reset (new internal::DoFHandler::Policy::Sequential >(*this)); distribute_dofs(fe); } diff --git a/source/hp/dof_handler.cc b/source/hp/dof_handler.cc index abe9c915bd..344c71a31c 100644 --- a/source/hp/dof_handler.cc +++ b/source/hp/dof_handler.cc @@ -1095,17 +1095,15 @@ namespace hp "this class does not currently support this.")); // decide whether we need a sequential or a parallel distributed policy -// if (dynamic_cast*> -// (&tria) -// != nullptr) -// policy.reset (new internal::DoFHandler::Policy::ParallelShared(*this)); -// else if (dynamic_cast*> -// (&tria) -// == nullptr) - policy.reset (new internal::DoFHandler::Policy::Sequential >(*this)); -// else -// policy.reset (new internal::DoFHandler::Policy::ParallelDistributed(*this)); - + if (dynamic_cast*> (&*this->tria) != nullptr) + policy.reset (new internal::DoFHandler::Policy::ParallelShared >(*this)); + else if (dynamic_cast*> (&*this->tria) != nullptr) + //policy.reset (new internal::DoFHandler::Policy::ParallelDistributed(*this)); + { + Assert (false, ExcNotImplemented()); + } + else + policy.reset (new internal::DoFHandler::Policy::Sequential >(*this)); create_active_fe_table (); @@ -1588,10 +1586,6 @@ namespace hp ///////////////////////////////// - Assert ((dynamic_cast*> - (&this->get_triangulation()) - == nullptr), - ExcNotImplemented()); Assert ((dynamic_cast*> (&this->get_triangulation()) == nullptr), -- 2.39.5