ug4
grid_impl.hpp
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_IMPLEMENTATION__
34 #define __H__LIB_GRID__GRID_IMPLEMENTATION__
35 
36 //#include <cassert>
37 #include "common/common.h"
38 #include "common/static_assert.h"
39 #include "grid_util.h"
40 #include "grid.h"
41 
42 namespace ug
43 {
45 // parallelism
46 bool Grid::
47 is_parallel() const
48 {
49  return m_distGridMgr != NULL;
50 }
51 
54 {
55  return m_distGridMgr;
56 }
57 
60 {
61  return m_distGridMgr;
62 }
63 
64 
66 // create functions
67 template<class TGeomObj>
70 {
73  invalid_geometry_type);
74 
75  TGeomObj* geomObj = new TGeomObj;
76 // int baseObjectType = geometry_traits<GeomObjType>::base_object_type();
77 // geomObj->m_elemHandle = m_elementStorage[baseObjectType].m_sectionContainer.insert_element(geomObj, geometry_traits<GeomObjType>::container_section());
78 // m_elementStorage[baseObjectType].m_attachmentPipe.register_element(geomObj);
79 
80  register_element(geomObj, pParent);
81 
82  return iterator_cast<typename geometry_traits<TGeomObj>::iterator>(get_iterator(geomObj));
83 }
84 
85 template <class TGeomObj>
88  GridObject* pParent)
89 {
92  invalid_geometry_type);
93 
94  TGeomObj* geomObj = new TGeomObj(descriptor);
95 
96 // int baseObjectType = geometry_traits<TGeomObj>::base_object_type();
97 // geomObj->m_elemHandle = m_elementStorage[baseObjectType].m_sectionContainer.insert_element(geomObj, geometry_traits<GeomObjType>::container_section());
98 // m_elementStorage[baseObjectType].m_attachmentPipe.register_element(geomObj);
99 
100  register_element(geomObj, pParent);
101 
102  return iterator_cast<typename geometry_traits<TGeomObj>::iterator>(get_iterator(geomObj));
103 }
104 
105 template<class TGeomObj>
108 {
111  invalid_geometry_type);
112 
113  TGeomObj* geomObj = new TGeomObj;
114 
115  if(geomObj->reference_object_id() == pReplaceMe->reference_object_id())
116  {
117  register_and_replace_element(geomObj, pReplaceMe);
118  return iterator_cast<typename geometry_traits<TGeomObj>::iterator>(get_iterator(geomObj));
119  }
120  else
121  {
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!");
124  delete geomObj;
125  return end<TGeomObj>();
126  }
127 }
128 
130 template <class TGeomObj>
131 void Grid::reserve(size_t num)
132 {
134  invalid_geometry_type);
135 
136  element_storage<TGeomObj>().m_attachmentPipe.reserve(num);
137 }
138 
140 // erase
141 template <class GeomObjIter>
142 void Grid::erase(const GeomObjIter& iterBegin, const GeomObjIter& iterEnd)
143 {
144  GeomObjIter iter = iterBegin;
145  while(iter != iterEnd)
146  {
147  GeomObjIter tmpIter = iter;
148  ++iter;
149  erase(*tmpIter);
150  }
151 }
152 
153 template <class TGeomObj>
155 {
156  while(begin<TGeomObj>() != end<TGeomObj>())
157  erase(*begin<TGeomObj>());
158 }
159 
161 // Iterators
162 template <class TGeomObj>
165 {
167  invalid_GeomObj);
168 
169  return iterator_cast<typename geometry_traits<TGeomObj>::iterator>
170  (element_storage<TGeomObj>().m_sectionContainer.section_begin(geometry_traits<TGeomObj>::CONTAINER_SECTION));
171 }
172 
173 template <class TGeomObj>
176 {
178  invalid_GeomObj);
179 
180  return iterator_cast<typename geometry_traits<TGeomObj>::iterator>
181  (element_storage<TGeomObj>().m_sectionContainer.section_end(geometry_traits<TGeomObj>::CONTAINER_SECTION));
182 }
183 
184 template <class TGeomObj>
186 Grid::begin() const
187 {
189  invalid_GeomObj);
190 
191  return iterator_cast<typename geometry_traits<TGeomObj>::const_iterator>
192  (element_storage<TGeomObj>().m_sectionContainer.section_begin(geometry_traits<TGeomObj>::CONTAINER_SECTION));
193 }
194 
195 template <class TGeomObj>
197 Grid::end() const
198 {
200  invalid_GeomObj);
201 
202  return iterator_cast<typename geometry_traits<TGeomObj>::const_iterator>
203  (element_storage<TGeomObj>().m_sectionContainer.section_end(geometry_traits<TGeomObj>::CONTAINER_SECTION));
204 }
205 
206 template <class TGeomObj>
207 TGeomObj*
209 {
211  invalid_GeomObj);
212 
213  return static_cast<TGeomObj*>(*element_storage<TGeomObj>().m_sectionContainer.
215 }
216 
217 template <class TGeomObj>
218 TGeomObj*
220 {
222  invalid_GeomObj);
223 
224  return static_cast<TGeomObj*>(*element_storage<TGeomObj>().m_sectionContainer.
226 }
228 // element numbers
229 template <class TGeomObj>
230 size_t Grid::num() const
231 {
233  invalid_GeomObj);
234 
236 
237  if(secIndex == -1)
238  return element_storage<TGeomObj>().m_sectionContainer.num_elements();
239 
240  return element_storage<TGeomObj>().m_sectionContainer.num_elements(secIndex);
241 }
242 
243 inline void Grid::
245  Vertex* elem2)
246 {
247  for(Grid::ObserverContainer::iterator iter = m_vertexObservers.begin();
248  iter != m_vertexObservers.end(); iter++)
249  {
250  (*iter)->vertices_to_be_merged(this, target, elem1, elem2);
251  }
252 }
253 
254 inline void Grid::
256  Edge* elem2)
257 {
258  for(Grid::ObserverContainer::iterator iter = m_edgeObservers.begin();
259  iter != m_edgeObservers.end(); iter++)
260  {
261  (*iter)->edges_to_be_merged(this, target, elem1, elem2);
262  }
263 }
264 
265 inline void Grid::
267  Face* elem2)
268 {
269  for(Grid::ObserverContainer::iterator iter = m_faceObservers.begin();
270  iter != m_faceObservers.end(); iter++)
271  {
272  (*iter)->faces_to_be_merged(this, target, elem1, elem2);
273  }
274 }
275 
276 inline void Grid::
278  Volume* elem2)
279 {
280  for(Grid::ObserverContainer::iterator iter = m_volumeObservers.begin();
281  iter != m_volumeObservers.end(); iter++)
282  {
283  (*iter)->volumes_to_be_merged(this, target, elem1, elem2);
284  }
285 }
286 
287 template <class TGeomObj>
289 {
290  return element_storage<TGeomObj>().m_attachmentPipe.num_data_entries();
291 }
292 
294 // attachment handling
295 template <class TGeomObjClass>
296 void Grid::attach_to(IAttachment& attachment, bool passOnValues)
297 {
299  invalid_GeomObjClass);
300 
301 // setup the options for this attachment.
302  int options = 0;
303  if(passOnValues)
304  options = 1;
305 
306  element_storage<TGeomObjClass>().m_attachmentPipe.attach(attachment, options);
307 }
308 
309 inline void Grid::attach_to_all(IAttachment& attachment, bool passOnValues)
310 {
311  attach_to<Vertex>(attachment, passOnValues);
312  attach_to<Edge>(attachment, passOnValues);
313  attach_to<Face>(attachment, passOnValues);
314  attach_to<Volume>(attachment, passOnValues);
315 }
316 
317 inline void Grid::attach_to_all(IAttachment& attachment)
318 {
319  attach_to<Vertex>(attachment);
320  attach_to<Edge>(attachment);
321  attach_to<Face>(attachment);
322  attach_to<Volume>(attachment);
323 }
324 
325 template <class TGeomObjClass, class TAttachment>
326 void Grid::attach_to_dv(TAttachment& attachment, const typename TAttachment::ValueType& defaultValue)
327 {
328  attach_to_dv<TGeomObjClass, TAttachment>(attachment, defaultValue, attachment.default_pass_on_behaviour());
329 }
330 
331 template <class TAttachment>
332 inline void Grid::
333 attach_to_all_dv(TAttachment& attachment,
334  const typename TAttachment::ValueType& defaultValue)
335 {
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);
340 }
341 
342 template <class TGeomObjClass, class TAttachment>
343 void Grid::attach_to_dv(TAttachment& attachment, const typename TAttachment::ValueType& defaultValue, bool passOnValues)
344 {
346  invalid_GeomObjClass);
347 
348 // setup the options for this attachment.
349  int options = 0;
350  if(passOnValues)
351  options = 1;
352 
353  element_storage<TGeomObjClass>().m_attachmentPipe.attach(attachment, defaultValue, options);
354 }
355 
356 template <class TAttachment>
357 inline void Grid::
358 attach_to_all_dv(TAttachment& attachment,
359  const typename TAttachment::ValueType& defaultValue,
360  bool passOnValues)
361 {
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);
366 }
367 
368 template <class TGeomObjClass>
370 {
372  invalid_GeomObjClass);
373 
374  element_storage<TGeomObjClass>().m_attachmentPipe.detach(attachment);
375 }
376 
377 inline void Grid::detach_from_all(IAttachment& attachment)
378 {
379  detach_from<Vertex>(attachment);
380  detach_from<Edge>(attachment);
381  detach_from<Face>(attachment);
382  detach_from<Volume>(attachment);
383 }
384 
385 /*
386 template <class TGeomObjClass>
387 util::IAttachmentDataContainer* Grid::get_data_container(util::IAttachment& attachment)
388 {
389  assert(geometry_traits<TGeomObjClass>::base_object_type() != -1
390  && "ERROR in Grid::get_data_container(...). Invalid base_object_type of GeomObjClass!");
391 
392  return m_elementStorage[geometry_traits<TGeomObjClass>::base_object_type()].
393  m_attachmentPipe.get_data_container(attachment);
394 }
395 */
396 
397 template <class TGeomObj, class TAttachment>
398 typename TAttachment::ContainerType*
399 Grid::get_attachment_data_container(TAttachment& attachment)
400 {
402  invalid_GeomObj);
403 
404  return element_storage<TGeomObj>().m_attachmentPipe.get_data_container(attachment);
405 }
406 
407 template <class TGeomObj>
410 {
412  invalid_GeomObj);
413 
414  return element_storage<TGeomObj>().m_attachmentPipe;
415 }
416 
417 template <class TGeomObj>
418 uint
419 Grid::get_attachment_data_index(TGeomObj* pObj) const
420 {
421  typedef typename geometry_traits<TGeomObj>::grid_base_object BaseObj;
423  get_data_index(&element_storage<TGeomObj>(), pObj);
424 }
425 
426 inline void
427 Grid::autoenable_option(uint option, const char* caller, const char* optionName)
428 {
429  if(!option_is_enabled(option))
430  {
431  LOG("WARNING in " << caller << ": auto-enabling " << optionName << "." << std::endl);
432  enable_options(option);
433  }
434 }
435 
437 // marks
438 template <class TIterator>
439 void Grid::mark(TIterator begin, TIterator end)
440 {
441  for(TIterator iter = begin; iter != end; ++iter)
442  mark(*iter);
443 }
444 
445 template <class TIterator>
446 void Grid::unmark(TIterator begin, TIterator end)
447 {
448  for(TIterator iter = begin; iter != end; ++iter)
449  unmark(*iter);
450 }
451 
452 
454 template <class TContainer>
455 void Grid::get_associated(TContainer& container, GridObject* o)
456 {
457  switch(o->base_object_id()){
458  case VERTEX: return get_associated(container, static_cast<Vertex*>(o));
459  case EDGE: return get_associated(container, static_cast<Edge*>(o));
460  case FACE: return get_associated(container, static_cast<Face*>(o));
461  case VOLUME: return get_associated(container, static_cast<Volume*>(o));
462  }
463 }
464 
465 template <class TElem>
467 {
468  get_associated(elemsOut, e);
469 }
470 
471 template <class TElem>
473 {
474  get_associated(elemsOut, e);
475 }
476 
477 template <class TElem>
479 {
480  get_associated(elemsOut, e);
481 }
482 
483 template <class TElem>
485 {
486  get_associated(elemsOut, e);
487 }
488 
489 template <class TElem>
491  ::secure_container& elems, TElem* e)
492 {
493 // we have to retrieve a valid pointer on the element pointer. The only way
494 // to receive it, is to return the pointer to the entry in which e is stored in
495 // the element storage.
496  elems.set_external_array(
497  element_storage<typename TElem::grid_base_object>().m_sectionContainer.
498  get_container().get_pointer_to_element(e),
499  1);
500 }
501 
502 template <class TElem>
504 {
505  get_associated_sorted(elemsOut, e);
506 }
507 
508 template <class TElem>
510 {
511  get_associated_sorted(elemsOut, e);
512 }
513 
514 template <class TElem>
516 {
517  get_associated_sorted(elemsOut, e);
518 }
519 
520 template <class TElem>
522 {
523  get_associated_sorted(elemsOut, e);
524 }
525 
526 
527 template <class TElem>
529  ::secure_container& elems, TElem* e)
530 {
531 // we have to retrieve a valid pointer on the element pointer. The only way
532 // to receive it, is to return the pointer to the entry in which e is stored in
533 // the element storage.
534  elems.set_external_array(
535  element_storage<typename TElem::grid_base_object>().m_sectionContainer.
536  get_container().get_pointer_to_element(e),
537  1);
538 }
539 
540 
542 // neighbourhood access
543 template <class TGeomObj>
545 {
547 
550  iter != iterEnd; ++iter)
551  {
552  Edge* e = *iter;
553  if(CompareVertices(e, &ev))
554  return e;
555  }
556  return NULL;
557 }
558 
559 
560 template <class TGeomObj>
562 {
564 
565  unsigned long key = hash_key(&fv);
568  iter != iterEnd; ++iter)
569  {
570  Face* f = *iter;
571  if(key == hash_key(f))
572  {
573  if(CompareVertices(f, &fv))
574  return f;
575  }
576  }
577 
578  return NULL;
579 }
580 
581 template <class TGeomObj>
583  const VolumeVertices& vv)
584 {
586 
587  unsigned long key = hash_key(&vv);
590  iter != iterEnd; ++iter)
591  {
592  Volume* v = *iter;
593  if(key == hash_key(v))
594  {
595  if(CompareVertices(v, &vv))
596  return v;
597  }
598  }
599 
600  return NULL;
601 }
602 
603 
606 // implementation of Grids AttachmentAccessors
607 
609 // AttachmentAccessor
610 template <class TElem, class TAttachment>
613 ug::AttachmentAccessor<TElem*, TAttachment, ElementStorage<TElem> >()
614 {
615 }
616 
617 template <class TElem, class TAttachment>
620 ug::AttachmentAccessor<TElem*, TAttachment, ElementStorage<TElem> >(aa)
621 {
622 }
623 
624 template <class TElem, class TAttachment>
626 AttachmentAccessor(Grid& grid, TAttachment& a) :
627 ug::AttachmentAccessor<typename TElem::grid_base_object*, TAttachment,
628  typename traits<TElem>::ElementStorage>
629  (grid.get_attachment_pipe<TElem>(), a)
630 {
631 }
632 
633 template <class TElem, class TAttachment>
635 AttachmentAccessor(Grid& grid, TAttachment& a, bool autoAttach) :
636 ug::AttachmentAccessor<typename TElem::grid_base_object*, TAttachment,
637  typename traits<TElem>::ElementStorage>()
638 {
639  if(autoAttach){
640  if(!grid.has_attachment<TElem>(a))
641  grid.attach_to<TElem>(a);
642  }
643 
644  access(grid, a);
645 }
646 
648 // VertexAttachmentAccessor
649 template <class TAttachment>
652  Grid::AttachmentAccessor<Vertex, TAttachment>()
653 {
654 }
655 
656 template <class TAttachment>
659  Grid::AttachmentAccessor<Vertex, TAttachment>(aa)
660 {
661 }
662 
663 template <class TAttachment>
665 VertexAttachmentAccessor(Grid& grid, TAttachment& a) :
666  Grid::AttachmentAccessor<Vertex, TAttachment>(grid, a)
667 {
668 }
669 
670 template <class TAttachment>
672 VertexAttachmentAccessor(Grid& grid, TAttachment& a, bool autoAttach) :
673  Grid::AttachmentAccessor<Vertex, TAttachment>(grid, a, autoAttach)
674 {
675 }
676 
677 
679 // EdgeAttachmentAccessor
680 template <class TAttachment>
683  Grid::AttachmentAccessor<Edge, TAttachment>()
684 {
685 }
686 
687 template <class TAttachment>
690  Grid::AttachmentAccessor<Edge, TAttachment>(aa)
691 {
692 }
693 
694 template <class TAttachment>
696 EdgeAttachmentAccessor(Grid& grid, TAttachment& a) :
697  Grid::AttachmentAccessor<Edge, TAttachment>(grid, a)
698 {
699 }
700 
701 template <class TAttachment>
703 EdgeAttachmentAccessor(Grid& grid, TAttachment& a, bool autoAttach) :
704  Grid::AttachmentAccessor<Edge, TAttachment>(grid, a, autoAttach)
705 {
706 }
707 
708 
710 // FaceAttachmentAccessor
711 template <class TAttachment>
714  Grid::AttachmentAccessor<Face, TAttachment>()
715 {
716 }
717 
718 template <class TAttachment>
721  Grid::AttachmentAccessor<Face, TAttachment>(aa)
722 {
723 }
724 
725 template <class TAttachment>
727 FaceAttachmentAccessor(Grid& grid, TAttachment& a) :
728  Grid::AttachmentAccessor<Face, TAttachment>(grid, a)
729 {
730 }
731 
732 template <class TAttachment>
734 FaceAttachmentAccessor(Grid& grid, TAttachment& a, bool autoAttach) :
735  Grid::AttachmentAccessor<Face, TAttachment>(grid, a, autoAttach)
736 {
737 }
738 
739 
741 // FaceAttachmentAccessor
742 template <class TAttachment>
745  Grid::AttachmentAccessor<Volume, TAttachment>()
746 {
747 }
748 
749 template <class TAttachment>
752  Grid::AttachmentAccessor<Volume, TAttachment>(aa)
753 {
754 }
755 
756 template <class TAttachment>
758 VolumeAttachmentAccessor(Grid& grid, TAttachment& a) :
759  Grid::AttachmentAccessor<Volume, TAttachment>(grid, a)
760 {
761 }
762 
763 template <class TAttachment>
765 VolumeAttachmentAccessor(Grid& grid, TAttachment& a, bool autoAttach) :
766  Grid::AttachmentAccessor<Volume, TAttachment>(grid, a, autoAttach)
767 {
768 }
769 
770 
772 // marks
773 inline void Grid::mark(GridObject* obj)
774 {
775  const int typeID = obj->base_object_id();
776  switch(typeID){
777  case VERTEX: mark(static_cast<Vertex*>(obj)); break;
778  case EDGE: mark(static_cast<Edge*>(obj)); break;
779  case FACE: mark(static_cast<Face*>(obj)); break;
780  case VOLUME: mark(static_cast<Volume*>(obj)); break;
781  }
782 }
783 
784 inline void Grid::mark(Vertex* obj)
785 {
786  assert(m_bMarking && "ERROR: Grid::mark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
787  m_aaMarkVRT[obj] = m_currentMark;
788 }
789 
790 inline void Grid::mark(Edge* obj)
791 {
792  assert(m_bMarking && "ERROR: Grid::mark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
794 }
795 
796 inline void Grid::mark(Face* obj)
797 {
798  assert(m_bMarking && "ERROR: Grid::mark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
800 }
801 
802 inline void Grid::mark(Volume* obj)
803 {
804  assert(m_bMarking && "ERROR: Grid::mark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
805  m_aaMarkVOL[obj] = m_currentMark;
806 }
807 
808 inline void Grid::unmark(GridObject* obj)
809 {
810  const int typeID = obj->base_object_id();
811  switch(typeID){
812  case VERTEX: unmark(static_cast<Vertex*>(obj)); break;
813  case EDGE: unmark(static_cast<Edge*>(obj)); break;
814  case FACE: unmark(static_cast<Face*>(obj)); break;
815  case VOLUME: unmark(static_cast<Volume*>(obj)); break;
816  }
817 }
818 
819 inline void Grid::unmark(Vertex* obj)
820 {
821  assert(m_bMarking && "ERROR: Grid::unmark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
822  m_aaMarkVRT[obj] = 0;
823 }
824 
825 inline void Grid::unmark(Edge* obj)
826 {
827  assert(m_bMarking && "ERROR: Grid::unmark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
828  m_aaMarkEDGE[obj] = 0;
829 }
830 
831 inline void Grid::unmark(Face* obj)
832 {
833  assert(m_bMarking && "ERROR: Grid::unmark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
834  m_aaMarkFACE[obj] = 0;
835 }
836 
837 inline void Grid::unmark(Volume* obj)
838 {
839  assert(m_bMarking && "ERROR: Grid::unmark may only be called between calls to Grid::begin_marking and Grid::end_marking.");
840  m_aaMarkVOL[obj] = 0;
841 }
842 
843 inline bool Grid::is_marked(GridObject* obj) const
844 {
845  const int typeID = obj->base_object_id();
846  switch(typeID){
847  case VERTEX: return is_marked(static_cast<Vertex*>(obj));
848  case EDGE: return is_marked(static_cast<Edge*>(obj));
849  case FACE: return is_marked(static_cast<Face*>(obj));
850  case VOLUME: return is_marked(static_cast<Volume*>(obj));
851  default: return false;
852  }
853 }
854 
855 inline bool Grid::is_marked(Vertex* obj) const
856 {
857  if(m_currentMark == 0)
858  return false;
859  return m_aaMarkVRT[obj] == m_currentMark;
860 }
861 
862 inline bool Grid::is_marked(Edge* obj) const
863 {
864  if(m_currentMark == 0)
865  return false;
866  return m_aaMarkEDGE[obj] == m_currentMark;
867 }
868 
869 inline bool Grid::is_marked(Face* obj) const
870 {
871  if(m_currentMark == 0)
872  return false;
873  return m_aaMarkFACE[obj] == m_currentMark;
874 }
875 
876 inline bool Grid::is_marked(Volume* obj) const
877 {
878  if(m_currentMark == 0)
879  return false;
880  return m_aaMarkVOL[obj] == m_currentMark;
881 }
882 
883 }// end of namespace libGrid
884 #endif
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
Definition: grid.h:211
EdgeAttachmentAccessor()
Definition: grid_impl.hpp:682
Definition: grid.h:221
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
the ug namespace
@ 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