ug4
grid.h
Go to the documentation of this file.
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__GRID__
34 #define __H__LIB_GRID__GRID__
35 
36 #include <vector>
37 #include <list>
38 #include <memory>
39 #include <boost/function.hpp>
41 #include "common/ug_config.h"
42 #include "grid_constants.h"
43 #include "grid_base_objects.h"
44 #include "grid_observer.h"
45 #include "grid_object_collection.h"
46 #include "element_storage.h"
48 
49 // Define PROFILE_GRID to profile some often used gird-methods
50 //#define PROFILE_GRID
51 #ifdef PROFILE_GRID
53  #define GRID_PROFILE_FUNC() PROFILE_FUNC()
54  #define GRID_PROFILE(name) PROFILE_BEGIN(name)
55  #define GRID_PROFILE_END() PROFILE_END()
56 #else
57  #define GRID_PROFILE_FUNC()
58  #define GRID_PROFILE(name)
59  #define GRID_PROFILE_END()
60 #endif
61 
62 namespace ug
63 {
64 
65 // predeclaration of the distributed grid manager, which handles parallelization
66 // of grids. If you want to use it, you have to include
67 // "lib_grid/parallelization/distributed_grid.h"
68 class DistributedGridManager;
69 
70 // predeclaration of the periodic boundary identifier, which handles the master/slave
71 // identification of grid elements. If you want to use it, you have to include
72 // "lib_grid/tools/periodic_boundary_identifier.h"
73 class PeriodicBoundaryManager;
74 
82 // Grid
84 
132 {
133  public:
135  template <class TElem>
136  struct traits{
137  typedef typename TElem::grid_base_object base_object;
142 
145 
147 
148  // CALLBACKS
150  typedef boost::function<bool (base_object*)> callback;
151  };
152 
154 
169 
175 
176 
178  template <class TElem, class TAttachment>
179  class AttachmentAccessor : public ug::AttachmentAccessor<typename TElem::grid_base_object*,
180  TAttachment,
181  typename traits<TElem>::ElementStorage>
182  {
183  public:
186  AttachmentAccessor(Grid& grid, TAttachment& a);
187  AttachmentAccessor(Grid& grid, TAttachment& a, bool autoAttach);
188 
189  inline bool access(Grid& grid, TAttachment& a)
190  {
191  return ug::AttachmentAccessor<typename TElem::grid_base_object*,
192  TAttachment,
194  access(grid.get_attachment_pipe<TElem>(), a);
195  }
196  };
197 
198  // half-specialized AttachmentAccessors:
199  template <class TAttachment>
200  class VertexAttachmentAccessor : public AttachmentAccessor<Vertex, TAttachment>
201  {
202  public:
205  VertexAttachmentAccessor(Grid& grid, TAttachment& a);
206  VertexAttachmentAccessor(Grid& grid, TAttachment& a, bool autoAttach);
207  };
208 
209  template <class TAttachment>
210  class EdgeAttachmentAccessor : public AttachmentAccessor<Edge, TAttachment>
211  {
212  public:
215  EdgeAttachmentAccessor(Grid& grid, TAttachment& a);
216  EdgeAttachmentAccessor(Grid& grid, TAttachment& a, bool autoAttach);
217  };
218 
219  template <class TAttachment>
220  class FaceAttachmentAccessor : public AttachmentAccessor<Face, TAttachment>
221  {
222  public:
225  FaceAttachmentAccessor(Grid& grid, TAttachment& a);
226  FaceAttachmentAccessor(Grid& grid, TAttachment& a, bool autoAttach);
227  };
228 
229  template <class TAttachment>
230  class VolumeAttachmentAccessor : public AttachmentAccessor<Volume, TAttachment>
231  {
232  public:
235  VolumeAttachmentAccessor(Grid& grid, TAttachment& a);
236  VolumeAttachmentAccessor(Grid& grid, TAttachment& a, bool autoAttach);
237  };
238 
240  typedef std::vector<Vertex*> VertexContainer;
242  typedef std::vector<Edge*> EdgeContainer;
244  typedef std::vector<Face*> FaceContainer;
246  typedef std::vector<Volume*> VolumeContainer;
247 
249  typedef EdgeContainer::iterator AssociatedEdgeIterator;
251  typedef FaceContainer::iterator AssociatedFaceIterator;
253  typedef VolumeContainer::iterator AssociatedVolumeIterator;
254 
255  public:
257  // constructors and destructor
259 
262  Grid();
263 
265 
267  Grid(uint options);
268 
270 
272  Grid(const Grid& grid);
273 
274  virtual ~Grid();
275 
277 
283  Grid& operator = (const Grid& grid);
284 
286  // grid options
291  void set_options(uint options);
292  uint get_options() const;
293  void enable_options(uint options);
294  void disable_options(uint options);
295  bool option_is_enabled(uint option) const;
296 
298  // parallelism
300 
309  void set_parallel(bool parallel);
310 
312 
314  inline bool is_parallel() const;
315 
317 
324  inline DistributedGridManager* distributed_grid_manager();
325  inline const DistributedGridManager* distributed_grid_manager() const;
329  // periodic boundaries
331 
333  void set_periodic_boundaries(bool);
335  bool has_periodic_boundaries() const;
336 
338 
344  PeriodicBoundaryManager* periodic_boundary_manager();
345  const PeriodicBoundaryManager* periodic_boundary_manager() const;
350  // clear
352  void clear();
354  void clear_geometry();
356  void clear_attachments();
357 
359  // element creation
361 
366  template<class TGeomObj>
368  create(GridObject* pParent = NULL);
369 
371 
376  template <class TGeomObj>
378  create(const typename geometry_traits<TGeomObj>::Descriptor& descriptor,
379  GridObject* pParent = NULL);
380 
382 
396  template <class TGeomObj>
398  create_and_replace(typename geometry_traits<TGeomObj>::grid_base_object* pReplaceMe);
399 
401  VertexIterator create_by_cloning(Vertex* pCloneMe, GridObject* pParent = NULL);
402 
404  EdgeIterator create_by_cloning(Edge* pCloneMe, const IVertexGroup& ev, GridObject* pParent = NULL);
405 
407  FaceIterator create_by_cloning(Face* pCloneMe, const IVertexGroup& fv, GridObject* pParent = NULL);
408 
410  VolumeIterator create_by_cloning(Volume* pCloneMe, const IVertexGroup& vv, GridObject* pParent = NULL);
411 
413 
418  template <class TGeomObj>
419  void reserve(size_t num);
420 
422  // element deletion
423  void erase(GridObject* geomObj);
424  void erase(Vertex* vrt);
425  void erase(Edge* edge);
426  void erase(Face* face);
427  void erase(Volume* vol);
428 
430  template <class GeomObjIter>
431  void erase(const GeomObjIter& iterBegin, const GeomObjIter& iterEnd);
432 
433  template <class TGeomObj>
434  void clear();
435 
437  // replace
439 
455  bool replace_vertex(Vertex* vrtOld, Vertex* vrtNew);
456 
458 
465  bool replace_vertex_is_valid(Vertex* vrtOld, Vertex* vrtNew);
466 
468 
471  void objects_will_be_merged(Vertex* target, Vertex* elem1,
472  Vertex* elem2);
473  void objects_will_be_merged(Edge* target, Edge* elem1,
474  Edge* elem2);
475  void objects_will_be_merged(Face* target, Face* elem1,
476  Face* elem2);
477  void objects_will_be_merged(Volume* target, Volume* elem1,
478  Volume* elem2);
480  /*
482  template <class VrtPairIter>
483  void replace_vertices(VrtPairIter& iterBegin, VrtPairIter& iterEnd);
484  */
485 
487  // geometric-object-collection
489  virtual GridObjectCollection get_grid_objects();
490 
493  void flip_orientation(Edge* e);
494 
497  void flip_orientation(Face* f);
498 
501  void flip_orientation(Volume* vol);
502 
504  // Iterators
505  template <class TGeomObj>
507  begin();
508 
509  template <class TGeomObj>
511  end();
512 
513  inline VertexIterator vertices_begin() {return begin<Vertex>();}
514  inline VertexIterator vertices_end() {return end<Vertex>();}
515  inline EdgeIterator edges_begin() {return begin<Edge>();}
516  inline EdgeIterator edges_end() {return end<Edge>();}
517  inline FaceIterator faces_begin() {return begin<Face>();}
518  inline FaceIterator faces_end() {return end<Face>();}
519  inline VolumeIterator volumes_begin() {return begin<Volume>();}
520  inline VolumeIterator volumes_end() {return end<Volume>();}
521 
522  template <class TGeomObj>
524  begin() const;
525 
526  template <class TGeomObj>
528  end() const;
529 
531 
533  template <class TGeomObj> TGeomObj* front();
534 
536 
538  template <class TGeomObj> TGeomObj* back();
539 
540  // element manipulation
541  /*
542  void set_vertices(Edge* e, EdgeDesctiptor& ed);
543  void set_vertices(Face* f, FaceDescriptor& fd);
544  void set_vertices(Volume* v, VolumeDescriptor& vd);
545  */
546 
548  // element numbers
549  template <class TGeomObj>
550  size_t num() const;
551  inline size_t num_vertices() const {return num<Vertex>();}
552  inline size_t num_edges() const {return num<Edge>();}
553  inline size_t num_faces() const {return num<Face>();}
554  inline size_t num_volumes()const {return num<Volume>();}
555 
556  size_t vertex_fragmentation();
557  size_t edge_fragmentation();
558  size_t face_fragmentation();
559  size_t volume_fragmentation();
560 
562 
563  template <class TGeomObj>
564  size_t attachment_container_size() const;
565 
567  // connectivity-information
569  Edge* get_edge(Vertex* v1, Vertex* v2);
571 
572  Edge* get_edge(const EdgeVertices& ev);
574 
581  Edge* get_edge(Face* f, int ind);
583 
590  Edge* get_edge(Volume* v, int ind);
592 
593  Face* get_face(const FaceVertices& fv);
595 
602  Face* get_face(Volume* v, int ind);
604 
605  Volume* get_volume(const VolumeVertices& vv);
606 
608 
614  Edge* get_element(const EdgeVertices& ev) {return get_edge(ev);}
615  Face* get_element(const FaceVertices& fv) {return get_face(fv);}
616  Volume* get_element(const VolumeVertices& vv) {return get_volume(vv);}
620  Vertex* get_element(const VertexDescriptor& vd) {return vd.vertex();}
621 
622 
624  // access to the sides of an geometric object
626 
647  Vertex::side* get_side(Vertex* obj, size_t side);
648  Edge::side* get_side(Edge* obj, size_t side);
649  Face::side* get_side(Face* obj, size_t side);
650  Volume::side* get_side(Volume* obj, size_t side);
651 
653 
655  GridObject* get_opposing_object(Vertex* vrt, Face* elem);
656  GridObject* get_opposing_object(Vertex* vrt, Volume* elem);
661 
676  template <class TElem>
677  void associated_elements(traits<Vertex>::secure_container& elemsOut, TElem* e);
678  template <class TElem>
679  void associated_elements(traits<Edge>::secure_container& elemsOut, TElem* e);
680  template <class TElem>
681  void associated_elements(traits<Face>::secure_container& elemsOut, TElem* e);
682  template <class TElem>
683  void associated_elements(traits<Volume>::secure_container& elemsOut, TElem* e);
687 
711  template <class TElem>
712  void associated_elements_sorted(traits<Vertex>::secure_container& elemsOut, TElem* e);
713  template <class TElem>
714  void associated_elements_sorted(traits<Edge>::secure_container& elemsOut, TElem* e);
715  template <class TElem>
716  void associated_elements_sorted(traits<Face>::secure_container& elemsOut, TElem* e);
717  template <class TElem>
718  void associated_elements_sorted(traits<Volume>::secure_container& elemsOut, TElem* e);
719 
720 
722  // attachments
725  template <class TGeomObjClass>
726  void attach_to(IAttachment& attachment, bool passOnValues);
727 
728  inline void attach_to_vertices(IAttachment& attachment, bool passOnValues) {attach_to<Vertex>(attachment, passOnValues);}
729  inline void attach_to_edges(IAttachment& attachment, bool passOnValues) {attach_to<Edge>(attachment, passOnValues);}
730  inline void attach_to_faces(IAttachment& attachment, bool passOnValues) {attach_to<Face>(attachment, passOnValues);}
731  inline void attach_to_volumes(IAttachment& attachment, bool passOnValues) {attach_to<Volume>(attachment, passOnValues);}
732 
733  inline void attach_to_all(IAttachment& attachment, bool passOnValues);
734 
737  template <class TGeomObjClass>
738  inline void attach_to(IAttachment& attachment) {attach_to<TGeomObjClass>(attachment, attachment.default_pass_on_behaviour());}
739 
740  inline void attach_to_vertices(IAttachment& attachment) {attach_to<Vertex>(attachment);}
741  inline void attach_to_edges(IAttachment& attachment) {attach_to<Edge>(attachment);}
742  inline void attach_to_faces(IAttachment& attachment) {attach_to<Face>(attachment);}
743  inline void attach_to_volumes(IAttachment& attachment) {attach_to<Volume>(attachment);}
744 
746  inline void attach_to_all(IAttachment& attachment);
747 
749  // attach with specified default value and default pass-on behaviour
750  template <class TGeomObjClass, class TAttachment>
751  void attach_to_dv(TAttachment& attachment, const typename TAttachment::ValueType& defaultValue);
752 
753  template <class TAttachment>
754  inline void attach_to_vertices_dv(TAttachment& attachment, const typename TAttachment::ValueType& defaultValue) {attach_to_dv<Vertex>(attachment, defaultValue);}
755  template <class TAttachment>
756  inline void attach_to_edges_dv(TAttachment& attachment, const typename TAttachment::ValueType& defaultValue) {attach_to_dv<Edge>(attachment, defaultValue);}
757  template <class TAttachment>
758  inline void attach_to_faces_dv(TAttachment& attachment, const typename TAttachment::ValueType& defaultValue) {attach_to_dv<Face>(attachment, defaultValue);}
759  template <class TAttachment>
760  inline void attach_to_volumes_dv(TAttachment& attachment, const typename TAttachment::ValueType& defaultValue) {attach_to_dv<Volume>(attachment, defaultValue);}
761 
763  template <class TAttachment>
764  inline void attach_to_all_dv(TAttachment& attachment, const typename TAttachment::ValueType& defaultValue);
765 
767  // attach with specified default value and custom pass-on behaviour
768  template <class TGeomObjClass, class TAttachment>
769  void attach_to_dv(TAttachment& attachment, const typename TAttachment::ValueType& defaultValue, bool passOnValues);
770 
771  template <class TAttachment>
772  inline void attach_to_vertices_dv(TAttachment& attachment, const typename TAttachment::ValueType& defaultValue, bool passOnValues) {attach_to_dv<Vertex>(attachment, defaultValue, passOnValues);}
773  template <class TAttachment>
774  inline void attach_to_edges_dv(TAttachment& attachment, const typename TAttachment::ValueType& defaultValue, bool passOnValues) {attach_to_dv<Edge>(attachment, defaultValue, passOnValues);}
775  template <class TAttachment>
776  inline void attach_to_faces_dv(TAttachment& attachment, const typename TAttachment::ValueType& defaultValue, bool passOnValues) {attach_to_dv<Face>(attachment, defaultValue, passOnValues);}
777  template <class TAttachment>
778  inline void attach_to_volumes_dv(TAttachment& attachment, const typename TAttachment::ValueType& defaultValue, bool passOnValues) {attach_to_dv<Volume>(attachment, defaultValue, passOnValues);}
779 
780  template <class TAttachment>
781  inline void attach_to_all_dv(TAttachment& attachment, const typename TAttachment::ValueType& defaultValue, bool passOnValues);
783  // detach
784  template <class TGeomObjClass>
785  void detach_from(IAttachment& attachment);
786 
787  inline void detach_from_vertices(IAttachment& attachment) {detach_from<Vertex>(attachment);}
788  inline void detach_from_edges(IAttachment& attachment) {detach_from<Edge>(attachment);}
789  inline void detach_from_faces(IAttachment& attachment) {detach_from<Face>(attachment);}
790  inline void detach_from_volumes(IAttachment& attachment) {detach_from<Volume>(attachment);}
791 
792  inline void detach_from_all(IAttachment& attachment);
793 
794 
795  template <class TGeomObjClass>
796  inline bool has_attachment(IAttachment& attachment) {return get_attachment_pipe<TGeomObjClass>().has_attachment(attachment);}
797 
798  inline bool has_vertex_attachment(IAttachment& attachment) {return has_attachment<Vertex>(attachment);}
799  inline bool has_edge_attachment(IAttachment& attachment) {return has_attachment<Edge>(attachment);}
800  inline bool has_face_attachment(IAttachment& attachment) {return has_attachment<Face>(attachment);}
801  inline bool has_volume_attachment(IAttachment& attachment) {return has_attachment<Volume>(attachment);}
802 
804  // direct attachment access
805  template <class TGeomObj>
806  uint get_attachment_data_index(TGeomObj* pObj) const;
807 
808  template <class TGeomObj, class TAttachment>
809  typename TAttachment::ContainerType*
810  get_attachment_data_container(TAttachment& attachment);
811 
813 
817  template <class TGeomObj>
818  typename traits<TGeomObj>::AttachmentPipe&
819  get_attachment_pipe();
820 
822  // observers
826  void register_observer(GridObserver* observer, uint observerType = OT_FULL_OBSERVER);
827  void unregister_observer(GridObserver* observer);
828 
829 /*
830  template <class GeomObjClass>
831  util::IAttachmentDataContainer* get_data_container(util::IAttachment& attachment);
832 
833  util::IAttachmentDataContainer* get_vertex_data_container(util::IAttachment& attachment) {return get_data_container<Vertex>(attachment);}
834  util::IAttachmentDataContainer* get_edge_data_container(util::IAttachment& attachment) {return get_data_container<Edge>(attachment);}
835  util::IAttachmentDataContainer* get_face_data_container(util::IAttachment& attachment) {return get_data_container<Face>(attachment);}
836  util::IAttachmentDataContainer* get_volume_data_container(util::IAttachment& attachment) {return get_data_container<Volume>(attachment);}
837 */
838 
840  // pass_on_values
841  void pass_on_values(Vertex* objSrc, Vertex* objDest);
842  void pass_on_values(Edge* objSrc, Edge* objDest);
843  void pass_on_values(Face* objSrc, Face* objDest);
844  void pass_on_values(Volume* objSrc, Volume* objDest);
845 
846  // subject to change!
847  AssociatedEdgeIterator associated_edges_begin(Vertex* vrt);
848  AssociatedEdgeIterator associated_edges_end(Vertex* vrt);
849  AssociatedEdgeIterator associated_edges_begin(Face* face);
850  AssociatedEdgeIterator associated_edges_end(Face* face);
851  AssociatedEdgeIterator associated_edges_begin(Volume* vol);
852  AssociatedEdgeIterator associated_edges_end(Volume* vol);
853 
854  AssociatedFaceIterator associated_faces_begin(Vertex* vrt);
855  AssociatedFaceIterator associated_faces_end(Vertex* vrt);
856  AssociatedFaceIterator associated_faces_begin(Edge* edge);
857  AssociatedFaceIterator associated_faces_end(Edge* edge);
858  AssociatedFaceIterator associated_faces_begin(Volume* vol);
859  AssociatedFaceIterator associated_faces_end(Volume* vol);
860 
861  AssociatedVolumeIterator associated_volumes_begin(Vertex* vrt);
862  AssociatedVolumeIterator associated_volumes_end(Vertex* vrt);
863  AssociatedVolumeIterator associated_volumes_begin(Edge* edge);
864  AssociatedVolumeIterator associated_volumes_end(Edge* edge);
865  AssociatedVolumeIterator associated_volumes_begin(Face* face);
866  AssociatedVolumeIterator associated_volumes_end(Face* face);
867 
869  // advanced element manipulation
870  inline void register_element(Vertex* v, GridObject* pParent = NULL) {register_vertex(v, pParent);}
871  inline void unregister_element(Vertex* v) {unregister_vertex(v);}
872  inline void register_element(Edge* e, GridObject* pParent = NULL) {register_edge(e, pParent);}
873  inline void unregister_element(Edge* e) {unregister_edge(e);}
874  inline void register_element(Face* f, GridObject* pParent = NULL) {register_face(f, pParent);}
875  inline void unregister_element(Face* f) {unregister_face(f);}
876  inline void register_element(Volume* v, GridObject* pParent = NULL) {register_volume(v, pParent);}
877  inline void unregister_element(Volume* v) {unregister_volume(v);}
878 
881  void register_and_replace_element(Vertex* v, Vertex* pReplaceMe);
882  void register_and_replace_element(Edge* e, Edge* pReplaceMe);
883  void register_and_replace_element(Face* f, Face* pReplaceMe);
884  void register_and_replace_element(Volume* v, Volume* pReplaceMe);
886 
888  // marks
890 
894  void begin_marking();
896 
897  void clear_marks();
898 
900 
902  inline void mark(GridObject* obj);
903  inline void mark(Vertex* obj);
904  inline void mark(Edge* obj);
905  inline void mark(Face* obj);
906  inline void mark(Volume* obj);
910 
912  template <class TIterator>
913  void mark(TIterator begin, TIterator end);
914 
916 
918  inline void unmark(GridObject* obj);
919  inline void unmark(Vertex* obj);
920  inline void unmark(Edge* obj);
921  inline void unmark(Face* obj);
922  inline void unmark(Volume* obj);
926 
928  template <class TIterator>
929  void unmark(TIterator begin, TIterator end);
930 
932 
934  inline bool is_marked(GridObject* obj) const;
935  inline bool is_marked(Vertex* obj) const;
936  inline bool is_marked(Edge* obj) const;
937  inline bool is_marked(Face* obj) const;
938  inline bool is_marked(Volume* obj) const;
942  void end_marking();
943 
945  SPMessageHub message_hub() {return m_messageHub;}
946 
948  void test_attached_linked_lists();
949 
950  protected:
951  typedef std::vector<GridObserver*> ObserverContainer;
952 
957 
959 
960  protected:
962 
968  void notify_and_clear_observers_on_grid_destruction(GridObserver* initiator = NULL);
969 
971  template <class TElem> inline
975  element_storage(m_vertexElementStorage, m_edgeElementStorage,
976  m_faceElementStorage, m_volumeElementStorage);
977  }
978 
980  template <class TElem> inline
981  const typename traits<TElem>::ElementStorage&
984  element_storage(m_vertexElementStorage, m_edgeElementStorage,
985  m_faceElementStorage, m_volumeElementStorage);
986  }
987 
989 
991  void assign_grid(const Grid& grid);
992 
994 
996  inline void assign_hash_value(Vertex* vrt) {vrt->m_hashValue = m_hashCounter++;}
997 
998  void register_vertex(Vertex* v, GridObject* pParent = NULL);
999  void unregister_vertex(Vertex* v);
1000  void register_edge(Edge* e, GridObject* pParent = NULL,
1001  Face* createdByFace = NULL, Volume* createdByVol = NULL);
1002  void unregister_edge(Edge* e);
1003  void register_face(Face* f, GridObject* pParent = NULL,
1004  Volume* createdByVol = NULL);
1005  void unregister_face(Face* f);
1006  void register_volume(Volume* v, GridObject* pParent = NULL);
1007  void unregister_volume(Volume* v);
1008 
1009  void change_options(uint optsNew);
1010 
1011  void change_vertex_options(uint optsNew);
1012  void change_edge_options(uint optsNew);
1013  void change_face_options(uint optsNew);
1014  void change_volume_options(uint optsNew);
1015 
1016  void vertex_store_associated_edges(bool bStoreIt);
1017  void vertex_store_associated_faces(bool bStoreIt);
1018  void vertex_store_associated_volumes(bool bStoreIt);
1019  void edge_store_associated_faces(bool bStoreIt);
1020  void edge_store_associated_volumes(bool bStoreIt);
1021  void face_store_associated_edges(bool bStoreIt);
1022  void face_store_associated_volumes(bool bStoreIt);
1023  void face_autogenerate_edges(bool bAutogen);
1024  void volume_store_associated_edges(bool bStoreIt);
1025  void volume_store_associated_faces(bool bStoreIt);
1026  void volume_autogenerate_edges(bool bAutogen);
1027  void volume_autogenerate_faces(bool bAutogen);
1028 
1029  void volume_sort_associated_edge_container();
1030 
1031  template <class TAttachmentPipe, class TElem>
1032  void pass_on_values(TAttachmentPipe& attachmentPipe,
1033  TElem* pSrc, TElem* pDest);
1034 
1035  // some methods that simplify auto-enabling of grid options
1036  inline void autoenable_option(uint option, const char* caller, const char* optionName);
1037 
1038  // neighbourhood access
1039  template <class TGeomObj>
1040  Edge* find_edge_in_associated_edges(TGeomObj* obj,
1041  const EdgeVertices& ev);
1042 
1043  template <class TGeomObj>
1044  Face* find_face_in_associated_faces(TGeomObj* obj,
1045  const FaceVertices& fv);
1046 
1047  template <class TGeomObj>
1048  Volume* find_volume_in_associated_volumes(TGeomObj* obj,
1049  const VolumeVertices& vv);
1050 
1051  // get associated elements
1052  void get_associated(SecureVertexContainer& vrts, Edge* e);
1053  void get_associated(SecureVertexContainer& vrts, Face* f);
1054  void get_associated(SecureVertexContainer& vrts, Volume* v);
1055 
1056  void get_associated(SecureEdgeContainer& edges, Vertex* v);
1059 
1063 
1067 
1068  template <class TContainer>
1069  void get_associated(TContainer& container, GridObject* o);
1070 
1071  template <class TElem>
1072  void get_associated(typename traits<typename TElem::grid_base_object>
1073  ::secure_container& elems, TElem* e);
1074 
1077  void get_associated_vols_raw(SecureVolumeContainer& vols, Face* f);
1078 
1079  void get_associated_sorted(SecureVertexContainer& vrts, Edge* e) const;
1080  void get_associated_sorted(SecureVertexContainer& vrts, Face* f) const;
1081  void get_associated_sorted(SecureVertexContainer& vrts, Volume* v) const;
1082 
1083  void get_associated_sorted(SecureEdgeContainer& edges, Vertex* v);
1084  void get_associated_sorted(SecureEdgeContainer& edges, Face* f);
1085  void get_associated_sorted(SecureEdgeContainer& edges, Volume* v);
1086 
1088  void get_associated_sorted(SecureFaceContainer& faces, Edge* e);
1090 
1094 
1095  template <class TElem>
1096  void get_associated_sorted(typename traits<typename TElem::grid_base_object>
1097  ::secure_container& elems, TElem* e);
1098 
1099 
1101 
1103  template <class TAttachmentPipe>
1104  void copy_user_attachments(const TAttachmentPipe& apSrc, TAttachmentPipe& apDest,
1105  std::vector<int>& srcDataIndices);
1106 
1107  // marks
1108  void init_marks();
1109  void reset_marks();
1110  void remove_marks();
1111 
1112  protected:
1114 
1119  {
1120  return m_vertexElementStorage.m_sectionContainer.
1121  get_container().get_iterator(o);
1122  }
1123 
1124  inline traits<Edge>::SectionContainer::iterator
1126  {
1127  return m_edgeElementStorage.m_sectionContainer.
1128  get_container().get_iterator(o);
1129  }
1130 
1131  inline traits<Face>::SectionContainer::iterator
1133  {
1134  return m_faceElementStorage.m_sectionContainer.
1135  get_container().get_iterator(o);
1136  }
1137 
1138  inline traits<Volume>::SectionContainer::iterator
1140  {
1141  return m_volumeElementStorage.m_sectionContainer.
1142  get_container().get_iterator(o);
1143  }
1148  template <class TElem>
1149  void clear_attachments();
1150 
1151  protected:
1156 
1159 
1160  // observer handling
1166 
1167  // interconnection management
1172 
1176 
1180 
1184 
1188 
1189  // marks
1190  int m_currentMark; // 0: marks inactive. -1: reset-marks (sets currentMark to 1)
1197 
1201 };
1202 
1204 }//end of namespace
1205 
1206 #include "grid_impl.hpp"
1207 
1208 #endif
A linked list of elements living in an attachment.
Definition: attached_list.h:182
A special iterator which allows to iterate over elements in a AttachedElementList.
Definition: attached_list.h:52
Used to access data that has been attached to an attachment pipe.
Definition: attachment_pipe.h:510
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
bool access(Grid &grid, TAttachment &a)
Definition: grid.h:189
Definition: grid.h:211
Definition: grid.h:221
Manages the elements of a grid and their interconnection.
Definition: grid.h:132
SPMessageHub message_hub()
gives access to the grid's message-hub
Definition: grid.h:945
bool has_volume_attachment(IAttachment &attachment)
Definition: grid.h:801
traits< TElem >::ElementStorage & element_storage()
returns the element storage for a given element type
Definition: grid.h:973
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
EdgeElementStorage m_edgeElementStorage
Definition: grid.h:1153
VolumeIterator volumes_begin()
Definition: grid.h:519
void get_associated_sorted(SecureVolumeContainer &vols, Edge *e)
void register_element(Face *f, GridObject *pParent=NULL)
Definition: grid.h:874
void get_associated(SecureEdgeContainer &edges, Volume *v)
void get_associated(SecureFaceContainer &faces, Edge *e)
Attachment< EdgeContainer > AEdgeContainer
Definition: grid.h:954
VolumeAttachmentAccessor< AMark > m_aaMarkVOL
Definition: grid.h:1196
FaceIterator faces_end()
Definition: grid.h:518
void attach_to_edges_dv(TAttachment &attachment, const typename TAttachment::ValueType &defaultValue, bool passOnValues)
Definition: grid.h:774
void unregister_element(Vertex *v)
Definition: grid.h:871
traits< Face >::secure_container SecureFaceContainer
Container to store associated faces.
Definition: grid.h:166
AttachmentAccessor< Face, AVolumeContainer > m_aaVolumeContainerFACE
Definition: grid.h:1183
bool m_bMarking
Definition: grid.h:1191
ObserverContainer m_vertexObservers
Definition: grid.h:1162
std::vector< GridObserver * > ObserverContainer
Definition: grid.h:951
std::vector< Volume * > VolumeContainer
Container used to store associated volumes.
Definition: grid.h:246
AVertexContainer m_aVertexContainer
Definition: grid.h:1168
void attach_to_volumes_dv(TAttachment &attachment, const typename TAttachment::ValueType &defaultValue)
Definition: grid.h:760
EdgeIterator edges_begin()
Definition: grid.h:515
void register_element(Vertex *v, GridObject *pParent=NULL)
Definition: grid.h:870
uint32 m_hashCounter
Definition: grid.h:1158
void attach_to_vertices_dv(TAttachment &attachment, const typename TAttachment::ValueType &defaultValue, bool passOnValues)
Definition: grid.h:772
traits< Volume >::SectionContainer::iterator get_iterator(Volume *o)
returns the iterator at which the given element lies in the section container
Definition: grid.h:1139
void attach_to_vertices_dv(TAttachment &attachment, const typename TAttachment::ValueType &defaultValue)
Definition: grid.h:754
bool has_face_attachment(IAttachment &attachment)
Definition: grid.h:800
SPMessageHub m_messageHub
Definition: grid.h:1198
void get_associated(SecureVolumeContainer &vols, Face *f)
PeriodicBoundaryManager * m_periodicBndMgr
Definition: grid.h:1200
VertexIterator vertices_begin()
Definition: grid.h:513
void get_associated_sorted(SecureVolumeContainer &vols, Vertex *v)
VertexElementStorage m_vertexElementStorage
Definition: grid.h:1152
DistributedGridManager * m_distGridMgr
Definition: grid.h:1199
void attach_to_edges(IAttachment &attachment, bool passOnValues)
Definition: grid.h:729
void get_associated(SecureFaceContainer &faces, Vertex *v)
Attachment< FaceContainer > AFaceContainer
Definition: grid.h:955
Attachment< VolumeContainer > AVolumeContainer
Definition: grid.h:956
void attach_to_edges_dv(TAttachment &attachment, const typename TAttachment::ValueType &defaultValue)
Definition: grid.h:756
void get_associated(SecureFaceContainer &faces, Volume *v)
traits< Vertex >::secure_container SecureVertexContainer
Container to store associated vertices.
Definition: grid.h:162
VertexIterator vertices_end()
Definition: grid.h:514
AEdgeContainer m_aEdgeContainer
Definition: grid.h:1169
AttachmentAccessor< Volume, AVolumeContainer > m_aaVolumeContainerVOLUME
Definition: grid.h:1187
Face * get_element(const FaceVertices &fv)
returns the element for the given vertices.
Definition: grid.h:615
void attach_to_edges(IAttachment &attachment)
Definition: grid.h:741
VolumeContainer::iterator AssociatedVolumeIterator
used to iterate over associated volumes of vertices, edges and faces
Definition: grid.h:253
void register_element(Volume *v, GridObject *pParent=NULL)
Definition: grid.h:876
bool has_attachment(IAttachment &attachment)
Definition: grid.h:796
size_t num_volumes() const
Definition: grid.h:554
ug::AttachmentPipe< Edge *, EdgeElementStorage > EdgeAttachmentPipe
Definition: grid.h:172
void assign_hash_value(Vertex *vrt)
assigns a unique hash value to a Vertex.
Definition: grid.h:996
Volume * get_element(const VolumeVertices &vv)
returns the element for the given vertices.
Definition: grid.h:616
int m_currentMark
Definition: grid.h:1190
std::vector< Vertex * > VertexContainer
Container used to store associated vertices.
Definition: grid.h:240
FaceElementStorage m_faceElementStorage
Definition: grid.h:1154
Vertex * get_element(const VertexDescriptor &vd)
This overload is only useful to avoid compile issues in templated code.
Definition: grid.h:620
void attach_to_vertices(IAttachment &attachment)
Definition: grid.h:740
AttachmentAccessor< Vertex, AFaceContainer > m_aaFaceContainerVERTEX
Definition: grid.h:1174
void detach_from_volumes(IAttachment &attachment)
Definition: grid.h:790
VertexAttachmentAccessor< AMark > m_aaMarkVRT
Definition: grid.h:1193
VolumeIterator volumes_end()
Definition: grid.h:520
void attach_to_faces_dv(TAttachment &attachment, const typename TAttachment::ValueType &defaultValue)
Definition: grid.h:758
AVolumeContainer m_aVolumeContainer
Definition: grid.h:1171
std::vector< Edge * > EdgeContainer
Container used to store associated edges.
Definition: grid.h:242
void attach_to(IAttachment &attachment)
attach with default pass-on behaviour and unspecified default value.
Definition: grid.h:738
void attach_to_faces(IAttachment &attachment)
Definition: grid.h:742
void get_associated(SecureEdgeContainer &edges, Face *f)
AttachmentAccessor< Vertex, AEdgeContainer > m_aaEdgeContainerVERTEX
Definition: grid.h:1173
size_t num_faces() const
Definition: grid.h:553
void attach_to_volumes(IAttachment &attachment)
Definition: grid.h:743
AMark m_aMark
Definition: grid.h:1192
void attach_to_volumes(IAttachment &attachment, bool passOnValues)
Definition: grid.h:731
size_t num_vertices() const
Definition: grid.h:551
ObserverContainer m_gridObservers
Definition: grid.h:1161
ug::AttachmentPipe< Vertex *, VertexElementStorage > VertexAttachmentPipe
the attachment-pipe used by Grid
Definition: grid.h:171
ObserverContainer m_faceObservers
Definition: grid.h:1164
void get_associated(SecureVolumeContainer &vols, Edge *e)
ObserverContainer m_edgeObservers
Definition: grid.h:1163
void detach_from_vertices(IAttachment &attachment)
Definition: grid.h:787
AttachmentAccessor< Face, AFaceContainer > m_aaFaceContainerFACE
Definition: grid.h:1182
void attach_to_volumes_dv(TAttachment &attachment, const typename TAttachment::ValueType &defaultValue, bool passOnValues)
Definition: grid.h:778
ug::AttachmentPipe< Face *, FaceElementStorage > FaceAttachmentPipe
Definition: grid.h:173
uint m_options
Definition: grid.h:1157
AttachmentAccessor< Edge, AVolumeContainer > m_aaVolumeContainerEDGE
Definition: grid.h:1179
void get_associated_sorted(SecureVolumeContainer &vols, Face *f)
AttachmentAccessor< Vertex, AVolumeContainer > m_aaVolumeContainerVERTEX
Definition: grid.h:1175
Edge * get_element(const EdgeVertices &ev)
returns the element for the given vertices.
Definition: grid.h:614
void attach_to_faces(IAttachment &attachment, bool passOnValues)
Definition: grid.h:730
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 detach_from_edges(IAttachment &attachment)
Definition: grid.h:788
void unregister_element(Volume *v)
Definition: grid.h:877
bool has_vertex_attachment(IAttachment &attachment)
Definition: grid.h:798
AttachmentAccessor< Face, AEdgeContainer > m_aaEdgeContainerFACE
Definition: grid.h:1181
traits< Face >::SectionContainer::iterator get_iterator(Face *o)
returns the iterator at which the given element lies in the section container
Definition: grid.h:1132
ObserverContainer m_volumeObservers
Definition: grid.h:1165
void unregister_element(Face *f)
Definition: grid.h:875
EdgeAttachmentAccessor< AMark > m_aaMarkEDGE
Definition: grid.h:1194
size_t num_edges() const
Definition: grid.h:552
void register_element(Edge *e, GridObject *pParent=NULL)
Definition: grid.h:872
FaceAttachmentAccessor< AMark > m_aaMarkFACE
Definition: grid.h:1195
void get_associated_sorted(SecureFaceContainer &faces, Vertex *v)
bool has_edge_attachment(IAttachment &attachment)
Definition: grid.h:799
void unregister_element(Edge *e)
Definition: grid.h:873
void attach_to_vertices(IAttachment &attachment, bool passOnValues)
Definition: grid.h:728
AttachmentAccessor< Edge, AEdgeContainer > m_aaEdgeContainerEDGE
Definition: grid.h:1177
void get_associated_sorted(SecureFaceContainer &faces, Volume *v)
void attach_to_faces_dv(TAttachment &attachment, const typename TAttachment::ValueType &defaultValue, bool passOnValues)
Definition: grid.h:776
const traits< TElem >::ElementStorage & element_storage() const
returns the const element storage for a given element type
Definition: grid.h:982
traits< Volume >::secure_container SecureVolumeContainer
Container to store associated volumes.
Definition: grid.h:168
void get_associated(SecureVolumeContainer &vols, Vertex *v)
ug::AttachmentPipe< Volume *, VolumeElementStorage > VolumeAttachmentPipe
Definition: grid.h:174
FaceContainer::iterator AssociatedFaceIterator
used to iterate over associated faces of vertices, edges and volumes
Definition: grid.h:251
FaceIterator faces_begin()
Definition: grid.h:517
Attachment< VertexContainer > AVertexContainer
Definition: grid.h:953
AFaceContainer m_aFaceContainer
Definition: grid.h:1170
EdgeIterator edges_end()
Definition: grid.h:516
traits< Edge >::secure_container SecureEdgeContainer
Container to store associated edges.
Definition: grid.h:164
std::vector< Face * > FaceContainer
Container used to store associated faces.
Definition: grid.h:244
Attachment< int > AMark
Definition: grid.h:958
traits< Edge >::SectionContainer::iterator get_iterator(Edge *o)
returns the iterator at which the given element lies in the section container
Definition: grid.h:1125
AttachmentAccessor< Volume, AEdgeContainer > m_aaEdgeContainerVOLUME
Definition: grid.h:1185
VolumeElementStorage m_volumeElementStorage
Definition: grid.h:1155
void detach_from_faces(IAttachment &attachment)
Definition: grid.h:789
AttachmentAccessor< Edge, AFaceContainer > m_aaFaceContainerEDGE
Definition: grid.h:1178
AttachmentAccessor< Volume, AFaceContainer > m_aaFaceContainerVOLUME
Definition: grid.h:1186
a helper class that holds a collection of possibly unconnected geometric-objects.
Definition: grid_object_collection.h:96
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
Definition: grid_observer.h:80
the interface for attachments.
Definition: attachment_pipe.h:239
virtual bool default_pass_on_behaviour() const =0
Base class for all classes which consist of a group of vertices.
Definition: grid_base_objects.h:317
Definition: periodic_boundary_manager.h:99
Container which holds an array of pointers.
Definition: pointer_const_array.h:84
This descriptor is mainly useful to avoid compilation errors in templated code.
Definition: grid_base_objects.h:285
Vertex * vertex() const
Definition: grid_base_objects.h:299
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
uint32 m_hashValue
Definition: grid_base_objects.h:275
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
Definition: grid_base_object_traits.h:68
traits< Face > face_traits
Definition: grid.h:157
traits< Edge > edge_traits
Definition: grid.h:156
traits< Volume > volume_traits
Definition: grid.h:158
traits< Vertex > vertex_traits
Convenience access to grid elements.
Definition: grid.h:155
virtual void clear_attachments(typename TDomain::grid_type &grid)
ugtypes::uint32_t uint32
Definition: types.h:116
#define UG_API
Definition: ug_config.h:65
unsigned int uint
Definition: types.h:114
function util LuaCallbackHelper create(func)
size_t target(SM_edge< typename T::value_type > const &e, ug::BidirectionalMatrix< T > const &m)
Definition: bidirectional_boost.h:100
the ug namespace
ElementStorage< Vertex >::SectionContainer::iterator VertexIterator
This Iterator will be used as base-class for iterators of specialized geometric objects.
Definition: grid_base_object_traits.h:73
ElementStorage< Face >::SectionContainer::iterator FaceIterator
Definition: grid_base_object_traits.h:79
ElementStorage< Edge >::SectionContainer::iterator EdgeIterator
Definition: grid_base_object_traits.h:76
@ OT_FULL_OBSERVER
Definition: grid_observer.h:59
ElementStorage< Volume >::SectionContainer::iterator VolumeIterator
Definition: grid_base_object_traits.h:82
Helper class to access the correct element storage from its element type.
Definition: element_storage.h:148
The traits class holds some important types for each element-type.
Definition: grid.h:136
ug::ElementStorage< base_object > ElementStorage
Definition: grid.h:138
boost::function< bool(base_object *)> callback
callback type for the elements base type.
Definition: grid.h:150
ElementStorage::AttachmentPipe AttachmentPipe
Definition: grid.h:139
geometry_traits< TElem >::const_iterator const_iterator
Definition: grid.h:144
TElem::grid_base_object base_object
Definition: grid.h:137
geometry_traits< TElem >::iterator iterator
Definition: grid.h:143
ElementStorage::SectionContainer SectionContainer
Definition: grid.h:141
PointerConstArray< TElem * > secure_container
Definition: grid.h:146
ElementStorage::AttachedElementList AttachedElementList
Definition: grid.h:140