33 #ifndef __H__LIB_GRID__GRID_IMPLEMENTATION__
34 #define __H__LIB_GRID__GRID_IMPLEMENTATION__
67 template<
class TGeomObj>
73 invalid_geometry_type);
75 TGeomObj* geomObj =
new TGeomObj;
82 return iterator_cast<typename geometry_traits<TGeomObj>::iterator>(
get_iterator(geomObj));
85 template <
class TGeomObj>
92 invalid_geometry_type);
94 TGeomObj* geomObj =
new TGeomObj(descriptor);
102 return iterator_cast<typename geometry_traits<TGeomObj>::iterator>(
get_iterator(geomObj));
105 template<
class TGeomObj>
111 invalid_geometry_type);
113 TGeomObj* geomObj =
new TGeomObj;
115 if(geomObj->reference_object_id() == pReplaceMe->reference_object_id())
118 return iterator_cast<typename geometry_traits<TGeomObj>::iterator>(
get_iterator(geomObj));
122 LOG(
"ERROR in Grid::create_and_replace(...): reference objects do not match!");
123 assert(!
"ERROR in Grid::create_and_replace(...): reference objects do not match!");
125 return end<TGeomObj>();
130 template <
class TGeomObj>
134 invalid_geometry_type);
136 element_storage<TGeomObj>().m_attachmentPipe.reserve(
num);
141 template <
class GeomObjIter>
142 void Grid::erase(
const GeomObjIter& iterBegin,
const GeomObjIter& iterEnd)
144 GeomObjIter iter = iterBegin;
145 while(iter != iterEnd)
147 GeomObjIter tmpIter = iter;
153 template <
class TGeomObj>
156 while(begin<TGeomObj>() != end<TGeomObj>())
157 erase(*begin<TGeomObj>());
162 template <
class TGeomObj>
169 return iterator_cast<typename geometry_traits<TGeomObj>::iterator>
173 template <
class TGeomObj>
180 return iterator_cast<typename geometry_traits<TGeomObj>::iterator>
184 template <
class TGeomObj>
191 return iterator_cast<typename geometry_traits<TGeomObj>::const_iterator>
195 template <
class TGeomObj>
202 return iterator_cast<typename geometry_traits<TGeomObj>::const_iterator>
206 template <
class TGeomObj>
213 return static_cast<TGeomObj*
>(*element_storage<TGeomObj>().m_sectionContainer.
217 template <
class TGeomObj>
224 return static_cast<TGeomObj*
>(*element_storage<TGeomObj>().m_sectionContainer.
229 template <
class TGeomObj>
238 return element_storage<TGeomObj>().m_sectionContainer.num_elements();
240 return element_storage<TGeomObj>().m_sectionContainer.num_elements(secIndex);
250 (*iter)->vertices_to_be_merged(
this,
target, elem1, elem2);
261 (*iter)->edges_to_be_merged(
this,
target, elem1, elem2);
272 (*iter)->faces_to_be_merged(
this,
target, elem1, elem2);
283 (*iter)->volumes_to_be_merged(
this,
target, elem1, elem2);
287 template <
class TGeomObj>
290 return element_storage<TGeomObj>().m_attachmentPipe.num_data_entries();
295 template <
class TGeomObjClass>
299 invalid_GeomObjClass);
306 element_storage<TGeomObjClass>().m_attachmentPipe.attach(attachment, options);
311 attach_to<Vertex>(attachment, passOnValues);
312 attach_to<Edge>(attachment, passOnValues);
313 attach_to<Face>(attachment, passOnValues);
314 attach_to<Volume>(attachment, passOnValues);
319 attach_to<Vertex>(attachment);
320 attach_to<Edge>(attachment);
321 attach_to<Face>(attachment);
322 attach_to<Volume>(attachment);
325 template <
class TGeomObjClass,
class TAttachment>
326 void Grid::attach_to_dv(TAttachment& attachment,
const typename TAttachment::ValueType& defaultValue)
328 attach_to_dv<TGeomObjClass, TAttachment>(attachment, defaultValue, attachment.default_pass_on_behaviour());
331 template <
class TAttachment>
334 const typename TAttachment::ValueType& defaultValue)
336 attach_to_dv<Vertex>(attachment, defaultValue);
337 attach_to_dv<Edge>(attachment, defaultValue);
338 attach_to_dv<Face>(attachment, defaultValue);
339 attach_to_dv<Volume>(attachment, defaultValue);
342 template <
class TGeomObjClass,
class TAttachment>
343 void Grid::attach_to_dv(TAttachment& attachment,
const typename TAttachment::ValueType& defaultValue,
bool passOnValues)
346 invalid_GeomObjClass);
353 element_storage<TGeomObjClass>().m_attachmentPipe.attach(attachment, defaultValue, options);
356 template <
class TAttachment>
359 const typename TAttachment::ValueType& defaultValue,
362 attach_to_dv<Vertex>(attachment, defaultValue, passOnValues);
363 attach_to_dv<Edge>(attachment, defaultValue, passOnValues);
364 attach_to_dv<Face>(attachment, defaultValue, passOnValues);
365 attach_to_dv<Volume>(attachment, defaultValue, passOnValues);
368 template <
class TGeomObjClass>
372 invalid_GeomObjClass);
374 element_storage<TGeomObjClass>().m_attachmentPipe.detach(attachment);
379 detach_from<Vertex>(attachment);
380 detach_from<Edge>(attachment);
381 detach_from<Face>(attachment);
382 detach_from<Volume>(attachment);
397 template <
class TGeomObj,
class TAttachment>
398 typename TAttachment::ContainerType*
404 return element_storage<TGeomObj>().m_attachmentPipe.get_data_container(attachment);
407 template <
class TGeomObj>
414 return element_storage<TGeomObj>().m_attachmentPipe;
417 template <
class TGeomObj>
423 get_data_index(&element_storage<TGeomObj>(), pObj);
431 LOG(
"WARNING in " << caller <<
": auto-enabling " << optionName <<
"." << std::endl);
438 template <
class TIterator>
441 for(TIterator iter =
begin; iter !=
end; ++iter)
445 template <
class TIterator>
448 for(TIterator iter =
begin; iter !=
end; ++iter)
454 template <
class TContainer>
465 template <
class TElem>
471 template <
class TElem>
477 template <
class TElem>
483 template <
class TElem>
489 template <
class TElem>
491 ::secure_container& elems, TElem* e)
496 elems.set_external_array(
497 element_storage<typename TElem::grid_base_object>().m_sectionContainer.
498 get_container().get_pointer_to_element(e),
502 template <
class TElem>
508 template <
class TElem>
514 template <
class TElem>
520 template <
class TElem>
527 template <
class TElem>
529 ::secure_container& elems, TElem* e)
534 elems.set_external_array(
535 element_storage<typename TElem::grid_base_object>().m_sectionContainer.
536 get_container().get_pointer_to_element(e),
543 template <
class TGeomObj>
550 iter != iterEnd; ++iter)
560 template <
class TGeomObj>
568 iter != iterEnd; ++iter)
581 template <
class TGeomObj>
590 iter != iterEnd; ++iter)
610 template <
class TElem,
class TAttachment>
617 template <
class TElem,
class TAttachment>
624 template <
class TElem,
class TAttachment>
633 template <
class TElem,
class TAttachment>
649 template <
class TAttachment>
656 template <
class TAttachment>
663 template <
class TAttachment>
670 template <
class TAttachment>
680 template <
class TAttachment>
687 template <
class TAttachment>
694 template <
class TAttachment>
701 template <
class TAttachment>
711 template <
class TAttachment>
718 template <
class TAttachment>
725 template <
class TAttachment>
732 template <
class TAttachment>
742 template <
class TAttachment>
749 template <
class TAttachment>
756 template <
class TAttachment>
763 template <
class TAttachment>
786 assert(
m_bMarking &&
"ERROR: Grid::mark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
792 assert(
m_bMarking &&
"ERROR: Grid::mark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
798 assert(
m_bMarking &&
"ERROR: Grid::mark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
804 assert(
m_bMarking &&
"ERROR: Grid::mark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
821 assert(
m_bMarking &&
"ERROR: Grid::unmark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
827 assert(
m_bMarking &&
"ERROR: Grid::unmark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
833 assert(
m_bMarking &&
"ERROR: Grid::unmark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
839 assert(
m_bMarking &&
"ERROR: Grid::unmark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
851 default:
return false;
manages the layouts and interfaces which are associated with a distributed grid.
Definition: distributed_grid.h:88
Base-class for edges.
Definition: grid_base_objects.h:397
holds the vertices of an Edge or an EdgeDescriptor.
Definition: grid_base_objects.h:362
This struct is used to hold GridObjects and their attachment pipes.
Definition: element_storage.h:44
Faces are 2-dimensional objects.
Definition: grid_base_objects.h:510
Definition: grid_base_objects.h:483
the generic attachment-accessor for access to grids attachment pipes.
Definition: grid.h:182
AttachmentAccessor()
Definition: grid_impl.hpp:612
bool access(Grid &grid, TAttachment &a)
Definition: grid.h:189
EdgeAttachmentAccessor()
Definition: grid_impl.hpp:682
FaceAttachmentAccessor()
Definition: grid_impl.hpp:713
VertexAttachmentAccessor()
Definition: grid_impl.hpp:651
VolumeAttachmentAccessor()
Definition: grid_impl.hpp:744
Manages the elements of a grid and their interconnection.
Definition: grid.h:132
EdgeContainer::iterator AssociatedEdgeIterator
used to iterate over associated edges of vertices, faces and volumes
Definition: grid.h:249
traits< Vertex >::SectionContainer::iterator get_iterator(Vertex *o)
returns the iterator at which the given element lies in the section container
Definition: grid.h:1118
void clear()
clears the grids geometry and attachments
Definition: grid.cpp:220
void detach_from_all(IAttachment &attachment)
Definition: grid_impl.hpp:377
AssociatedFaceIterator associated_faces_begin(Vertex *vrt)
DO NOT INVOKE! Subject to change.
Definition: grid.cpp:944
VolumeAttachmentAccessor< AMark > m_aaMarkVOL
Definition: grid.h:1196
AssociatedEdgeIterator associated_edges_begin(Vertex *vrt)
DO NOT INVOKE! Subject to change.
Definition: grid.cpp:882
bool option_is_enabled(uint option) const
see set_options for a description of valid parameters.
Definition: grid.cpp:721
uint get_attachment_data_index(TGeomObj *pObj) const
Definition: grid_impl.hpp:419
Edge * find_edge_in_associated_edges(TGeomObj *obj, const EdgeVertices &ev)
Definition: grid_impl.hpp:544
void detach_from(IAttachment &attachment)
Definition: grid_impl.hpp:369
bool m_bMarking
Definition: grid.h:1191
ObserverContainer m_vertexObservers
Definition: grid.h:1162
void reserve(size_t num)
Reserves memory for the creation of the given object type.
Definition: grid_impl.hpp:131
Face * find_face_in_associated_faces(TGeomObj *obj, const FaceVertices &fv)
Definition: grid_impl.hpp:561
void register_element(Vertex *v, GridObject *pParent=NULL)
Definition: grid.h:870
void get_associated(SecureVertexContainer &vrts, Edge *e)
Definition: grid_connection_managment.cpp:2608
DistributedGridManager * distributed_grid_manager()
returns a pointer to the associated distributed grid manager.
Definition: grid_impl.hpp:53
void unmark(GridObject *obj)
unmarks the object. Calls are only valid between calls to Grid::begin_marking and Grid::end_marking.
Definition: grid_impl.hpp:808
bool is_marked(GridObject *obj) const
returns true if the object is marked, false if not.
Definition: grid_impl.hpp:843
DistributedGridManager * m_distGridMgr
Definition: grid.h:1199
size_t num() const
Definition: grid_impl.hpp:230
AssociatedEdgeIterator associated_edges_end(Vertex *vrt)
DO NOT INVOKE! Subject to change.
Definition: grid.cpp:892
size_t attachment_container_size() const
returns the size of the associated attachment containers.
Definition: grid_impl.hpp:288
void attach_to(IAttachment &attachment, bool passOnValues)
attach with custom pass-on-behaviour and unspecified default value.
Definition: grid_impl.hpp:296
VolumeContainer::iterator AssociatedVolumeIterator
used to iterate over associated volumes of vertices, edges and faces
Definition: grid.h:253
bool has_attachment(IAttachment &attachment)
Definition: grid.h:796
int m_currentMark
Definition: grid.h:1190
void attach_to_all(IAttachment &attachment, bool passOnValues)
Definition: grid_impl.hpp:309
void mark(GridObject *obj)
marks the object. Calls are only valid between calls to Grid::begin_marking and Grid::end_marking.
Definition: grid_impl.hpp:773
VertexAttachmentAccessor< AMark > m_aaMarkVRT
Definition: grid.h:1193
void autoenable_option(uint option, const char *caller, const char *optionName)
Definition: grid_impl.hpp:427
TGeomObj * back()
returns the last element of the given type.
Definition: grid_impl.hpp:219
void erase(GridObject *geomObj)
Definition: grid.cpp:459
AssociatedVolumeIterator associated_volumes_begin(Vertex *vrt)
DO NOT INVOKE! Subject to change.
Definition: grid.cpp:1006
Volume * find_volume_in_associated_volumes(TGeomObj *obj, const VolumeVertices &vv)
Definition: grid_impl.hpp:582
void get_associated_sorted(SecureVertexContainer &vrts, Edge *e) const
Definition: grid_connection_managment.cpp:2932
ObserverContainer m_faceObservers
Definition: grid.h:1164
ObserverContainer m_edgeObservers
Definition: grid.h:1163
bool is_parallel() const
returns true if the grid is prepared for parallel computations.
Definition: grid_impl.hpp:47
AssociatedFaceIterator associated_faces_end(Vertex *vrt)
DO NOT INVOKE! Subject to change.
Definition: grid.cpp:954
void objects_will_be_merged(Vertex *target, Vertex *elem1, Vertex *elem2)
notifies the grid that two objects will be merged.
Definition: grid_impl.hpp:244
geometry_traits< TGeomObj >::iterator create_and_replace(typename geometry_traits< TGeomObj >::grid_base_object *pReplaceMe)
create a custom element and replaces an old one.
Definition: grid_impl.hpp:107
void attach_to_dv(TAttachment &attachment, const typename TAttachment::ValueType &defaultValue)
Definition: grid_impl.hpp:326
geometry_traits< TGeomObj >::iterator begin()
Definition: grid_impl.hpp:164
traits< TGeomObj >::AttachmentPipe & get_attachment_pipe()
returns the attachment-pipe in which data associated with the given objects-types are stored.
Definition: grid_impl.hpp:409
void associated_elements(traits< Vertex >::secure_container &elemsOut, TElem *e)
Puts all elements of type TAss which are contained in 'e' or which contain 'e' into elemsOut.
Definition: grid_impl.hpp:466
ObserverContainer m_volumeObservers
Definition: grid.h:1165
EdgeAttachmentAccessor< AMark > m_aaMarkEDGE
Definition: grid.h:1194
FaceAttachmentAccessor< AMark > m_aaMarkFACE
Definition: grid.h:1195
void attach_to_all_dv(TAttachment &attachment, const typename TAttachment::ValueType &defaultValue)
attaches to vertices, edges, faces and volumes at once.
Definition: grid_impl.hpp:333
geometry_traits< TGeomObj >::iterator create(GridObject *pParent=NULL)
create a custom element.
Definition: grid_impl.hpp:69
AssociatedVolumeIterator associated_volumes_end(Vertex *vrt)
DO NOT INVOKE! Subject to change.
Definition: grid.cpp:1016
FaceContainer::iterator AssociatedFaceIterator
used to iterate over associated faces of vertices, edges and volumes
Definition: grid.h:251
void enable_options(uint options)
see set_options for a description of valid parameters.
Definition: grid.cpp:711
void associated_elements_sorted(traits< Vertex >::secure_container &elemsOut, TElem *e)
Puts all elements of type TAss which are contained in 'e' into elemsOut in the reference elements ord...
Definition: grid_impl.hpp:503
geometry_traits< TGeomObj >::iterator end()
Definition: grid_impl.hpp:175
void register_and_replace_element(Vertex *v, Vertex *pReplaceMe)
Definition: grid_connection_managment.cpp:114
TAttachment::ContainerType * get_attachment_data_container(TAttachment &attachment)
Definition: grid_impl.hpp:399
TGeomObj * front()
returns the first element of the given type.
Definition: grid_impl.hpp:208
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
virtual int base_object_id() const =0
the interface for attachments.
Definition: attachment_pipe.h:239
Container which holds an array of pointers.
Definition: pointer_const_array.h:84
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition: grid_base_objects.h:754
holds the vertices of a Volume or a VolumeDescriptor
Definition: grid_base_objects.h:723
define the interface that enables you to use your own types as element-types in an AttachmentPipe.
Definition: attachment_pipe.h:305
Definition: grid_base_object_traits.h:68
#define GRID_PROFILE_FUNC()
Definition: grid.h:57
bool CompareVertices(const FaceVertices *fv1, const FaceVertices *fv2)
Checks whether fv1 and fv2 contain the same vertices.
Definition: grid_util.cpp:44
size_t hash_key(const TKey &key)
The hashing method can be specialized for different types.
Definition: hash_function.h:50
#define LOG(msg)
Definition: common.h:60
#define STATIC_ASSERT(expr, msg)
Definition: common.h:61
unsigned int uint
Definition: types.h:114
size_t target(SM_edge< typename T::value_type > const &e, ug::BidirectionalMatrix< T > const &m)
Definition: bidirectional_boost.h:100
@ VOLUME
Definition: grid_base_objects.h:63
@ VERTEX
Definition: grid_base_objects.h:60
@ EDGE
Definition: grid_base_objects.h:61
@ FACE
Definition: grid_base_objects.h:62
The traits class holds some important types for each element-type.
Definition: grid.h:136