]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Partial merge from the cmake branch: Avoid warnings about accesses past the end of...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Sun, 4 Nov 2012 22:58:42 +0000 (22:58 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Sun, 4 Nov 2012 22:58:42 +0000 (22:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@27358 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/dofs/dof_renumbering.cc

index 2a0085e8509eeb6905cb399dae364651de2950c0..05f978abeb4e9258040a88c6f283e69698d7b7a6 100644 (file)
@@ -15,6 +15,7 @@
 #include <deal.II/base/thread_management.h>
 #include <deal.II/base/utilities.h>
 #include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/template_constraints.h>
 
 #include <deal.II/lac/sparsity_pattern.h>
 #include <deal.II/lac/sparsity_tools.h>
@@ -2016,6 +2017,7 @@ namespace DoFRenumbering
                         center(center),
                         counter(counter)
           {}
+
                                          /**
                                           * Comparison operator
                                           */
@@ -2023,15 +2025,42 @@ namespace DoFRenumbering
         bool operator () (const DHCellIterator& c1,
                           const DHCellIterator& c2) const
           {
-           Assert (dim >= 2,
-                   ExcMessage ("This operation only makes sense for dim>=2."));
+                                            // dispatch to
+                                            // dimension-dependent functions
+           return compare (c1, c2, dealii::internal::int2type<dim>());
+          }
 
+      private:
+                                         /**
+                                          * Comparison operator for dim>=2
+                                          */
+        template <class DHCellIterator, int xdim>
+        bool compare (const DHCellIterator& c1,
+                     const DHCellIterator& c2,
+                     dealii::internal::int2type<xdim>) const
+         {
             const Point<dim> v1 = c1->center() - center;
             const Point<dim> v2 = c2->center() - center;
             const double s1 = std::atan2(v1(0), v1(1));
             const double s2 = std::atan2(v2(0), v2(1));
             return ( counter ? (s1>s2) : (s2>s1));
           }
+
+
+                                         /**
+                                          * Comparison operator for dim==1
+                                          * where this function makes no sense
+                                          */
+        template <class DHCellIterator>
+        bool compare (const DHCellIterator& c1,
+                     const DHCellIterator& c2,
+                     dealii::internal::int2type<1>) const
+         {
+           Assert (dim >= 2,
+                   ExcMessage ("This operation only makes sense for dim>=2."));
+           return false;
+          }
+
     };
   }
 

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.