]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify logic a bit.
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 6 Jul 2017 19:38:11 +0000 (13:38 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sun, 9 Jul 2017 15:54:50 +0000 (09:54 -0600)
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
source/hp/dof_handler.cc

index cea077c60bb8961d128681b7f750d9e416914ab5..f4d3a20b267fc83fd5a82c9d9a38b0267f5e9db7 100644 (file)
@@ -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);
 }
index abe9c915bd68bc9172848d9e89b5d1f6247072c7..344c71a31c793068bf191870da9831666410db28 100644 (file)
@@ -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),

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.