ug4
parallel_index_layout.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2015: G-CSC, Goethe University Frankfurt
3  * Authors: Andreas Vogel, 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_ALGEBRA__PARALLELIZATION__PARALLEL_INDEX_LAYOUT__
34 #define __H__LIB_ALGEBRA__PARALLELIZATION__PARALLEL_INDEX_LAYOUT__
35 
36 #include <set>
37 #include <vector>
38 #include <iostream>
39 #include "pcl/pcl.h"
40 
41 namespace ug
42 {
43 
45 
47 
54 
56 
60 void LogIndexLayout(IndexLayout& layout, int depth = 0);
61 
62 
64 void LogIndexLayoutOnAllProcs(IndexLayout& layout, int depth = 0);
65 
67 
73 void ReplaceIndicesInLayout(IndexLayout& layout, const std::vector<int>& vMap);
74 
75 
76 
78 {
79  for(IndexLayout::Interface::iterator iter = interface.begin(); iter != interface.end(); ++iter)
80  {
81  if(interface.get_element(iter) == i)
82  return iter;
83  }
84  return interface.end();
85 }
86 
87 inline bool IsInInterface(IndexLayout::Interface &interface, size_t i)
88 {
89  return find(interface, i) != interface.end();
90 }
91 
92 inline void AddIfUnique(IndexLayout::Interface &interface, size_t i)
93 {
94  if(IsInInterface(interface, i) == false)
95  interface.push_back(i);
96 }
97 
103 void MarkAllFromInterface(std::vector<bool> &mark, const IndexLayout::Interface &interface);
104 
105 template <class T>
106 void MarkAllFromInterface(std::vector<T> &mark, const IndexLayout::Interface &interface, const T &default_val)
107 {
108  for(IndexLayout::Interface::const_iterator iter = interface.begin(); iter != interface.end(); ++iter)
109  mark[ interface.get_element(iter) ] = default_val;
110 }
111 
117 void MarkAllFromLayout(std::vector<bool> &mark, const IndexLayout &layout);
118 
119 template <class T>
120 void MarkAllFromLayout(std::vector<T> &mark, const IndexLayout &layout, const T &default_val)
121 {
122  for(IndexLayout::const_iterator iter = layout.begin(); iter != layout.end(); ++iter)
123  MarkAllFromInterface<T> (mark, layout.interface(iter), default_val);
124 }
125 
130 void AddAllFromInterface(std::set<size_t> &s, const IndexLayout::Interface &interface);
131 
132 
137 void AddAllFromLayout(std::set<size_t> &s, const IndexLayout &layout);
138 
139 
140 std::ostream &operator << (std::ostream &out, const IndexLayout &layout);
141 
142 } // end namespace ug
143 
144 #endif /* __H__LIB_ALGEBRA__PARALLELIZATION__PARALLEL_INDEX_LAYOUT__ */
the standard single-level-layout implementation
Definition: pcl_communication_structs.h:452
iterator end(size_t level=0)
returns the iterator to the last interface of the layout.
Definition: pcl_communication_structs.h:492
iterator begin(size_t level=0)
returns the iterator to the first interface of the layout.
Definition: pcl_communication_structs.h:486
Interface & interface(iterator iter)
returns the interface to the given iterator.
Definition: pcl_communication_structs.h:505
InterfaceMap::const_iterator const_iterator
Definition: pcl_communication_structs.h:477
TInterface Interface
Interface type.
Definition: pcl_communication_structs.h:467
InterfaceMap::iterator iterator
An iterator that allows to iterate over the interfaces stored in the layout.
Definition: pcl_communication_structs.h:476
pcl::SingleLevelLayout< pcl::OrderedInterface< size_t, std::vector > > IndexLayout
Definition: parallel_index_layout.h:53
std::ostream & operator<<(std::ostream &outStream, const ug::MathMatrix< 2, 2 > &m)
Definition: math_matrix.cpp:38
the ug namespace
void AddIfUnique(IndexLayout::Interface &interface, size_t i)
Definition: parallel_index_layout.h:92
IndexLayout::Interface::iterator find(IndexLayout::Interface &interface, size_t i)
Definition: parallel_index_layout.h:77
void LogIndexLayout(IndexLayout &layout, int depth)
Logs the internals of an index layout.
Definition: parallel_index_layout.cpp:42
void ReplaceIndicesInLayout(IndexLayout &layout, const std::vector< int > &vMap)
replaces the indices in the layout based on a passed mapping
Definition: parallel_index_layout.cpp:141
void AddAllFromLayout(std::set< size_t > &s, const IndexLayout &layout)
Definition: parallel_index_layout.cpp:196
void MarkAllFromInterface(std::vector< bool > &mark, const IndexLayout::Interface &interface)
Definition: parallel_index_layout.cpp:177
void LogIndexLayoutOnAllProcs(IndexLayout &layout, int depth)
logs index infos for all procs successively
Definition: parallel_index_layout.cpp:113
void MarkAllFromLayout(std::vector< bool > &mark, const IndexLayout &layout)
Definition: parallel_index_layout.cpp:183
void AddAllFromInterface(std::set< size_t > &s, const IndexLayout::Interface &interface)
Definition: parallel_index_layout.cpp:190
bool IsInInterface(IndexLayout::Interface &interface, size_t i)
Definition: parallel_index_layout.h:87