LCOV - code coverage report
Current view: top level - ugbase/lib_grid/algorithms - serialization.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 26 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 270 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2009-2015:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Sebastian Reiter
       4              :  * 
       5              :  * This file is part of UG4.
       6              :  * 
       7              :  * UG4 is free software: you can redistribute it and/or modify it under the
       8              :  * terms of the GNU Lesser General Public License version 3 (as published by the
       9              :  * Free Software Foundation) with the following additional attribution
      10              :  * requirements (according to LGPL/GPL v3 §7):
      11              :  * 
      12              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      13              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      14              :  * 
      15              :  * (2) The following notice must be displayed at a prominent place in the
      16              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      17              :  * 
      18              :  * (3) The following bibliography is recommended for citation and must be
      19              :  * preserved in all covered files:
      20              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      21              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      22              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      23              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      24              :  *   flexible software system for simulating pde based models on high performance
      25              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      26              :  * 
      27              :  * This program is distributed in the hope that it will be useful,
      28              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      29              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      30              :  * GNU Lesser General Public License for more details.
      31              :  */
      32              : 
      33              : #ifndef __H__LIB_GRID__SERIALIZATION__
      34              : #define __H__LIB_GRID__SERIALIZATION__
      35              : 
      36              : #include <iostream>
      37              : #include "common/util/smart_pointer.h"
      38              : #include "common/util/binary_buffer.h"
      39              : #include "common/serialization.h"
      40              : #include "lib_grid/grid_objects/grid_objects.h"
      41              : #include "lib_grid/tools/subset_handler_interface.h"
      42              : #include "lib_grid/tools/selector_interface.h"
      43              : #include "lib_grid/multi_grid.h"
      44              : #include "lib_grid/common_attachments.h"
      45              : #include "lib_grid/algorithms/attachment_util.h"
      46              : #include "lib_grid/parallelization/grid_object_id.h"
      47              : // #include "lib_grid/refinement/projectors/refinement_projector.h"
      48              : // #include "lib_grid/refinement/projectors/projection_handler.h"
      49              : 
      50              : namespace ug
      51              : {
      52              : 
      53              : /**
      54              :  * Methods that perform grid-related serialization are grouped here.
      55              :  * \defgroup lib_grid_algorithms_serialization serialization
      56              :  * \ingroup lib_grid_algorithms
      57              :  * @{
      58              :  */
      59              : 
      60              : ////////////////////////////////////////////////////////////////////////
      61              : //      Utilities
      62              : 
      63              : /**     \brief  Interface for handling serialization and deserialization of
      64              :  *                      data associated with geometric objects.
      65              :  *
      66              :  * The GeomObjDataSerializer allows to serialize data associated with
      67              :  * geometric objects. Before the data will be serialized, write_info is
      68              :  * called. Accordingly read_info is called before data is deserialized.
      69              :  *
      70              :  * Note that this class handles serialization and deserialization at once.
      71              :  *
      72              :  * Make sure to completely read all data written by the associated write calls.
      73              :  *
      74              :  * Note that the following typedefs exist: VertexDataSerializer,
      75              :  * EdgeDataSerializer, FaceDataSerializer, VolumeDataSerializer.
      76              :  *
      77              :  * If one wants to serialize data of all objects in a grid, he should
      78              :  * take a look at GridDataSerializer.
      79              :  *
      80              :  * If you call read_info and/or read_data directly, make sure to also call
      81              :  * deserialization_done after deserialization has been performed for all
      82              :  * geometric objects.
      83              :  */
      84              : template <class TGeomObj>
      85              : class GeomObjDataSerializer
      86              : {
      87              :         public:
      88              :                 virtual ~GeomObjDataSerializer()        {}
      89              : 
      90              :         ///     can be used to write arbitrary info to the file.
      91              :         /**     Make sure to read everything you've written during read_data.
      92              :          * Default implementation is empty.*/
      93            0 :                 virtual void write_info(BinaryBuffer& out) const {};
      94              :         ///     write data associated with the given object. Pure virtual.
      95              :                 virtual void write_data(BinaryBuffer& out, TGeomObj* o) const = 0;
      96              : 
      97              :         ///     Read the info written during write_info here. Default: empty implementation.
      98            0 :                 virtual void read_info(BinaryBuffer& in)    {};
      99              :         ///     read data associated with the given object. Pure virtual.
     100              :                 virtual void read_data(BinaryBuffer& in, TGeomObj* o) = 0;
     101              : 
     102              :         ///     this method is called after read_info has been called for all geometric objects.
     103            0 :                 virtual void deserialization_starts()                                   {}
     104              : 
     105              :         ///     this method will be called after read_info has been called for all geometric objects.
     106            0 :                 virtual void deserialization_done()                                             {}
     107              : };
     108              : 
     109              : typedef GeomObjDataSerializer<Vertex>     VertexDataSerializer;
     110              : typedef GeomObjDataSerializer<Edge>               EdgeDataSerializer;
     111              : typedef GeomObjDataSerializer<Face>                       FaceDataSerializer;
     112              : typedef GeomObjDataSerializer<Volume>             VolumeDataSerializer;
     113              : 
     114              : typedef SmartPtr<VertexDataSerializer>    SPVertexDataSerializer;
     115              : typedef SmartPtr<EdgeDataSerializer>      SPEdgeDataSerializer;
     116              : typedef SmartPtr<FaceDataSerializer>      SPFaceDataSerializer;
     117              : typedef SmartPtr<VolumeDataSerializer>    SPVolumeDataSerializer;
     118              : 
     119              : /**     \brief  Interface for handling serialization and deserialization of
     120              :  *                      data associated with all geometric objects in a grid.
     121              :  *
     122              :  * The GridDataSerializer allows to serialize data associated with
     123              :  * all geometric objects in a grid. Before the data will be serialized,
     124              :  * write_info is called. Accordingly read_info is called before data is
     125              :  * deserialized.
     126              :  *
     127              :  * Note that this class handles serialization and deserialization at once.
     128              :  *
     129              :  * Make sure to completely read all data written by the associated write calls.
     130              :  *
     131              :  * All methods have an empty implementation by default.
     132              :  *
     133              :  * If you call read_info and/or read_data directly, make sure to also call
     134              :  * deserialization_done after deserialization has been performed for all
     135              :  * geometric objects.
     136              :  */
     137              : class GridDataSerializer
     138              : {
     139              :         public:
     140            0 :                 virtual ~GridDataSerializer()   {}
     141              : 
     142              :         ///     can be used to write arbitrary info to the file.
     143              :         /**     Make sure to read everything you've written during read_data.
     144              :          * Default implementation is empty.*/
     145            0 :                 virtual void write_info(BinaryBuffer& out) const                            {}
     146              : 
     147              :         ///     Read the info written during write_info here. Default: empty implementation.
     148            0 :                 virtual void read_info(BinaryBuffer& in)                                    {}
     149              : 
     150            0 :                 virtual void write_data(BinaryBuffer& out, Vertex* o) const {}
     151            0 :                 virtual void write_data(BinaryBuffer& out, Edge* o) const   {}
     152            0 :                 virtual void write_data(BinaryBuffer& out, Face* o) const           {}
     153            0 :                 virtual void write_data(BinaryBuffer& out, Volume* o) const         {}
     154              : 
     155            0 :                 virtual void read_data(BinaryBuffer& in, Vertex* o) {}
     156            0 :                 virtual void read_data(BinaryBuffer& in, Edge* o)   {}
     157            0 :                 virtual void read_data(BinaryBuffer& in, Face* o)           {}
     158            0 :                 virtual void read_data(BinaryBuffer& in, Volume* o)         {}
     159              : 
     160              :         ///     this method is called after read_info has been called for all geometric objects.
     161            0 :                 virtual void deserialization_starts()                                   {}
     162              : 
     163              :         ///     this method is called after read_info has been called for all geometric objects.
     164            0 :                 virtual void deserialization_done()                                             {}
     165              : };
     166              : 
     167              : typedef SmartPtr<GridDataSerializer>      SPGridDataSerializer;
     168              : 
     169              : 
     170              : ///     Serialization of data associated with grid elements.
     171              : /**     Through the add-method callback-classes can be registered,
     172              :  * which will be called during serialization and deserialization to
     173              :  * write data associated with the given elements into a binary stream.
     174              :  *
     175              :  * Note when data for a given object-type not only registered
     176              :  * callback classes for the type are called, but also registered
     177              :  * instances of GridDataSerializer.
     178              :  *
     179              :  * Note that this class performs both serialization and deserialization.
     180              :  *
     181              :  * If you call the deserialize method directly, make sure to also call
     182              :  * deserialization_done after your last call to deserialize for a given
     183              :  * dezerialization.
     184              :  */
     185              : class GridDataSerializationHandler
     186              : {
     187              :         public:
     188              :                 ~GridDataSerializationHandler() {}
     189              : 
     190              :         ///     Adds a callback class for serialization and deserialization.
     191              :         /**     \{ */
     192              :                 void add(SPVertexDataSerializer cb);
     193              :                 void add(SPEdgeDataSerializer cb);
     194              :                 void add(SPFaceDataSerializer cb);
     195              :                 void add(SPVolumeDataSerializer cb);
     196              :                 void add(SPGridDataSerializer cb);
     197              :         /**     \} */
     198              : 
     199              : 
     200              :         ///     calls write_info on all registered serializers
     201              :                 void write_infos(BinaryBuffer& out) const;
     202              : 
     203              :         /**     \{
     204              :          * \brief Serializes data associated with the given object.*/
     205              :                 inline void serialize(BinaryBuffer& out, Vertex* vrt) const;
     206              :                 inline void serialize(BinaryBuffer& out, Edge* edge) const;
     207              :                 inline void serialize(BinaryBuffer& out, Face* face) const;
     208              :                 inline void serialize(BinaryBuffer& out, Volume* vol) const;
     209              :         /**     \} */
     210              : 
     211              :         ///     Calls serialize on all elements between begin and end.
     212              :         /**     Make sure that TIterator::value_type is compatible with
     213              :          * either Vertex*, Edge*, Face*, Volume*.*/
     214              :                 template <class TIterator>
     215              :                 void serialize(BinaryBuffer& out, TIterator begin, TIterator end) const;
     216              : 
     217              :         ///     Calls serialize on all elements in the given geometric object collection
     218              :                 void serialize(BinaryBuffer& out, GridObjectCollection goc) const;
     219              : 
     220              :         ///     calls read_info on all registered serializers
     221              :                 void read_infos(BinaryBuffer& in);
     222              : 
     223              :         /**     \{
     224              :          * \brief Deserializes data associated with the given object.*/
     225              :                 inline void deserialize(BinaryBuffer& in, Vertex* vrt);
     226              :                 inline void deserialize(BinaryBuffer& in, Edge* edge);
     227              :                 inline void deserialize(BinaryBuffer& in, Face* face);
     228              :                 inline void deserialize(BinaryBuffer& in, Volume* vol);
     229              :         /**     \} */
     230              : 
     231              :         ///     Calls deserialize on all elements between begin and end.
     232              :         /**     Make sure that TIterator::value_type is compatible with
     233              :          * either Vertex*, Edge*, Face*, Volume*.*/
     234              :                 template <class TIterator>
     235              :                 void deserialize(BinaryBuffer& in, TIterator begin, TIterator end);
     236              : 
     237              :         ///     Calls deserialize on all elements in the given geometric object collection
     238              :                 void deserialize(BinaryBuffer& in, GridObjectCollection goc);
     239              : 
     240              :         ///     this method will be called before read_infos is called for the first time
     241              :         ///     in a deserialization run.
     242              :                 void deserialization_starts();
     243              : 
     244              :         ///     this method will be called after deserialize was called for the last time
     245              :         ///     in a deserialization run.
     246              :                 void deserialization_done();
     247              : 
     248              :         private:
     249              :         ///     performs serialization on all given serializers.
     250              :                 template<class TGeomObj, class TSerializers>
     251              :                 void serialize(BinaryBuffer& out, TGeomObj* o,
     252              :                                            TSerializers& serializers) const;
     253              : 
     254              :         ///     performs deserialization on all given deserializers.
     255              :                 template<class TGeomObj, class TDeserializers>
     256              :                 void deserialize(BinaryBuffer& in, TGeomObj* o,
     257              :                                            TDeserializers& deserializers);
     258              : 
     259              :                 template<class TSerializers>
     260              :                 void write_info(BinaryBuffer& out, TSerializers& serializers) const;
     261              : 
     262              :                 template<class TSerializers>
     263              :                 void read_info(BinaryBuffer& in, TSerializers& serializers);
     264              : 
     265              :                 template<class TSerializers>
     266              :                 void deserialization_starts(TSerializers& serializers);
     267              : 
     268              :                 template<class TSerializers>
     269              :                 void deserialization_done(TSerializers& serializers);
     270              : 
     271              :         private:
     272              :                 std::vector<SPVertexDataSerializer>       m_vrtSerializers;
     273              :                 std::vector<SPEdgeDataSerializer> m_edgeSerializers;
     274              :                 std::vector<SPFaceDataSerializer> m_faceSerializers;
     275              :                 std::vector<SPVolumeDataSerializer>       m_volSerializers;
     276              :                 std::vector<SPGridDataSerializer> m_gridSerializers;
     277              : };
     278              : 
     279              : 
     280              : ////////////////////////////////////////////////////////////////////////
     281              : ///     Serialization callback for grid attachments
     282              : /**     template class where TGeomObj should be one of the
     283              :  * following types: Vertex, Edge, Face, Volume.
     284              :  *
     285              :  * Note that the attachment is automatically attached, if not yet present.
     286              :  */
     287              : template <class TGeomObj, class TAttachment>
     288              : class GeomObjAttachmentSerializer :
     289              :         public GeomObjDataSerializer<TGeomObj>
     290              : {
     291              :         public:
     292              :                 static SmartPtr<GeomObjDataSerializer<TGeomObj> >
     293            0 :                 create(Grid& g, TAttachment a)
     294            0 :                 {return SmartPtr<GeomObjDataSerializer<TGeomObj> >(new GeomObjAttachmentSerializer(g, a));}
     295              : 
     296            0 :                 GeomObjAttachmentSerializer(Grid& g, TAttachment a) :
     297            0 :                         m_aa(g, a, true)        {}
     298              : 
     299            0 :                 virtual ~GeomObjAttachmentSerializer() {};
     300              : 
     301            0 :                 virtual void write_data(BinaryBuffer& out, TGeomObj* o) const
     302            0 :                 {Serialize(out, m_aa[o]);}
     303              : 
     304            0 :                 virtual void read_data(BinaryBuffer& in, TGeomObj* o)
     305            0 :                 {Deserialize(in, m_aa[o]);}
     306              : 
     307              :         private:
     308              :                 Grid::AttachmentAccessor<TGeomObj, TAttachment>   m_aa;
     309              : };
     310              : 
     311              : class SubsetHandlerSerializer : public GridDataSerializer
     312              : {
     313              :         public:
     314              :                 static SPGridDataSerializer create(ISubsetHandler& sh)
     315              :                 {return SPGridDataSerializer(new SubsetHandlerSerializer(sh));}
     316              : 
     317              :                 SubsetHandlerSerializer(ISubsetHandler& sh);
     318              : 
     319              :         ///     writes subset-infos to the stream (subset names and colors)
     320              :                 virtual void write_info(BinaryBuffer& out) const;
     321              : 
     322              :                 ///     Read the info written during write_info here. Default: empty implementation.
     323              :                 virtual void read_info(BinaryBuffer& in);
     324              : 
     325              :                 virtual void write_data(BinaryBuffer& out, Vertex* o) const;
     326              :                 virtual void write_data(BinaryBuffer& out, Edge* o) const;
     327              :                 virtual void write_data(BinaryBuffer& out, Face* o) const;
     328              :                 virtual void write_data(BinaryBuffer& out, Volume* o) const;
     329              : 
     330              :                 virtual void read_data(BinaryBuffer& in, Vertex* o);
     331              :                 virtual void read_data(BinaryBuffer& in, Edge* o);
     332              :                 virtual void read_data(BinaryBuffer& in, Face* o);
     333              :                 virtual void read_data(BinaryBuffer& in, Volume* o);
     334              : 
     335              :         private:
     336              :                 ISubsetHandler& m_sh;
     337              : };
     338              : 
     339              : ////////////////////////////////////////////////////////////////////////
     340              : ////////////////////////////////////////////////////////////////////////
     341              : //      GRID
     342              : 
     343              : ////////////////////////////////////////////////////////////////////////
     344              : ///     Writes a part of the grids elements to a binary-stream.
     345              : /**
     346              :  * The passed GridObjectCollection goc may only reference
     347              :  * elements of the given grid. It is important, that the goc
     348              :  * is complete - that means that all referenced vertices are
     349              :  * contained in the goc.
     350              :  *
     351              :  * If you pack several different parts of your grid, you should use
     352              :  * this method, since it is faster than calling SerializeGridElements
     353              :  * without the attachment.
     354              :  *
     355              :  * the integer attachment aInt is used during this method to store
     356              :  * an index in each vertex of the goc. The initial content of
     357              :  * the referenced attachment is ignored.
     358              :  *
     359              :  * The caller is responsible to attach the aIntVRT attachment to the 
     360              :  * to the vertices of the grid before calling this method.
     361              :  * The caller is also responsible to detach aIntVRT from the grids
     362              :  * vertices when it is no longer required.
     363              :  *
     364              :  * After termination the attachment holds the indices at which
     365              :  * the respcetive vertices are stored in the pack.
     366              :  */
     367              : bool SerializeGridElements(Grid& grid, GridObjectCollection goc,
     368              :                                                    AInt& aIntVRT, BinaryBuffer& out);
     369              : 
     370              : ////////////////////////////////////////////////////////////////////////
     371              : ///     Writes all grid elements into a binary-stream.
     372              : bool SerializeGridElements(Grid& grid, BinaryBuffer& out);
     373              : 
     374              : ////////////////////////////////////////////////////////////////////////
     375              : ///     Writes a part of the grids elements to a binary-stream.
     376              : /**
     377              :  * The passed GridObjectCollection goc may only reference
     378              :  * elements of the given grid. It is important, that the goc
     379              :  * is complete - that means that all referenced vertices are
     380              :  * contained in the goc.
     381              :  *
     382              :  * If you're planning to serialize multiple parts of one grid, you
     383              :  * should consider to use the full-featured serialization method.
     384              :  */
     385              : bool SerializeGridElements(Grid& grid, GridObjectCollection goc,
     386              :                                                    BinaryBuffer& out);
     387              : 
     388              : ////////////////////////////////////////////////////////////////////////
     389              : ///     Creates grid elements from a binary stream
     390              : /**     Old versions of SerializeGrid did not support grid-headers.
     391              :  * This is why you can specify via readGridHeader whether a
     392              :  * header should be read (default is true).
     393              :  */
     394              : bool DeserializeGridElements(Grid& grid, BinaryBuffer& in,
     395              :                                                         bool readGridHeader = true);
     396              : 
     397              : 
     398              : ////////////////////////////////////////////////////////////////////////
     399              : ////////////////////////////////////////////////////////////////////////
     400              : //      MULTI-GRID
     401              : 
     402              : ////////////////////////////////////////////////////////////////////////
     403              : //      SerializeMultiGridElements
     404              : ///     writes a part of the elements of a MultiGrid to a binary stream.
     405              : /**
     406              :  * THIS METHOD USES Grid::mark.
     407              :  *
     408              :  * The passed GridObjectCollection goc may only
     409              :  * reference elements of the given grid. It is important, that the goc
     410              :  * is complete - that means that all referenced vertices are
     411              :  * contained in the goc.
     412              :  * The goc has also to be complete in regard to the multi-grid hierarchy.
     413              :  * This means that for each element of the goc, the parent has to be
     414              :  * also part of the goc.
     415              :  *
     416              :  * If you pack several different parts of your grid, you should use
     417              :  * this method, since it is faster than calling SerializeGridElements
     418              :  * without the attachment.
     419              :  *
     420              :  * the integer attachment aInt is used during this method to store
     421              :  * an index in each element of the goc. The initial content of
     422              :  * the referenced attachment is ignored.
     423              :  *
     424              :  * The caller is responsible to attach the aInt attachment to the
     425              :  * to the elements of the grid before calling this method.
     426              :  * The caller is also responsible to detach aInt from the grids
     427              :  * elements when it is no longer required.
     428              :  *
     429              :  * Optionally an accessor to global ids in mg can be specified through paaID.
     430              :  * Those ids have to be attached and correctly set before the method is called.
     431              :  * If you specify those ids, they are serialized together with the grid elements.
     432              :  * Make sure to pass a corresponding id-accessor on a call to deserialize.
     433              :  *
     434              :  * After termination the attachments hold the indices that were
     435              :  * assigned to the respective elements - starting from 0 for each
     436              :  * element type.
     437              :  *
     438              :  * \todo        add support for constrained/constraining faces
     439              :  * \todo        use ConstVertexArrays instead of virtual functions ...->vertex(...)
     440              :  */
     441              : bool SerializeMultiGridElements(MultiGrid& mg,
     442              :                                                                 GridObjectCollection goc,
     443              :                                                                 MultiElementAttachmentAccessor<AInt>& aaInt,
     444              :                                                                 BinaryBuffer& out,
     445              :                                                                 MultiElementAttachmentAccessor<AGeomObjID>* paaID = NULL);
     446              : 
     447              : ////////////////////////////////////////////////////////////////////////
     448              : //      SerializeMultiGridElements
     449              : ///     writes a part of the elements of a MultiGrid to a binary stream.
     450              : /**
     451              :  * The passed GridObjectCollection goc may only reference
     452              :  * elements of the given grid. It is important, that the goc
     453              :  * is complete - that means that all referenced vertices are
     454              :  * contained in the goc.
     455              :  * The goc has also to be complete in regard to the multi-grid hierarchy.
     456              :  * This means that for each element of the goc, the parent has to be
     457              :  * also part of the goc.
     458              :  *
     459              :  * If you're planning to serialize multiple parts of one grid, you
     460              :  * should consider to use the full-featured serialization method.
     461              :  */
     462              : bool SerializeMultiGridElements(MultiGrid& mg,
     463              :                                                                 GridObjectCollection goc,
     464              :                                                                 BinaryBuffer& out);
     465              : 
     466              : ////////////////////////////////////////////////////////////////////////
     467              : //      SerializeMultiGridElements
     468              : ///     writes the elements of a MultiGrid to a binary stream.
     469              : bool SerializeMultiGridElements(MultiGrid& mg,
     470              :                                                                 BinaryBuffer& out);
     471              :                                                                 
     472              : ////////////////////////////////////////////////////////////////////////
     473              : ///     Creates multi-grid elements from a binary stream
     474              : /**
     475              :  * If you pass a pointer to a std::vector using pvVrts, pvEdges,
     476              :  * pvFaces or pvVolumes, those vectors will contain the elements
     477              :  * of the grid in the order they were read.
     478              :  * Specifying those vectors does not lead to a performance loss.
     479              :  *
     480              :  * An accessor to global ids in the grids elements can optionally be specified
     481              :  * through paaID.
     482              :  * If it is specified, the existing grid is automatically merged with the new
     483              :  * elements based on the global ids. The accessor must only be specified if it
     484              :  * was also specified in SerializeMultiGridElements.
     485              :  *
     486              :  * \todo        add support for constrained/constraining faces
     487              :  */
     488              : bool DeserializeMultiGridElements(MultiGrid& mg, BinaryBuffer& in,
     489              :                                                                         std::vector<Vertex*>* pvVrts = NULL,
     490              :                                                                         std::vector<Edge*>* pvEdges = NULL,
     491              :                                                                         std::vector<Face*>* pvFaces = NULL,
     492              :                                                                         std::vector<Volume*>* pvVols = NULL,
     493              :                                                                         MultiElementAttachmentAccessor<AGeomObjID>* paaID = NULL);
     494              : 
     495              : 
     496              : 
     497              : ////////////////////////////////////////////////////////////////////////
     498              : ////////////////////////////////////////////////////////////////////////
     499              : //      ATTACHMENTS
     500              : 
     501              : ////////////////////////////////////////////////////////////////////////
     502              : //      copies attached values to a binary stream.
     503              : /**
     504              :  * copies attached values of the grids elements of the given type
     505              :  * to the binary stream.
     506              :  *
     507              :  * Make sure that attachment is attached to the specified elements.
     508              :  */
     509              : template <class TElem, class TAttachment>
     510              : bool SerializeAttachment(Grid& grid, TAttachment& attachment,
     511              :                                                  BinaryBuffer& out);
     512              : 
     513              : ////////////////////////////////////////////////////////////////////////
     514              : ///     copies attached values to a binary stream.
     515              : /**
     516              :  * copies attached values of the elements between iterBegin and iterEnd
     517              :  * to the binary stream.
     518              :  *
     519              :  * Make sure that attachment is attached to the specified elements.
     520              :  */
     521              : template <class TElem, class TAttachment>
     522              : bool SerializeAttachment(Grid& grid, TAttachment& attachment,
     523              :                                                  typename geometry_traits<TElem>::iterator iterBegin,
     524              :                                                  typename geometry_traits<TElem>::iterator iterEnd,
     525              :                                                  BinaryBuffer& out);
     526              : 
     527              : ////////////////////////////////////////////////////////////////////////
     528              : ///     copies attached values from a binary stream
     529              : /**
     530              :  * copies values from the given binary stream to the given attachment of
     531              :  * elements between iterBegin and iterEnd.
     532              :  * If attachment was not attached to the grid, then it will be attached
     533              :  * automatically.
     534              :  */
     535              : template <class TElem, class TAttachment>
     536              : bool DeserializeAttachment(Grid& grid, TAttachment& attachment,
     537              :                                                  BinaryBuffer& in);
     538              : 
     539              : ////////////////////////////////////////////////////////////////////////
     540              : ///     copies attached values from a binary stream
     541              : /**
     542              :  * copies values from the given binary stream to the given attachment of
     543              :  * elements between iterBegin and iterEnd.
     544              :  * If attachment was not attached to the grid, then it will be attached
     545              :  * automatically.
     546              :  */
     547              : template <class TElem, class TAttachment>
     548              : bool DeserializeAttachment(Grid& grid, TAttachment& attachment,
     549              :                                                  typename geometry_traits<TElem>::iterator iterBegin,
     550              :                                                  typename geometry_traits<TElem>::iterator iterEnd,
     551              :                                                  BinaryBuffer& in);
     552              : 
     553              : 
     554              : ////////////////////////////////////////////////////////////////////////
     555              : ////////////////////////////////////////////////////////////////////////
     556              : //      SUBSET-HANDLER
     557              : 
     558              : ////////////////////////////////////////////////////////////////////////
     559              : ///     writes the subset-indices of all elements in the goc to a stream.
     560              : bool SerializeSubsetHandler(Grid& grid, ISubsetHandler& sh,
     561              :                                                         GridObjectCollection goc,
     562              :                                                         BinaryBuffer& out);
     563              :                                                         
     564              : ////////////////////////////////////////////////////////////////////////
     565              : ///     writes the subset-indices of all elements in the grid to a stream.
     566              : bool SerializeSubsetHandler(Grid& grid, ISubsetHandler& sh,
     567              :                                                         BinaryBuffer& out);
     568              : 
     569              : ////////////////////////////////////////////////////////////////////////
     570              : ///     assigns subset-indices to all elements in the goc from a stream.
     571              : /**     One has to be very careful that the given goc only contains
     572              :  * the elements that were passed to the serialization routine.
     573              :  * Problems could be caused by automatic element creation.
     574              :  * consider to set grid.set_option(GRIDOPT_NONE) before loading
     575              :  * the grid.
     576              :  *
     577              :  * readPropertyMap should always be true. It is only contained for backwards
     578              :  * compatibility with older binary files, which did not support property maps.
     579              :  */
     580              : bool DeserializeSubsetHandler(Grid& grid, ISubsetHandler& sh,
     581              :                                                         GridObjectCollection goc,
     582              :                                                         BinaryBuffer& in,
     583              :                                                         bool readPropertyMap = true);
     584              : 
     585              :                                                         
     586              : ////////////////////////////////////////////////////////////////////////
     587              : ///     assigns subset-indices to all elements in the grid from a stream.
     588              : /**     One has to be very careful that the given grid only contains
     589              :  * the elements that were passed to the serialization routine.
     590              :  * Problems could be caused by automatic element creation.
     591              :  * consider to set grid.set_option(GRIDOPT_NONE) before loading
     592              :  * the grid.
     593              :  *
     594              :  * readPropertyMap should always be true. It is only contained for backwards
     595              :  * compatibility with older binary files, which did not support property maps.
     596              :  */
     597              : bool DeserializeSubsetHandler(Grid& grid, ISubsetHandler& sh,
     598              :                                                         BinaryBuffer& in,
     599              :                                                         bool readPropertyMap = true);
     600              : 
     601              : 
     602              : ////////////////////////////////////////////////////////////////////////
     603              : ////////////////////////////////////////////////////////////////////////
     604              : //      SELECTOR
     605              : 
     606              : ////////////////////////////////////////////////////////////////////////
     607              : ///     writes the subset-indices of all elements in the goc to a stream.
     608              : bool SerializeSelector(Grid& grid, ISelector& sel,
     609              :                                            GridObjectCollection goc,
     610              :                                            BinaryBuffer& out);
     611              :                                                         
     612              : ////////////////////////////////////////////////////////////////////////
     613              : ///     writes the subset-indices of all elements in the grid to a stream.
     614              : bool SerializeSelector(Grid& grid, ISelector& sel,
     615              :                                            BinaryBuffer& out);
     616              : 
     617              : ////////////////////////////////////////////////////////////////////////
     618              : ///     assigns subset-indices to all elements in the goc from a stream.
     619              : /**     One has to be very careful that the given goc only contains
     620              :  * the elements that were passed to the serialization routine.
     621              :  * Problems could be caused by automatic element creation.
     622              :  * consider to set grid.set_option(GRIDOPT_NONE) before loading
     623              :  * the grid.
     624              :  *
     625              :  * readPropertyMap should always be true. It is only contained for backwards
     626              :  * compatibility with older binary files, which did not support property maps.
     627              :  */
     628              : bool DeserializeSelector(Grid& grid, ISelector& sel,
     629              :                                                  GridObjectCollection goc,
     630              :                                                  BinaryBuffer& in);
     631              : 
     632              :                                                         
     633              : ////////////////////////////////////////////////////////////////////////
     634              : ///     assigns subset-indices to all elements in the grid from a stream.
     635              : /**     One has to be very careful that the given grid only contains
     636              :  * the elements that were passed to the serialization routine.
     637              :  * Problems could be caused by automatic element creation.
     638              :  * consider to set grid.set_option(GRIDOPT_NONE) before loading
     639              :  * the grid.
     640              :  *
     641              :  * readPropertyMap should always be true. It is only contained for backwards
     642              :  * compatibility with older binary files, which did not support property maps.
     643              :  */
     644              : bool DeserializeSelector(Grid& grid, ISelector& sel,
     645              :                                                  BinaryBuffer& in);
     646              : 
     647              : 
     648              : // void SerializeProjector(BinaryBuffer& out, RefinementProjector& proj);
     649              : // void SerializeProjectionHandler(BinaryBuffer& out, ProjectionHandler& ph);
     650              : // SPRefinementProjector DeserializeProjector(BinaryBuffer& in);
     651              : // void DeserializeProjectionHandler(BinaryBuffer& in, ProjectionHandler& ph);
     652              : 
     653              : /**@}*/ // end of doxygen defgroup command
     654              : 
     655              : }
     656              : 
     657              : ////////////////////////////////
     658              : //      include implementation
     659              : #include "serialization_impl.hpp"
     660              : 
     661              : #endif
        

Generated by: LCOV version 2.0-1