ug4
grid_object_collection_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__GEOMETRIC_OBJECT_COLLECTION_IMPL__
34 #define __H__LIB_GRID__GEOMETRIC_OBJECT_COLLECTION_IMPL__
35 
36 #include <cassert>
37 #include "grid_object_collection.h"
38 #include "element_storage.h"
39 
40 namespace ug
41 {
44 // GridObjectCollection
45 
47 // get_container
48 
49 template <class TGeomObj> inline
50 const typename ElementStorage<typename geometry_traits<TGeomObj>::grid_base_object>::
51 SectionContainer*
53 {
55  section_container(m_levels[level].vrtContainer, m_levels[level].edgeContainer,
56  m_levels[level].faceContainer, m_levels[level].volContainer);
57 }
58 
59 template <class TGeomObj> inline
63 {
65  section_container(m_levels[level].vrtContainer, m_levels[level].edgeContainer,
66  m_levels[level].faceContainer, m_levels[level].volContainer);
67 }
68 
70 // begin
71 template <class TGeomObj>
73 GridObjectCollection::begin(size_t level) const
74 {
75  return iterator_cast<typename geometry_traits<TGeomObj>::const_iterator>
76  (get_container<TGeomObj>(level)->section_begin(
78 }
79 
81 // end
82 template <class TGeomObj>
84 GridObjectCollection::end(size_t level) const
85 {
86  return iterator_cast<typename geometry_traits<TGeomObj>::const_iterator>
87  (get_container<TGeomObj>(level)->section_end(
89 }
90 
92 // begin
93 template <class TGeomObj>
96 {
97  return iterator_cast<typename geometry_traits<TGeomObj>::iterator>
98  (get_container<TGeomObj>(level)->section_begin(
100 }
101 
103 // end
104 template <class TGeomObj>
107 {
108  return iterator_cast<typename geometry_traits<TGeomObj>::iterator>
109  (get_container<TGeomObj>(level)->section_end(
111 }
112 
114 // element numbers
115 template <class TGeomObj>
116 size_t
117 GridObjectCollection::num(size_t level) const
118 {
120 
121  if(secIndex == -1)
122  return get_container<TGeomObj>(level)->num_elements();
123 
124  return get_container<TGeomObj>(level)->num_elements(secIndex);
125 }
126 
127 // GridObjectCollection
128 template <class TGeomObj>
129 size_t
131 {
132  size_t counter = 0;
133  for(size_t i = 0; i < m_levels.size(); ++i)
134  counter += num<TGeomObj>(i);
135  return counter;
136 }
137 
138 }
139 
140 #endif
This struct is used to hold GridObjects and their attachment pipes.
Definition: element_storage.h:44
geometry_traits< TGeomObj >::iterator begin(size_t level=0)
Definition: grid_object_collection_impl.hpp:95
geometry_traits< TGeomObj >::iterator end(size_t level=0)
Definition: grid_object_collection_impl.hpp:106
const ElementStorage< typename geometry_traits< TGeomObj >::grid_base_object >::SectionContainer * get_container(size_t level) const
Definition: grid_object_collection_impl.hpp:52
size_t num() const
Definition: grid_object_collection_impl.hpp:130
ContainerVec m_levels
Definition: grid_object_collection.h:225
A container that is divided into different sections.
Definition: section_container.h:59
Definition: grid_base_object_traits.h:68
the ug namespace
Helper class to access the correct element storage from its element type.
Definition: element_storage.h:210