From: Wolfgang Bangerth <bangerth@colostate.edu>
Date: Thu, 6 Jul 2017 19:38:11 +0000 (-0600)
Subject: Simplify logic a bit.
X-Git-Tag: v9.0.0-rc1~1427^2~4
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f73e497830cf559bc703729e873b1268529e88cc;p=dealii.git

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.
---

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<dim,spacedim> &t,
   faces = nullptr;
   number_cache.n_global_dofs = 0;
 
-  // decide whether we need a
-  // sequential or a parallel
-  // distributed policy
-  if (dynamic_cast<const parallel::shared::Triangulation< dim, spacedim>*>
-      (&t)
-      != nullptr)
+  // decide whether we need a sequential or a parallel distributed policy
+  if (dynamic_cast<const parallel::shared::Triangulation< dim, spacedim>*> (&t) != nullptr)
     policy.reset (new internal::DoFHandler::Policy::ParallelShared<DoFHandler<dim,spacedim> >(*this));
-  else if (dynamic_cast<const parallel::distributed::Triangulation< dim, spacedim >*>
-           (&t)
-           == nullptr)
-    policy.reset (new internal::DoFHandler::Policy::Sequential<DoFHandler<dim,spacedim> >(*this));
-  else
+  else if (dynamic_cast<const parallel::distributed::Triangulation< dim, spacedim >*> (&t) != nullptr)
     policy.reset (new internal::DoFHandler::Policy::ParallelDistributed<dim,spacedim>(*this));
+  else
+    policy.reset (new internal::DoFHandler::Policy::Sequential<DoFHandler<dim,spacedim> >(*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<const parallel::shared::Triangulation< dim, spacedim>*>
-//        (&tria)
-//        != nullptr)
-//      policy.reset (new internal::DoFHandler::Policy::ParallelShared<dim,spacedim>(*this));
-//    else if (dynamic_cast<const parallel::distributed::Triangulation< dim, spacedim >*>
-//             (&tria)
-//             == nullptr)
-    policy.reset (new internal::DoFHandler::Policy::Sequential<DoFHandler<dim,spacedim> >(*this));
-//    else
-//      policy.reset (new internal::DoFHandler::Policy::ParallelDistributed<dim,spacedim>(*this));
-
+    if (dynamic_cast<const parallel::shared::Triangulation< dim, spacedim>*> (&*this->tria) != nullptr)
+      policy.reset (new internal::DoFHandler::Policy::ParallelShared<DoFHandler<dim,spacedim> >(*this));
+    else if (dynamic_cast<const parallel::distributed::Triangulation< dim, spacedim >*> (&*this->tria) != nullptr)
+      //policy.reset (new internal::DoFHandler::Policy::ParallelDistributed<dim,spacedim>(*this));
+      {
+        Assert (false, ExcNotImplemented());
+      }
+    else
+      policy.reset (new internal::DoFHandler::Policy::Sequential<DoFHandler<dim,spacedim> >(*this));
 
     create_active_fe_table ();
 
@@ -1588,10 +1586,6 @@ namespace hp
     /////////////////////////////////
 
 
-    Assert ((dynamic_cast<const parallel::shared::Triangulation< dim, spacedim >*>
-             (&this->get_triangulation())
-             == nullptr),
-            ExcNotImplemented());
     Assert ((dynamic_cast<const parallel::distributed::Triangulation< dim, spacedim >*>
              (&this->get_triangulation())
              == nullptr),