ug4
serialization

Classes

class  ug::GeomObjAttachmentSerializer< TGeomObj, TAttachment >
 Serialization callback for grid attachments. More...
 
class  ug::GeomObjDataSerializer< TGeomObj >
 Interface for handling serialization and deserialization of data associated with geometric objects. More...
 
class  ug::GridDataSerializationHandler
 Serialization of data associated with grid elements. More...
 
class  ug::GridDataSerializer
 Interface for handling serialization and deserialization of data associated with all geometric objects in a grid. More...
 
class  ug::SubsetHandlerSerializer
 

Typedefs

typedef GeomObjDataSerializer< Edgeug::EdgeDataSerializer
 
typedef GeomObjDataSerializer< Faceug::FaceDataSerializer
 
typedef SmartPtr< EdgeDataSerializerug::SPEdgeDataSerializer
 
typedef SmartPtr< FaceDataSerializerug::SPFaceDataSerializer
 
typedef SmartPtr< GridDataSerializerug::SPGridDataSerializer
 
typedef SmartPtr< VertexDataSerializerug::SPVertexDataSerializer
 
typedef SmartPtr< VolumeDataSerializerug::SPVolumeDataSerializer
 
typedef GeomObjDataSerializer< Vertexug::VertexDataSerializer
 
typedef GeomObjDataSerializer< Volumeug::VolumeDataSerializer
 

Functions

template<class TElem , class TAttachment >
bool ug::DeserializeAttachment (Grid &grid, TAttachment &attachment, BinaryBuffer &in)
 copies attached values from a binary stream More...
 
template<class TElem , class TAttachment >
bool ug::DeserializeAttachment (Grid &grid, TAttachment &attachment, typename geometry_traits< TElem >::iterator iterBegin, typename geometry_traits< TElem >::iterator iterEnd, BinaryBuffer &in)
 copies attached values from a binary stream More...
 
bool ug::DeserializeGridElements (Grid &grid, BinaryBuffer &in, bool readGridHeader=true)
 Creates grid elements from a binary stream. More...
 
bool ug::DeserializeMultiGridElements (MultiGrid &mg, BinaryBuffer &in, std::vector< Vertex * > *pvVrts=NULL, std::vector< Edge * > *pvEdges=NULL, std::vector< Face * > *pvFaces=NULL, std::vector< Volume * > *pvVols=NULL, MultiElementAttachmentAccessor< AGeomObjID > *paaID=NULL)
 Creates multi-grid elements from a binary stream. More...
 
bool ug::DeserializeSelector (Grid &grid, ISelector &sel, BinaryBuffer &in)
 assigns subset-indices to all elements in the grid from a stream. More...
 
bool ug::DeserializeSelector (Grid &grid, ISelector &sel, GridObjectCollection goc, BinaryBuffer &in)
 assigns subset-indices to all elements in the goc from a stream. More...
 
bool ug::DeserializeSubsetHandler (Grid &grid, ISubsetHandler &sh, BinaryBuffer &in, bool readPropertyMap=true)
 assigns subset-indices to all elements in the grid from a stream. More...
 
bool ug::DeserializeSubsetHandler (Grid &grid, ISubsetHandler &sh, GridObjectCollection goc, BinaryBuffer &in, bool readPropertyMap=true)
 assigns subset-indices to all elements in the goc from a stream. More...
 
template<class TElem , class TAttachment >
bool ug::SerializeAttachment (Grid &grid, TAttachment &attachment, BinaryBuffer &out)
 
template<class TElem , class TAttachment >
bool ug::SerializeAttachment (Grid &grid, TAttachment &attachment, typename geometry_traits< TElem >::iterator iterBegin, typename geometry_traits< TElem >::iterator iterEnd, BinaryBuffer &out)
 copies attached values to a binary stream. More...
 
bool ug::SerializeGridElements (Grid &grid, BinaryBuffer &out)
 Writes all grid elements into a binary-stream. More...
 
bool ug::SerializeGridElements (Grid &grid, GridObjectCollection goc, AInt &aIntVRT, BinaryBuffer &out)
 Writes a part of the grids elements to a binary-stream. More...
 
bool ug::SerializeGridElements (Grid &grid, GridObjectCollection goc, BinaryBuffer &out)
 Writes a part of the grids elements to a binary-stream. More...
 
bool ug::SerializeMultiGridElements (MultiGrid &mg, BinaryBuffer &out)
 writes the elements of a MultiGrid to a binary stream. More...
 
bool ug::SerializeMultiGridElements (MultiGrid &mg, GridObjectCollection goc, BinaryBuffer &out)
 writes a part of the elements of a MultiGrid to a binary stream. More...
 
bool ug::SerializeMultiGridElements (MultiGrid &mg, GridObjectCollection goc, MultiElementAttachmentAccessor< AInt > &aaInt, BinaryBuffer &out, MultiElementAttachmentAccessor< AGeomObjID > *paaID=NULL)
 writes a part of the elements of a MultiGrid to a binary stream. More...
 
bool ug::SerializeSelector (Grid &grid, ISelector &sel, BinaryBuffer &out)
 writes the subset-indices of all elements in the grid to a stream. More...
 
bool ug::SerializeSelector (Grid &grid, ISelector &sel, GridObjectCollection goc, BinaryBuffer &out)
 writes the subset-indices of all elements in the goc to a stream. More...
 
bool ug::SerializeSubsetHandler (Grid &grid, ISubsetHandler &sh, BinaryBuffer &out)
 writes the subset-indices of all elements in the grid to a stream. More...
 
bool ug::SerializeSubsetHandler (Grid &grid, ISubsetHandler &sh, GridObjectCollection goc, BinaryBuffer &out)
 writes the subset-indices of all elements in the goc to a stream. More...
 

Detailed Description

Methods that perform grid-related serialization are grouped here.

Typedef Documentation

◆ EdgeDataSerializer

◆ FaceDataSerializer

◆ SPEdgeDataSerializer

◆ SPFaceDataSerializer

◆ SPGridDataSerializer

◆ SPVertexDataSerializer

◆ SPVolumeDataSerializer

◆ VertexDataSerializer

◆ VolumeDataSerializer

Function Documentation

◆ DeserializeAttachment() [1/2]

template<class TElem , class TAttachment >
bool ug::DeserializeAttachment ( Grid grid,
TAttachment &  attachment,
BinaryBuffer in 
)

copies attached values from a binary stream

copies values from the given binary stream to the given attachment of elements between iterBegin and iterEnd. If attachment was not attached to the grid, then it will be attached automatically.

References ug::Grid::begin(), and ug::Grid::end().

◆ DeserializeAttachment() [2/2]

template<class TElem , class TAttachment >
bool ug::DeserializeAttachment ( Grid grid,
TAttachment &  attachment,
typename geometry_traits< TElem >::iterator  iterBegin,
typename geometry_traits< TElem >::iterator  iterEnd,
BinaryBuffer in 
)

copies attached values from a binary stream

copies values from the given binary stream to the given attachment of elements between iterBegin and iterEnd. If attachment was not attached to the grid, then it will be attached automatically.

References ug::Grid::attach_to(), ug::Grid::has_attachment(), ug::BinaryBuffer::read(), and UG_LOG.

◆ DeserializeGridElements()

bool ug::DeserializeGridElements ( Grid grid,
BinaryBuffer in,
bool  readGridHeader = true 
)

◆ DeserializeMultiGridElements()

bool ug::DeserializeMultiGridElements ( MultiGrid mg,
BinaryBuffer in,
std::vector< Vertex * > *  pvVrts = NULL,
std::vector< Edge * > *  pvEdges = NULL,
std::vector< Face * > *  pvFaces = NULL,
std::vector< Volume * > *  pvVols = NULL,
MultiElementAttachmentAccessor< AGeomObjID > *  paaID = NULL 
)

Creates multi-grid elements from a binary stream.

If you pass a pointer to a std::vector using pvVrts, pvEdges, pvFaces or pvVolumes, those vectors will contain the elements of the grid in the order they were read. Specifying those vectors does not lead to a performance loss.

An accessor to global ids in the grids elements can optionally be specified through paaID. If it is specified, the existing grid is automatically merged with the new elements based on the global ids. The accessor must only be specified if it was also specified in SerializeMultiGridElements.

Todo:
add support for constrained/constraining faces

References ug::ConstrainingEdge::add_constrained_object(), ug::ConstrainingFace::add_constrained_object(), ug::MultiGrid::associate_parent(), ug::GridObject::base_object_id(), ug::MultiGrid::begin(), ug::GridHeader::contains_option(), ug::MultiGrid::create(), ug::Deserialize(), ug::EDGE, ug::MultiGrid::end(), ug::BinaryBuffer::eof(), ug::FACE, ug::MultiGrid::get_child(), ug::Hash< TKey, TValue >::get_entry(), ug::MultiGrid::get_parent(), ug::GetParent(), ug::GHRO_READ_LEVELS, ug::GHRO_READ_PARENTS, ug::GSID_CONSTRAINED_EDGE, ug::GSID_CONSTRAINED_QUADRILATERAL, ug::GSID_CONSTRAINED_TRIANGLE, ug::GSID_CONSTRAINING_EDGE, ug::GSID_CONSTRAINING_QUADRILATERAL, ug::GSID_CONSTRAINING_TRIANGLE, ug::GSID_EDGE, ug::GSID_END_OF_GRID, ug::GSID_HANGING_VERTEX, ug::GSID_HEXAHEDRON, ug::GSID_NEW_LEVEL, ug::GSID_OCTAHEDRON, ug::GSID_PRISM, ug::GSID_PYRAMID, ug::GSID_QUADRILATERAL, ug::GSID_TETRAHEDRON, ug::GSID_TRIANGLE, ug::GSID_VERTEX, ug::Hash< TKey, TValue >::insert(), LOG, ug::MultiGrid::num(), ug::MultiGrid::num_children(), p, ug::BinaryBuffer::read(), ug::ReadGridHeader(), ug::Hash< TKey, TValue >::reserve(), ug::ConstrainedVertex::set_constraining_object(), ug::ConstrainedEdge::set_constraining_object(), ug::ConstrainedFace::set_constraining_object(), ug::ConstrainedVertex::set_local_coordinate_1(), ug::ConstrainedVertex::set_local_coordinate_2(), ug::ConstrainedVertex::set_parent_base_object_id(), ug::ConstrainedEdge::set_parent_base_object_id(), ug::ConstrainedFace::set_parent_base_object_id(), ug::MultiGrid::set_parent_type(), SRLZ_PROFILE, SRLZ_PROFILE_END, SRLZ_PROFILE_FUNC, UG_ASSERT, UG_LOG, and UG_THROW.

Referenced by ug::DistributeGrid().

◆ DeserializeSelector() [1/2]

bool ug::DeserializeSelector ( Grid grid,
ISelector sel,
BinaryBuffer in 
)

assigns subset-indices to all elements in the grid from a stream.

One has to be very careful that the given grid only contains the elements that were passed to the serialization routine. Problems could be caused by automatic element creation. consider to set grid.set_option(GRIDOPT_NONE) before loading the grid.

readPropertyMap should always be true. It is only contained for backwards compatibility with older binary files, which did not support property maps.

References ug::DeserializeSelector(), and ug::Grid::get_grid_objects().

◆ DeserializeSelector() [2/2]

bool ug::DeserializeSelector ( Grid grid,
ISelector sel,
GridObjectCollection  goc,
BinaryBuffer in 
)

assigns subset-indices to all elements in the goc from a stream.

One has to be very careful that the given goc only contains the elements that were passed to the serialization routine. Problems could be caused by automatic element creation. consider to set grid.set_option(GRIDOPT_NONE) before loading the grid.

readPropertyMap should always be true. It is only contained for backwards compatibility with older binary files, which did not support property maps.

References ug::GridObjectCollection::begin(), ug::GridObjectCollection::end(), ug::GridObjectCollection::num_levels(), ug::BinaryBuffer::read(), ug::ReadSelectionStatesFromStream(), and UG_COND_THROW.

Referenced by ug::DeserializeSelector(), and ug::LoadGridFromLGB().

◆ DeserializeSubsetHandler() [1/2]

bool ug::DeserializeSubsetHandler ( Grid grid,
ISubsetHandler sh,
BinaryBuffer in,
bool  readPropertyMap = true 
)

assigns subset-indices to all elements in the grid from a stream.

One has to be very careful that the given grid only contains the elements that were passed to the serialization routine. Problems could be caused by automatic element creation. consider to set grid.set_option(GRIDOPT_NONE) before loading the grid.

readPropertyMap should always be true. It is only contained for backwards compatibility with older binary files, which did not support property maps.

References ug::DeserializeSubsetHandler(), and ug::Grid::get_grid_objects().

◆ DeserializeSubsetHandler() [2/2]

bool ug::DeserializeSubsetHandler ( Grid grid,
ISubsetHandler sh,
GridObjectCollection  goc,
BinaryBuffer in,
bool  readPropertyMap = true 
)

assigns subset-indices to all elements in the goc from a stream.

One has to be very careful that the given goc only contains the elements that were passed to the serialization routine. Problems could be caused by automatic element creation. consider to set grid.set_option(GRIDOPT_NONE) before loading the grid.

readPropertyMap should always be true. It is only contained for backwards compatibility with older binary files, which did not support property maps.

References ug::GridObjectCollection::begin(), ug::SubsetInfo::color, ug::Deserialize(), ug::GridObjectCollection::end(), ug::SubsetInfo::m_propertyMap, ug::SubsetInfo::materialIndex, ug::SubsetInfo::name, ug::GridObjectCollection::num_levels(), ug::BinaryBuffer::read(), ug::ReadSubsetIndicesFromStream(), ug::ISubsetHandler::subset_info(), ug::SubsetInfo::subsetState, and UG_COND_THROW.

Referenced by ug::DeserializeSubsetHandler(), and ug::LoadGridFromLGB().

◆ SerializeAttachment() [1/2]

template<class TElem , class TAttachment >
bool ug::SerializeAttachment ( Grid grid,
TAttachment &  attachment,
BinaryBuffer out 
)

copies attached values of the grids elements of the given type to the binary stream.

Make sure that attachment is attached to the specified elements.

References ug::Grid::begin(), and ug::Grid::end().

◆ SerializeAttachment() [2/2]

template<class TElem , class TAttachment >
bool ug::SerializeAttachment ( Grid grid,
TAttachment &  attachment,
typename geometry_traits< TElem >::iterator  iterBegin,
typename geometry_traits< TElem >::iterator  iterEnd,
BinaryBuffer out 
)

copies attached values to a binary stream.

copies attached values of the elements between iterBegin and iterEnd to the binary stream.

Make sure that attachment is attached to the specified elements.

References ug::Grid::has_attachment(), and ug::BinaryBuffer::write().

◆ SerializeGridElements() [1/3]

bool ug::SerializeGridElements ( Grid grid,
BinaryBuffer out 
)

Writes all grid elements into a binary-stream.

References ug::Grid::get_grid_objects().

Referenced by ug::AllGatherGrid(), ug::BroadcastGrid(), ug::GatherGrid(), ug::SaveGridToLGB(), and ug::SerializeGridElements().

◆ SerializeGridElements() [2/3]

bool ug::SerializeGridElements ( Grid grid,
GridObjectCollection  goc,
AInt aIntVRT,
BinaryBuffer out 
)

Writes a part of the grids elements to a binary-stream.

The passed GridObjectCollection goc may only reference elements of the given grid. It is important, that the goc is complete - that means that all referenced vertices are contained in the goc.

If you pack several different parts of your grid, you should use this method, since it is faster than calling SerializeGridElements without the attachment.

the integer attachment aInt is used during this method to store an index in each vertex of the goc. The initial content of the referenced attachment is ignored.

The caller is responsible to attach the aIntVRT attachment to the to the vertices of the grid before calling this method. The caller is also responsible to detach aIntVRT from the grids vertices when it is no longer required.

After termination the attachment holds the indices at which the respcetive vertices are stored in the pack.

References ug::GridObjectCollection::begin(), ug::GridObjectCollection::end(), ug::GSID_EDGE, ug::GSID_END_OF_GRID, ug::GSID_HANGING_VERTEX, ug::GSID_HEXAHEDRON, ug::GSID_PRISM, ug::GSID_PYRAMID, ug::GSID_QUADRILATERAL, ug::GSID_TETRAHEDRON, ug::GSID_TRIANGLE, ug::GSID_VERTEX, ug::Grid::has_vertex_attachment(), ug::GridObjectCollection::num(), p, ug::EdgeVertices::vertex(), ug::CustomTriangle< ConcreteTriangleType, BaseClass, RefTriType, RefQuadType >::vertex(), ug::CustomQuadrilateral< ConcreteQuadrilateralType, BaseClass, RefTriType, RefQuadType >::vertex(), ug::Tetrahedron::vertex(), ug::Hexahedron::vertex(), ug::BinaryBuffer::write(), and ug::WriteGridHeader().

◆ SerializeGridElements() [3/3]

bool ug::SerializeGridElements ( Grid grid,
GridObjectCollection  goc,
BinaryBuffer out 
)

Writes a part of the grids elements to a binary-stream.

The passed GridObjectCollection goc may only reference elements of the given grid. It is important, that the goc is complete - that means that all referenced vertices are contained in the goc.

If you're planning to serialize multiple parts of one grid, you should consider to use the full-featured serialization method.

References ug::Grid::attach_to_vertices(), ug::Grid::detach_from_vertices(), and ug::SerializeGridElements().

◆ SerializeMultiGridElements() [1/3]

bool ug::SerializeMultiGridElements ( MultiGrid mg,
BinaryBuffer out 
)

writes the elements of a MultiGrid to a binary stream.

References ug::MultiGrid::get_grid_objects(), and ug::SerializeMultiGridElements().

◆ SerializeMultiGridElements() [2/3]

bool ug::SerializeMultiGridElements ( MultiGrid mg,
GridObjectCollection  goc,
BinaryBuffer out 
)

writes a part of the elements of a MultiGrid to a binary stream.

The passed GridObjectCollection goc may only reference elements of the given grid. It is important, that the goc is complete - that means that all referenced vertices are contained in the goc. The goc has also to be complete in regard to the multi-grid hierarchy. This means that for each element of the goc, the parent has to be also part of the goc.

If you're planning to serialize multiple parts of one grid, you should consider to use the full-featured serialization method.

References ug::Grid::attach_to_all(), ug::Grid::detach_from_all(), and ug::SerializeMultiGridElements().

◆ SerializeMultiGridElements() [3/3]

bool ug::SerializeMultiGridElements ( MultiGrid mg,
GridObjectCollection  goc,
MultiElementAttachmentAccessor< AInt > &  aaInt,
BinaryBuffer out,
MultiElementAttachmentAccessor< AGeomObjID > *  paaID = NULL 
)

writes a part of the elements of a MultiGrid to a binary stream.

THIS METHOD USES Grid::mark.

The passed GridObjectCollection goc may only reference elements of the given grid. It is important, that the goc is complete - that means that all referenced vertices are contained in the goc. The goc has also to be complete in regard to the multi-grid hierarchy. This means that for each element of the goc, the parent has to be also part of the goc.

If you pack several different parts of your grid, you should use this method, since it is faster than calling SerializeGridElements without the attachment.

the integer attachment aInt is used during this method to store an index in each element of the goc. The initial content of the referenced attachment is ignored.

The caller is responsible to attach the aInt attachment to the to the elements of the grid before calling this method. The caller is also responsible to detach aInt from the grids elements when it is no longer required.

Optionally an accessor to global ids in mg can be specified through paaID. Those ids have to be attached and correctly set before the method is called. If you specify those ids, they are serialized together with the grid elements. Make sure to pass a corresponding id-accessor on a call to deserialize.

After termination the attachments hold the indices that were assigned to the respective elements - starting from 0 for each element type.

Todo:

add support for constrained/constraining faces

use ConstVertexArrays instead of virtual functions ...->vertex(...)

References ug::GridObjectCollection::begin(), ug::Grid::begin_marking(), ug::EDGE, ug::ElementDebugInfo(), ug::GridObjectCollection::end(), ug::Grid::end_marking(), ug::FACE, ug::ConstrainedVertex::get_constraining_object(), ug::ConstrainedEdge::get_constraining_object(), ug::ConstrainedFace::get_constraining_object(), ug::ConstrainedVertex::get_local_coordinate_1(), ug::ConstrainedVertex::get_local_coordinate_2(), ug::ConstrainedVertex::get_parent_base_object_id(), ug::ConstrainedEdge::get_parent_base_object_id(), ug::ConstrainedFace::get_parent_base_object_id(), ug::GHRO_READ_LEVELS, ug::GHRO_READ_PARENTS, ug::GSID_CONSTRAINED_EDGE, ug::GSID_CONSTRAINED_QUADRILATERAL, ug::GSID_CONSTRAINED_TRIANGLE, ug::GSID_CONSTRAINING_EDGE, ug::GSID_CONSTRAINING_QUADRILATERAL, ug::GSID_CONSTRAINING_TRIANGLE, ug::GSID_EDGE, ug::GSID_END_OF_GRID, ug::GSID_HANGING_VERTEX, ug::GSID_HEXAHEDRON, ug::GSID_NEW_LEVEL, ug::GSID_OCTAHEDRON, ug::GSID_PRISM, ug::GSID_PYRAMID, ug::GSID_QUADRILATERAL, ug::GSID_TETRAHEDRON, ug::GSID_TRIANGLE, ug::GSID_VERTEX, ug::Grid::is_marked(), ug::Grid::mark(), ug::GridObjectCollection::num(), ug::GridObjectCollection::num_levels(), p, ug::Serialize(), SRLZ_PROFILE_FUNC, UG_ASSERT, ug::EdgeVertices::vertex(), ug::CustomTriangle< ConcreteTriangleType, BaseClass, RefTriType, RefQuadType >::vertex(), ug::CustomQuadrilateral< ConcreteQuadrilateralType, BaseClass, RefTriType, RefQuadType >::vertex(), ug::Tetrahedron::vertex(), ug::Hexahedron::vertex(), ug::BinaryBuffer::write(), ug::WriteGridHeader(), and ug::WriteParent().

Referenced by ug::DistributeGrid(), and ug::SerializeMultiGridElements().

◆ SerializeSelector() [1/2]

bool ug::SerializeSelector ( Grid grid,
ISelector sel,
BinaryBuffer out 
)

writes the subset-indices of all elements in the grid to a stream.

References ug::Grid::get_grid_objects(), and ug::SerializeSelector().

◆ SerializeSelector() [2/2]

bool ug::SerializeSelector ( Grid grid,
ISelector sel,
GridObjectCollection  goc,
BinaryBuffer out 
)

◆ SerializeSubsetHandler() [1/2]

bool ug::SerializeSubsetHandler ( Grid grid,
ISubsetHandler sh,
BinaryBuffer out 
)

writes the subset-indices of all elements in the grid to a stream.

References ug::Grid::get_grid_objects(), and ug::SerializeSubsetHandler().

◆ SerializeSubsetHandler() [2/2]