Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
parallel_matrix_boost.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022: G-CSC, Goethe University Frankfurt
3 * Author: Felix Salfelder, 2022
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 UG_PARALLEL_MATRIX_BOOST_H
34#define UG_PARALLEL_MATRIX_BOOST_H
35#ifdef UG_PARALLEL
39
40
41namespace boost{
42
43template <class T> struct graph_traits<ug::BGLParallelMatrix<ug::ParallelMatrix<T>>>{
46 typedef typename type::edge edge_descriptor;
47 typedef directed_tag directed_category;
48 typedef typename type::out_edge_iterator out_edge_iterator;
49 typedef typename type::adjacency_iterator adjacency_iterator;
50 typedef typename type::vertex_iterator vertex_iterator;
51 typedef disallow_parallel_edge_tag edge_parallel_category;
53 typedef int degree_size_type;
54 typedef int vertices_size_type;
55 //typedef typename ug::SparseMatrix<T>::const_row_iterator adjacency_iterator;
56};
57
58template<class T>
59std::pair<typename ug::BGLParallelMatrix<T>::vertex_iterator,
62{
63 auto b = M.begin_vertices();
64 auto e = M.end_vertices();
65
66 return std::make_pair(b,e);
67}
68
69#if 0
71{
72 return x.owner();
73}
74
76{
77 return x.local();
78}
79#else
80// not needed.
83#endif
84
85template<class T>
87{
88// return M.out_degree(v);
89 incomplete();
90 return 17;
91}
92
93template<class T>
96{
97 return e.source();
98}
99
100template<class T>
103{
104 return e.target();
105}
106
107template<class T>
109{
110 incomplete();
111 return 0;
112}
113
114template<class T>
115inline SM_edge_weight_map<T>
116//inline typename property_map<ug::SparseMatrix<T>, edge_weight_t>::type
117get(edge_weight_t, ug::BGLParallelMatrix<T> const & g) {
118 incomplete();
119// return SM_edge_weight_map<T>(g);
120}
121
122template<class T>
123inline std::pair<typename ug::BGLParallelMatrix<T>::out_edge_iterator,
128{
129 auto l = local(v);
130// auto o = owner(v);
131
132 auto b = M.begin_out_edges(l);
133 auto e = M.end_out_edges(l);
134
135 return std::make_pair(b, e);
136}
137
138template<class T>
139inline std::pair<typename ug::BGLParallelMatrix<T>::adjacency_iterator,
144{
145 auto l = local(v);
146 auto b = M.begin_adjacent_vertices(l);
147 auto e = M.end_adjacent_vertices(l);
148
149 return std::make_pair(b,e);
150}
151
152template<class T>
154 : public put_get_helper<size_t, bglp_matrix_index_map<T> > { //
155public:
156 typedef size_t vertex_index_type;
157 typedef size_t vertex_descriptor;
158 typedef readable_property_map_tag category;
162
165 bglp_matrix_index_map(ug::SparseMatrix<T>const&, boost::vertex_index_t) { untested();
166 }
167 template<class X>
169 }
170 template <class T_>
171 value_type operator[](T_ x) const {
172 return x.local();
173 }
174 value_type operator[](int x) const {
175 return x;
176 }
178 return *this;
179 }
180};
181
182template<class T>
183struct property_map<ug::BGLParallelMatrix<T>, vertex_index_t>{
186};
187
188template<class T>
189typename property_map<ug::BGLParallelMatrix<T>, vertex_index_t>::const_type
190get(vertex_index_t, ug::BGLParallelMatrix<T> const& m)
191{
192 typedef typename property_map<ug::BGLParallelMatrix<T>, vertex_index_t>::type type;
193 return type(m);
194}
195
197
198// duplicate, same as graph_traits<ug::SparseMatrix<T>>?
199template <class T> struct graph_traits<ug::ParallelMatrix<ug::SparseMatrix<T>>>{
200 typedef int vertex_descriptor;
202 typedef directed_tag directed_category;
203 typedef counting_iterator<size_t> vertex_iterator;
206 typedef disallow_parallel_edge_tag edge_parallel_category;
208 typedef int degree_size_type;
210 //typedef typename ug::SparseMatrix<T>::const_row_iterator adjacency_iterator;
211};
212
213template<class T>
214std::pair<counting_iterator<size_t>, counting_iterator<size_t> > vertices(
216{
217 counting_iterator<size_t> b(0);
218 counting_iterator<size_t> e(M.num_rows());
219
220 return std::make_pair(b,e);
221}
222
223template<class T>
224struct property_map<ug::ParallelMatrix<T>, vertex_index_t>{
225 typedef typename T::value_type value_type;
228};
229
230} // boost
231
232namespace ug {
233
234using boost::counting_iterator;
235
236#if 0
237template<class T>
238std::pair<counting_iterator<size_t>, counting_iterator<size_t> > vertices(
240{
241 counting_iterator<size_t> b(0);
242 counting_iterator<size_t> e(M.num_rows());
243
244 return std::make_pair(b,e);
245}
246
247template<class T>
248inline std::pair<boost::SM_out_edge_iterator<T>, boost::SM_out_edge_iterator<T>>
250{
252 auto a = boost::adjacent_vertices(v, g);
253 return std::make_pair(Iter(a.first), Iter(a.second));
254}
255#endif
256
257// stuff neeeded in boost::print_graph (?)
258using boost::out_edges;
259using boost::vertices;
260using boost::source;
261using boost::target;
262
263} // ug
264
265#endif // UG_PARALLEL
266#endif // guard
Definition sparsematrix_boost.h:37
Definition sparsematrix_boost.h:152
Definition sparsematrix_boost.h:211
Definition parallel_matrix_boost.h:154
readable_property_map_tag category
Definition parallel_matrix_boost.h:158
value_type operator[](T_ x) const
Definition parallel_matrix_boost.h:171
value_type operator[](int x) const
Definition parallel_matrix_boost.h:174
bglp_matrix_index_map(X const &)
Definition parallel_matrix_boost.h:168
vertex_index_type value_type
Definition parallel_matrix_boost.h:159
size_t vertex_index_type
Definition parallel_matrix_boost.h:156
vertex_descriptor key_type
Definition parallel_matrix_boost.h:161
vertex_index_type reference
Definition parallel_matrix_boost.h:160
size_t vertex_descriptor
Definition parallel_matrix_boost.h:157
bglp_matrix_index_map & operator=(const bglp_matrix_index_map &s)
Definition parallel_matrix_boost.h:177
bglp_matrix_index_map(bglp_matrix_index_map const &p)
Definition parallel_matrix_boost.h:163
bglp_matrix_index_map(ug::SparseMatrix< T >const &, boost::vertex_index_t)
Definition parallel_matrix_boost.h:165
Definition sparsematrix_boost.h:350
Definition parallel_matrix.h:124
Definition parallel_matrix.h:193
vertex_descriptor target() const
Definition parallel_matrix.h:202
vertex_descriptor source() const
Definition parallel_matrix.h:199
Definition parallel_matrix.h:168
Definition parallel_matrix.h:68
adjacency_iterator begin_adjacent_vertices(int row) const
Definition parallel_matrix.h:264
out_edge_iterator begin_out_edges(int row) const
Definition parallel_matrix.h:274
vertex_iterator end_vertices() const
Definition parallel_matrix.h:313
adjacency_iterator end_adjacent_vertices(int row) const
Definition parallel_matrix.h:269
boost::filter_iterator< filter_local, vertex_iterator_ > vertex_iterator
Definition parallel_matrix.h:122
vertex_iterator begin_vertices() const
Definition parallel_matrix.h:304
out_edge_iterator end_out_edges(int row) const
Definition parallel_matrix.h:279
Wrapper for sequential matrices to handle them in parallel.
Definition parallel_matrix.h:65
sparse matrix for big, variable sparse matrices.
Definition sparsematrix.h:99
Definition parallel_matrix.h:43
int local() const
Definition parallel_matrix.h:50
int owner() const
Definition parallel_matrix.h:49
#define untested()
Definition lua_table_handle.cpp:15
Definition boost_serialization_routines.h:49
std::pair< typename graph_traits< T >::adjacency_iterator, typename graph_traits< T >::adjacency_iterator > adjacent_vertices(size_t v, ug::BidirectionalMatrix< T > const &M)
Definition bidirectional_boost.h:108
std::pair< SM_out_edge_iterator< typename T::value_type >, SM_out_edge_iterator< typename T::value_type > > out_edges(size_t v, ug::BidirectionalMatrix< T > const &g)
Definition bidirectional_boost.h:136
int out_degree(int v, ug::BidirectionalMatrix< T > const &M)
Definition bidirectional_boost.h:76
std::pair< counting_iterator< size_t >, counting_iterator< size_t > > vertices(ug::BidirectionalMatrix< T > const &M)
Definition bidirectional_boost.h:60
int num_vertices(ug::BidirectionalMatrix< T > const &M)
Definition bidirectional_boost.h:70
SM_edge_weight_map< typename T::value_type, ug::BidirectionalMatrix< T > > get(edge_weight_t, ug::BidirectionalMatrix< T > const &g)
Definition bidirectional_boost.h:157
size_t target(SM_edge< typename T::value_type > const &e, ug::BidirectionalMatrix< T > const &m)
Definition bidirectional_boost.h:100
size_t source(SM_edge< typename T::value_type > const &e, ug::BidirectionalMatrix< T > const &)
Definition bidirectional_boost.h:94
int local(bglp_vertex_descriptor p)
Definition parallel_matrix.h:57
int owner(bglp_vertex_descriptor p)
Definition parallel_matrix.h:53
the ug namespace
Definition sparsematrix_boost.h:309
SM_traversal_tag traversal_category
Definition parallel_matrix_boost.h:52
directed_tag directed_category
Definition parallel_matrix_boost.h:47
disallow_parallel_edge_tag edge_parallel_category
Definition parallel_matrix_boost.h:51
ug::detail::bglp_vertex_descriptor vertex_descriptor
Definition parallel_matrix_boost.h:45
type::edge edge_descriptor
Definition parallel_matrix_boost.h:46
ug::BGLParallelMatrix< ug::ParallelMatrix< T > > type
Definition parallel_matrix_boost.h:44
type::vertex_iterator vertex_iterator
Definition parallel_matrix_boost.h:50
type::out_edge_iterator out_edge_iterator
Definition parallel_matrix_boost.h:48
type::adjacency_iterator adjacency_iterator
Definition parallel_matrix_boost.h:49
directed_tag directed_category
Definition parallel_matrix_boost.h:202
disallow_parallel_edge_tag edge_parallel_category
Definition parallel_matrix_boost.h:206
SM_adjacency_iterator< T > adjacency_iterator
Definition parallel_matrix_boost.h:205
int degree_size_type
Definition parallel_matrix_boost.h:208
int vertices_size_type
Definition parallel_matrix_boost.h:209
counting_iterator< size_t > vertex_iterator
Definition parallel_matrix_boost.h:203
SM_traversal_tag traversal_category
Definition parallel_matrix_boost.h:207
SM_edge< T > edge_descriptor
Definition parallel_matrix_boost.h:201
SM_out_edge_iterator< T > out_edge_iterator
Definition parallel_matrix_boost.h:204
int vertex_descriptor
Definition parallel_matrix_boost.h:200
type const_type
Definition parallel_matrix_boost.h:185
bglp_matrix_index_map< T > type
Definition parallel_matrix_boost.h:184
T::value_type value_type
Definition parallel_matrix_boost.h:225
sparse_matrix_index_map< value_type > type
Definition parallel_matrix_boost.h:226
type const_type
Definition parallel_matrix_boost.h:227
#define incomplete()
Definition trace.h:10