]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Making the next_free_pair_object and next_free_single_object as inline functions. 192/head
authorVijay Mahadevan <vijay.m@gmail.com>
Thu, 9 Oct 2014 16:47:34 +0000 (11:47 -0500)
committerVijay Mahadevan <vijay.m@gmail.com>
Thu, 9 Oct 2014 16:47:34 +0000 (11:47 -0500)
Also contains a patch from Wolfgang with changes to the instantiation file.

Background: In release mode, GNU-4.8.x (OSX) seem to optimize away the calls when
specializing the template functions and then symbol definitions seem to be different
between debug and optimized modes. This causes undefined linkage for release mode.

References:
[1] https://groups.google.com/forum/#!topic/dealii/c2qjAsuJ7Mc
[2] https://code.google.com/p/dealii/issues/detail?id=137
[3] https://groups.google.com/forum/#!msg/dealii/6RXRR-iac0Y/Tjzwg1rFRMQJ

include/deal.II/grid/tria_objects.h
source/grid/tria_objects.cc
source/grid/tria_objects.inst.in

index 7a31f80665c660c3b89dc8d8349120da7b6f2efb..8b377e42b4a332f77c05cd4f041805e627aeb04a 100644 (file)
@@ -943,6 +943,84 @@ namespace internal
     }
 
 
+//----------------------------------------------------------------------//
+
+    template <class G>
+    template <int dim, int spacedim>
+    dealii::TriaRawIterator<dealii::TriaAccessor<G::dimension,dim,spacedim> >
+    TriaObjects<G>::next_free_single_object (const dealii::Triangulation<dim,spacedim> &tria)
+    {
+      // TODO: Think of a way to ensure that we are using the correct triangulation, i.e. the one containing *this.
+
+      int pos=next_free_single,
+          last=used.size()-1;
+      if (!reverse_order_next_free_single)
+        {
+          // first sweep forward, only use really single slots, do not use
+          // pair slots
+          for (; pos<last; ++pos)
+            if (!used[pos])
+              if (used[++pos])
+                {
+                  // this was a single slot
+                  pos-=1;
+                  break;
+                }
+          if (pos>=last)
+            {
+              reverse_order_next_free_single=true;
+              next_free_single=used.size()-1;
+              pos=used.size()-1;
+            }
+          else
+            next_free_single=pos+1;
+        }
+      else
+        {
+          // second sweep, use all slots, even
+          // in pairs
+          for (; pos>=0; --pos)
+            if (!used[pos])
+              break;
+          if (pos>0)
+            next_free_single=pos-1;
+          else
+            // no valid single object anymore
+            return dealii::TriaRawIterator<dealii::TriaAccessor<G::dimension,dim,spacedim> >(&tria, -1, -1);
+        }
+
+      return dealii::TriaRawIterator<dealii::TriaAccessor<G::dimension,dim,spacedim> >(&tria, 0, pos);
+    }
+
+
+
+    template <class G>
+    template <int dim, int spacedim>
+    dealii::TriaRawIterator<dealii::TriaAccessor<G::dimension,dim,spacedim> >
+    TriaObjects<G>::next_free_pair_object (const dealii::Triangulation<dim,spacedim> &tria)
+    {
+      // TODO: Think of a way to ensure that we are using the correct triangulation, i.e. the one containing *this.
+
+      int pos=next_free_pair,
+          last=used.size()-1;
+      for (; pos<last; ++pos)
+        if (!used[pos])
+          if (!used[++pos])
+            {
+              // this was a pair slot
+              pos-=1;
+              break;
+            }
+      if (pos>=last)
+        // no free slot
+        return dealii::TriaRawIterator<dealii::TriaAccessor<G::dimension,dim,spacedim> >(&tria, -1, -1);
+      else
+        next_free_pair=pos+2;
+
+      return dealii::TriaRawIterator<dealii::TriaAccessor<G::dimension,dim,spacedim> >(&tria, 0, pos);
+    }
+
+
 
 // declaration of explicit specializations
 
index a9326bbd4a06bdaed2333e58a4388cba3b5bb749..c97a265243f2a9ddf5db9b1e1831146f3ce3ad0f 100644 (file)
@@ -30,83 +30,6 @@ namespace internal
 {
   namespace Triangulation
   {
-    template <class G>
-    template <int dim, int spacedim>
-    dealii::TriaRawIterator<dealii::TriaAccessor<G::dimension,dim,spacedim> >
-    TriaObjects<G>::next_free_single_object (const dealii::Triangulation<dim,spacedim> &tria)
-    {
-      // TODO: Think of a way to ensure that we are using the correct triangulation, i.e. the one containing *this.
-
-      int pos=next_free_single,
-          last=used.size()-1;
-      if (!reverse_order_next_free_single)
-        {
-          // first sweep forward, only use really single slots, do not use
-          // pair slots
-          for (; pos<last; ++pos)
-            if (!used[pos])
-              if (used[++pos])
-                {
-                  // this was a single slot
-                  pos-=1;
-                  break;
-                }
-          if (pos>=last)
-            {
-              reverse_order_next_free_single=true;
-              next_free_single=used.size()-1;
-              pos=used.size()-1;
-            }
-          else
-            next_free_single=pos+1;
-        }
-
-      if (reverse_order_next_free_single)
-        {
-          // second sweep, use all slots, even
-          // in pairs
-          for (; pos>=0; --pos)
-            if (!used[pos])
-              break;
-          if (pos>0)
-            next_free_single=pos-1;
-          else
-            // no valid single object anymore
-            return dealii::TriaRawIterator<dealii::TriaAccessor<G::dimension,dim,spacedim> >(&tria, -1, -1);
-        }
-
-      return dealii::TriaRawIterator<dealii::TriaAccessor<G::dimension,dim,spacedim> >(&tria, 0, pos);
-    }
-
-
-
-    template <class G>
-    template <int dim, int spacedim>
-    dealii::TriaRawIterator<dealii::TriaAccessor<G::dimension,dim,spacedim> >
-    TriaObjects<G>::next_free_pair_object (const dealii::Triangulation<dim,spacedim> &tria)
-    {
-      // TODO: Think of a way to ensure that we are using the correct triangulation, i.e. the one containing *this.
-
-      int pos=next_free_pair,
-          last=used.size()-1;
-      for (; pos<last; ++pos)
-        if (!used[pos])
-          if (!used[++pos])
-            {
-              // this was a pair slot
-              pos-=1;
-              break;
-            }
-      if (pos>=last)
-        // no free slot
-        return dealii::TriaRawIterator<dealii::TriaAccessor<G::dimension,dim,spacedim> >(&tria, -1, -1);
-      else
-        next_free_pair=pos+2;
-
-      return dealii::TriaRawIterator<dealii::TriaAccessor<G::dimension,dim,spacedim> >(&tria, 0, pos);
-    }
-
-
     template<class G>
     void
     TriaObjects<G>::reserve_space (const unsigned int new_objects_in_pairs,
index f8b062f109c9ec2991526624e39fd5acaf92e5b9..b1dd64061d9078f1104f8149a8c10f2ce7943f7f 100644 (file)
 for (deal_II_dimension : DIMENSIONS)
   {
 #if deal_II_dimension >= 2
-    template dealii::TriaRawIterator<dealii::TriaAccessor<1,deal_II_dimension,deal_II_dimension> >
+    template dealii::TriaRawIterator<dealii::TriaAccessor<TriaObject<1>::dimension,deal_II_dimension,deal_II_dimension> >
     TriaObjects<TriaObject<1> >::next_free_single_object (const dealii::Triangulation<deal_II_dimension> &tria);
-    template dealii::TriaRawIterator<dealii::TriaAccessor<1,deal_II_dimension,deal_II_dimension> >
+    template dealii::TriaRawIterator<dealii::TriaAccessor<TriaObject<1>::dimension,deal_II_dimension,deal_II_dimension> >
     TriaObjects<TriaObject<1> >::next_free_pair_object (const dealii::Triangulation<deal_II_dimension> &tria);
-    template dealii::TriaRawIterator<dealii::TriaAccessor<2,deal_II_dimension,deal_II_dimension> >
+    template dealii::TriaRawIterator<dealii::TriaAccessor<TriaObject<2>::dimension,deal_II_dimension,deal_II_dimension> >
     TriaObjects<TriaObject<2> >::next_free_single_object (const dealii::Triangulation<deal_II_dimension> &tria);
-    template dealii::TriaRawIterator<dealii::TriaAccessor<2,deal_II_dimension,deal_II_dimension> >
+    template dealii::TriaRawIterator<dealii::TriaAccessor<TriaObject<2>::dimension,deal_II_dimension,deal_II_dimension> >
     TriaObjects<TriaObject<2> >::next_free_pair_object (const dealii::Triangulation<deal_II_dimension> &tria);
 #endif
 
 #if deal_II_dimension >= 3
-    template dealii::TriaRawIterator<dealii::TriaAccessor<3,deal_II_dimension,deal_II_dimension> >
+    template dealii::TriaRawIterator<dealii::TriaAccessor<TriaObject<3>::dimension,deal_II_dimension,deal_II_dimension> >
     TriaObjects<TriaObject<3> >::next_free_single_object (const dealii::Triangulation<deal_II_dimension> &tria);
-    template dealii::TriaRawIterator<dealii::TriaAccessor<3,deal_II_dimension,deal_II_dimension> >
+    template dealii::TriaRawIterator<dealii::TriaAccessor<TriaObject<3>::dimension,deal_II_dimension,deal_II_dimension> >
     TriaObjects<TriaObject<3> >::next_free_pair_object (const dealii::Triangulation<deal_II_dimension> &tria);
 
     template dealii::Triangulation<deal_II_dimension>::raw_hex_iterator

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.