From: kronbichler Date: Wed, 9 Apr 2014 08:42:47 +0000 (+0000) Subject: Cleanup TableBase implementation from internal AlignedVectorSet/Move functions X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa45e5d1fa517fbd37e7bd78a54c8d4b86fa9879;p=dealii-svn.git Cleanup TableBase implementation from internal AlignedVectorSet/Move functions git-svn-id: https://svn.dealii.org/trunk@32745 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/base/aligned_vector.h b/deal.II/include/deal.II/base/aligned_vector.h index c73f58f662..54540bf352 100644 --- a/deal.II/include/deal.II/base/aligned_vector.h +++ b/deal.II/include/deal.II/base/aligned_vector.h @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include @@ -152,6 +154,11 @@ public: void insert_back (ForwardIterator begin, ForwardIterator end); + /** + * Fills the vector with size() copies of the given input + */ + void fill (const T &element); + /** * Swaps the given vector with the calling vector. */ @@ -211,6 +218,22 @@ public: */ size_type memory_consumption () const; + /** + * Write the data of this object to + * a stream for the purpose of serialization. + */ + template + void save (Archive &ar, const unsigned int version) const; + + /** + * Read the data of this object + * from a stream for the purpose of serialization. + */ + template + void load (Archive &ar, const unsigned int version); + + BOOST_SERIALIZATION_SPLIT_MEMBER() + private: /** @@ -444,7 +467,7 @@ inline AlignedVector& AlignedVector::operator = (const AlignedVector &vec) { - clear(); + resize(0); resize_fast (vec._end_data - vec._data); internal::AlignedVectorMove (vec._data, vec._end_data, _data, true); return *this; @@ -480,8 +503,7 @@ AlignedVector::resize (const size_type size_in, // now _size is set correctly, need to set the // values if (size_in > old_size) - internal::AlignedVectorSet (size_in-old_size, init, - _data+old_size); + internal::AlignedVectorSet (size_in-old_size, init, _data+old_size); } @@ -619,6 +641,16 @@ AlignedVector::insert_back (ForwardIterator begin, +template < class T > +inline +void +AlignedVector::fill (const T &value) +{ + internal::AlignedVectorSet (size(), value, _data); +} + + + template < class T > inline void @@ -723,6 +755,39 @@ AlignedVector::end () const +template < class T > +template < class Archive > +inline +void +AlignedVector::save (Archive &ar, const unsigned int) const +{ + size_type vec_size (size()); + ar &vec_size; + if (vec_size > 0) + ar &boost::serialization::make_array(_data, vec_size); +} + + + +template < class T > +template < class Archive > +inline +void +AlignedVector::load (Archive &ar, const unsigned int) +{ + size_type vec_size = 0; + ar &vec_size ; + + if (vec_size > 0) + { + reserve(vec_size); + ar &boost::serialization::make_array(_data, vec_size); + _end_data = _data + vec_size; + } +} + + + template < class T > inline typename AlignedVector::size_type diff --git a/deal.II/include/deal.II/base/table.h b/deal.II/include/deal.II/base/table.h index fd22fece79..af4aa8d9f4 100644 --- a/deal.II/include/deal.II/base/table.h +++ b/deal.II/include/deal.II/base/table.h @@ -1922,12 +1922,8 @@ TableBase::TableBase (const TableBase &src) : Subscriptor () { - reinit (src.table_size); - if (src.n_elements() != 0) - internal::AlignedVectorMove (const_cast(src.values.begin()), - const_cast(src.values.end()), - values.begin(), - true); + values = src.values; + reinit (src.table_size, true); } @@ -2116,12 +2112,9 @@ inline TableBase & TableBase::operator = (const TableBase &m) { - reinit (m.size()); - if (!empty()) - internal::AlignedVectorMove (const_cast(m.values.begin()), - const_cast(m.values.end()), - values.begin(), - true); + if (!m.empty()) + values = m.values; + reinit (m.size(), true); return *this; } @@ -2160,8 +2153,7 @@ TableBase::reset_values () { // use parallel set operation if (n_elements() != 0) - dealii::internal::AlignedVectorSet (values.size(), T(), - values.begin()); + values.fill(T()); } @@ -2172,8 +2164,7 @@ void TableBase::fill (const T &value) { if (n_elements() != 0) - dealii::internal::AlignedVectorSet (values.size(), value, - values.begin()); + values.fill(value); } @@ -2206,8 +2197,7 @@ TableBase::reinit (const TableIndices &new_sizes, // not fast resize, zero out all values) values.resize_fast (new_size); if (!fast) - dealii::internal::AlignedVectorSet (values.size(), T(), - values.begin()); + values.fill(T()); }