From 1d327fd1dcd34023a3d5bb2c0ee7524593d44015 Mon Sep 17 00:00:00 2001 From: Vijay Mahadevan Date: Thu, 9 Oct 2014 11:47:34 -0500 Subject: [PATCH] Making the next_free_pair_object and next_free_single_object as inline functions. 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 | 78 +++++++++++++++++++++++++++++ source/grid/tria_objects.cc | 77 ---------------------------- source/grid/tria_objects.inst.in | 12 ++--- 3 files changed, 84 insertions(+), 83 deletions(-) diff --git a/include/deal.II/grid/tria_objects.h b/include/deal.II/grid/tria_objects.h index 7a31f80665..8b377e42b4 100644 --- a/include/deal.II/grid/tria_objects.h +++ b/include/deal.II/grid/tria_objects.h @@ -943,6 +943,84 @@ namespace internal } +//----------------------------------------------------------------------// + + template + template + dealii::TriaRawIterator > + TriaObjects::next_free_single_object (const dealii::Triangulation &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) + { + 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 >(&tria, -1, -1); + } + + return dealii::TriaRawIterator >(&tria, 0, pos); + } + + + + template + template + dealii::TriaRawIterator > + TriaObjects::next_free_pair_object (const dealii::Triangulation &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) + // no free slot + return dealii::TriaRawIterator >(&tria, -1, -1); + else + next_free_pair=pos+2; + + return dealii::TriaRawIterator >(&tria, 0, pos); + } + + // declaration of explicit specializations diff --git a/source/grid/tria_objects.cc b/source/grid/tria_objects.cc index a9326bbd4a..c97a265243 100644 --- a/source/grid/tria_objects.cc +++ b/source/grid/tria_objects.cc @@ -30,83 +30,6 @@ namespace internal { namespace Triangulation { - template - template - dealii::TriaRawIterator > - TriaObjects::next_free_single_object (const dealii::Triangulation &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) - { - 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 >(&tria, -1, -1); - } - - return dealii::TriaRawIterator >(&tria, 0, pos); - } - - - - template - template - dealii::TriaRawIterator > - TriaObjects::next_free_pair_object (const dealii::Triangulation &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) - // no free slot - return dealii::TriaRawIterator >(&tria, -1, -1); - else - next_free_pair=pos+2; - - return dealii::TriaRawIterator >(&tria, 0, pos); - } - - template void TriaObjects::reserve_space (const unsigned int new_objects_in_pairs, diff --git a/source/grid/tria_objects.inst.in b/source/grid/tria_objects.inst.in index f8b062f109..b1dd64061d 100644 --- a/source/grid/tria_objects.inst.in +++ b/source/grid/tria_objects.inst.in @@ -17,20 +17,20 @@ for (deal_II_dimension : DIMENSIONS) { #if deal_II_dimension >= 2 - template dealii::TriaRawIterator > + template dealii::TriaRawIterator::dimension,deal_II_dimension,deal_II_dimension> > TriaObjects >::next_free_single_object (const dealii::Triangulation &tria); - template dealii::TriaRawIterator > + template dealii::TriaRawIterator::dimension,deal_II_dimension,deal_II_dimension> > TriaObjects >::next_free_pair_object (const dealii::Triangulation &tria); - template dealii::TriaRawIterator > + template dealii::TriaRawIterator::dimension,deal_II_dimension,deal_II_dimension> > TriaObjects >::next_free_single_object (const dealii::Triangulation &tria); - template dealii::TriaRawIterator > + template dealii::TriaRawIterator::dimension,deal_II_dimension,deal_II_dimension> > TriaObjects >::next_free_pair_object (const dealii::Triangulation &tria); #endif #if deal_II_dimension >= 3 - template dealii::TriaRawIterator > + template dealii::TriaRawIterator::dimension,deal_II_dimension,deal_II_dimension> > TriaObjects >::next_free_single_object (const dealii::Triangulation &tria); - template dealii::TriaRawIterator > + template dealii::TriaRawIterator::dimension,deal_II_dimension,deal_II_dimension> > TriaObjects >::next_free_pair_object (const dealii::Triangulation &tria); template dealii::Triangulation::raw_hex_iterator -- 2.39.5