From: rao Date: Wed, 6 Oct 2010 12:44:38 +0000 (+0000) Subject: Add functions for serialization. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb4a379140c45aec1dc7b55ad06b5f6660e9150d;p=dealii-svn.git Add functions for serialization. git-svn-id: https://svn.dealii.org/trunk@22264 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/point.h b/deal.II/base/include/base/point.h index 9daa0aea61..e2afd834e8 100644 --- a/deal.II/base/include/base/point.h +++ b/deal.II/base/include/base/point.h @@ -177,6 +177,13 @@ class Point : public Tensor<1,dim> * representing the two points. */ double distance (const Point &p) const; + + /** + * Read or write the data of this object to or + * from a stream for the purpose of serialization + */ + template + void serialize(Archive & ar, const unsigned int version); }; /*------------------------------- Inline functions: Point ---------------------------*/ @@ -342,6 +349,18 @@ Point Point::operator / (const double factor) const return (Point(*this) /= factor); } + +template +template +inline +void +Point::serialize(Archive & ar, const unsigned int) +{ + // forward to serialization + // function in the base class + ar & static_cast &>(*this); +} + #endif // DOXYGEN diff --git a/deal.II/base/include/base/symmetric_tensor.h b/deal.II/base/include/base/symmetric_tensor.h index 6d45f7f9d9..5196f2698d 100644 --- a/deal.II/base/include/base/symmetric_tensor.h +++ b/deal.II/base/include/base/symmetric_tensor.h @@ -968,7 +968,13 @@ class SymmetricTensor */ static unsigned int memory_consumption (); - + /** + * Read or write the data of this object to or + * from a stream for the purpose of serialization + */ + template + void serialize(Archive & ar, const unsigned int version); + private: /** * A structure that describes @@ -2136,7 +2142,14 @@ SymmetricTensor<2,3>::unrolled_to_component_indices (const unsigned int i) return table[i]; } - +template +template +inline +void +SymmetricTensor::serialize(Archive & ar, const unsigned int) +{ + ar & data; +} #endif // DOXYGEN diff --git a/deal.II/base/include/base/tensor.h b/deal.II/base/include/base/tensor.h index 95553ae6c3..d0950abdb1 100644 --- a/deal.II/base/include/base/tensor.h +++ b/deal.II/base/include/base/tensor.h @@ -243,6 +243,13 @@ class Tensor int, << "Invalid tensor index " << arg1); + /** + * Read or write the data of this object to or + * from a stream for the purpose of serialization + */ + template + void serialize(Archive & ar, const unsigned int version); + private: /** * Array of tensors holding the @@ -488,6 +495,15 @@ Tensor::memory_consumption () return sizeof(Tensor); } +template +template +inline +void +Tensor::serialize(Archive & ar, const unsigned int) +{ + ar & subtensor; +} + #endif // DOXYGEN /* ----------------- Non-member functions operating on tensors. ------------ */ diff --git a/deal.II/base/include/base/tensor_base.h b/deal.II/base/include/base/tensor_base.h index 103c6fe14c..0a1c4bb63d 100644 --- a/deal.II/base/include/base/tensor_base.h +++ b/deal.II/base/include/base/tensor_base.h @@ -266,6 +266,13 @@ class Tensor<0,dim> int, << "dim must be positive, but was " << arg1); + /** + * Read or write the data of this object to or + * from a stream for the purpose of serialization + */ + template + void serialize(Archive & ar, const unsigned int version); + private: /** * The value of this scalar object. @@ -548,8 +555,16 @@ class Tensor<1,dim> DeclException1 (ExcDimTooSmall, int, << "dim must be positive, but was " << arg1); + + /** + * Read or write the data of this object to or + * from a stream for the purpose of serialization + */ + template + void serialize(Archive & ar, const unsigned int version); + private: - /** + /** * Store the values in a simple * array. For dim==0 store * one element, because otherways @@ -811,6 +826,13 @@ void Tensor<0,dim>::clear () value = 0; } +template +template +inline +void Tensor<0,dim>::serialize(Archive & ar, const unsigned int) +{ + ar & value; +} /*---------------------------- Inline functions: Tensor<1,dim> ------------------------*/ @@ -1175,6 +1197,13 @@ Tensor<1,dim>::memory_consumption () } +template +template +inline +void Tensor<1,dim>::serialize(Archive & ar, const unsigned int) +{ + ar & values; +} #endif // DOXYGEN