]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add functions for serialization.
authorrao <rao@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 6 Oct 2010 12:44:38 +0000 (12:44 +0000)
committerrao <rao@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 6 Oct 2010 12:44:38 +0000 (12:44 +0000)
git-svn-id: https://svn.dealii.org/trunk@22264 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/point.h
deal.II/base/include/base/symmetric_tensor.h
deal.II/base/include/base/tensor.h
deal.II/base/include/base/tensor_base.h

index 9daa0aea61f673465a9ac3dfbb7fe45dfac89fcf..e2afd834e8883fadfdceb9e63343092608331c77 100644 (file)
@@ -177,6 +177,13 @@ class Point : public Tensor<1,dim>
                                      * representing the two points.
                                      */
     double distance (const Point<dim> &p) const;
+
+                     /**
+                      * Read or write the data of this object to or 
+                      * from a stream for the purpose of serialization
+                      */ 
+    template <class Archive>
+    void serialize(Archive & ar, const unsigned int version);
 };
 
 /*------------------------------- Inline functions: Point ---------------------------*/
@@ -342,6 +349,18 @@ Point<dim> Point<dim>::operator / (const double factor) const
   return (Point<dim>(*this) /= factor);
 }
 
+
+template <int dim>
+template <class Archive>
+inline
+void 
+Point<dim>::serialize(Archive & ar, const unsigned int)
+{
+                                     // forward to serialization
+                                     // function in the base class
+  ar &  static_cast<Tensor<1,dim> &>(*this);
+}
+
 #endif // DOXYGEN
 
 
index 6d45f7f9d98a95c9745ab833ac451f34b2bfc73b..5196f2698d3ab75f9a68b26d5d91f78554d618fb 100644 (file)
@@ -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 <class Archive>
+    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 <int rank, int dim>
+template <class Archive>
+inline    
+void 
+SymmetricTensor<rank,dim>::serialize(Archive & ar, const unsigned int)
+{
+  ar & data;
+} 
 
 
 #endif // DOXYGEN
index 95553ae6c3f69d7d9355592493ec577b4bf92de6..d0950abdb1ccbcda8d91e66411ed03665d058496 100644 (file)
@@ -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 <class Archive>
+    void serialize(Archive & ar, const unsigned int version);
+
   private:
                                     /**
                                      * Array of tensors holding the
@@ -488,6 +495,15 @@ Tensor<rank_,dim>::memory_consumption ()
   return sizeof(Tensor<rank_,dim>);
 }
 
+template <int rank_, int dim>
+template <class Archive>
+inline
+void 
+Tensor<rank_,dim>::serialize(Archive & ar, const unsigned int)
+{
+  ar & subtensor;
+}    
+
 #endif // DOXYGEN
 /* ----------------- Non-member functions operating on tensors. ------------ */
 
index 103c6fe14c98c9d9ce9052666ecfc695d058e7c6..0a1c4bb63decdc44f211572d1184334a3596cf0c 100644 (file)
@@ -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 <class Archive>
+    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 <class Archive>
+    void serialize(Archive & ar, const unsigned int version);
+    
   private:
-                                    /**
+                                    /**
                                      * Store the values in a simple
                                      * array.  For <tt>dim==0</tt> store
                                      * one element, because otherways
@@ -811,6 +826,13 @@ void Tensor<0,dim>::clear ()
   value = 0;
 }
 
+template <int dim>
+template <class Archive>
+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 <int dim>
+template <class Archive>
+inline
+void Tensor<1,dim>::serialize(Archive & ar, const unsigned int)
+{
+  ar & values;
+}
 #endif // DOXYGEN
 
 

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.