Line data Source code
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 : {
42 : ////////////////////////////////////////////////////////////////////////
43 : ////////////////////////////////////////////////////////////////////////
44 : // GridObjectCollection
45 :
46 : ////////////////////////////////////////////////////////////////////////
47 : // get_container
48 :
49 : template <class TGeomObj> inline
50 : const typename ElementStorage<typename geometry_traits<TGeomObj>::grid_base_object>::
51 : SectionContainer*
52 : GridObjectCollection::get_container(size_t level) const
53 : {
54 : return SectionContainerSelector<typename geometry_traits<TGeomObj>::grid_base_object>::
55 0 : section_container(m_levels[level].vrtContainer, m_levels[level].edgeContainer,
56 0 : m_levels[level].faceContainer, m_levels[level].volContainer);
57 : }
58 :
59 : template <class TGeomObj> inline
60 : typename ElementStorage<typename geometry_traits<TGeomObj>::grid_base_object>::
61 : SectionContainer*
62 : GridObjectCollection::get_container(size_t level)
63 : {
64 : return SectionContainerSelector<typename geometry_traits<TGeomObj>::grid_base_object>::
65 0 : section_container(m_levels[level].vrtContainer, m_levels[level].edgeContainer,
66 : m_levels[level].faceContainer, m_levels[level].volContainer);
67 : }
68 :
69 : ////////////////////////////////////////////////////////////////////////
70 : // begin
71 : template <class TGeomObj>
72 : typename geometry_traits<TGeomObj>::const_iterator
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(
77 0 : geometry_traits<TGeomObj>::CONTAINER_SECTION));
78 : }
79 :
80 : ////////////////////////////////////////////////////////////////////////
81 : // end
82 : template <class TGeomObj>
83 : typename geometry_traits<TGeomObj>::const_iterator
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(
88 0 : geometry_traits<TGeomObj>::CONTAINER_SECTION));
89 : }
90 :
91 : ////////////////////////////////////////////////////////////////////////
92 : // begin
93 : template <class TGeomObj>
94 : typename geometry_traits<TGeomObj>::iterator
95 : GridObjectCollection::begin(size_t level)
96 : {
97 : return iterator_cast<typename geometry_traits<TGeomObj>::iterator>
98 : (get_container<TGeomObj>(level)->section_begin(
99 0 : geometry_traits<TGeomObj>::CONTAINER_SECTION));
100 : }
101 :
102 : ////////////////////////////////////////////////////////////////////////
103 : // end
104 : template <class TGeomObj>
105 : typename geometry_traits<TGeomObj>::iterator
106 : GridObjectCollection::end(size_t level)
107 : {
108 : return iterator_cast<typename geometry_traits<TGeomObj>::iterator>
109 : (get_container<TGeomObj>(level)->section_end(
110 : geometry_traits<TGeomObj>::CONTAINER_SECTION));
111 : }
112 :
113 : ////////////////////////////////////////////////////////////////////////
114 : // element numbers
115 : template <class TGeomObj>
116 : size_t
117 : GridObjectCollection::num(size_t level) const
118 : {
119 : int secIndex = geometry_traits<TGeomObj>::CONTAINER_SECTION;
120 :
121 : if(secIndex == -1)
122 0 : return get_container<TGeomObj>(level)->num_elements();
123 :
124 0 : return get_container<TGeomObj>(level)->num_elements(secIndex);
125 : }
126 :
127 : // GridObjectCollection
128 : template <class TGeomObj>
129 : size_t
130 : GridObjectCollection::num() const
131 : {
132 : size_t counter = 0;
133 0 : for(size_t i = 0; i < m_levels.size(); ++i)
134 0 : counter += num<TGeomObj>(i);
135 : return counter;
136 : }
137 :
138 : }
139 :
140 : #endif
|