Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
partitioner_dynamic_bisection.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-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__UG__partitioner_dynamic_biscection__
34#define __H__UG__partitioner_dynamic_biscection__
35
36#include <utility>
37#include <vector>
39#include "partitioner.h"
41
42namespace ug{
43
46
48
56template <class TElem, int dim>
58 public:
60 typedef TElem elem_t;
61 typedef typename TElem::side side_t;
66
69
71
74
76
77 void set_tolerance(number tol) {m_tolerance = tol;}
78
80
82
84
85 void enable_split_axis(int axis, bool enable);
86
88
90 void set_start_split_axis(int axis) {m_startSplitAxis = axis;}
91
95
96 virtual void set_next_process_hierarchy(SPProcessHierarchy procHierarchy);
97 virtual void set_balance_weights(SPBalanceWeights balanceWeights);
98// virtual void set_connection_weights(SmartPtr<ConnectionWeights<dim> >);
99
102
105
106 virtual bool supports_balance_weights() const;
107 virtual bool supports_connection_weights() const;
108 virtual bool supports_repartitioning() const {return false;}
109
110 virtual bool partition(size_t baseLvl, size_t elementThreshold);
111
112 virtual SubsetHandler& get_partitions();
113 virtual const std::vector<int>* get_process_map() const;
114
119 void enable_static_partitioning(bool enable);
120 bool static_partitioning_enabled() const;
121
122 private:
133
134 static const size_t s_invalidIndex = -1;
135
136 struct Entry{
138 size_t next;
140 };
141
142 struct ElemList{
147
148 void set_entry_list(std::vector<Entry>* entries) {m_entries = entries;}
149
150 void add(size_t entryInd)
151 {
152 if(m_first == s_invalidIndex){
153 m_first = m_last = entryInd;
154 m_num = 1;
155 }
156 else{
157 (*m_entries)[m_last].next = entryInd;
158 m_last = entryInd;
159 ++m_num;
160 }
161 (*m_entries)[entryInd].next = s_invalidIndex;
162 }
163
164 void clear()
165 {
167 m_num = 0;
168 }
169
170 size_t size() const {return m_num;}
171 bool empty() const {return m_num == 0;}
172
173 size_t first() const {return m_first;}
174 size_t last() const {return m_last;}
175 size_t next(size_t entryInd) const {return (*m_entries)[entryInd].next;}
176 elem_t* elem(size_t entryInd) const {return (*m_entries)[entryInd].elem;}
177
178 std::vector<Entry>* entries() {return m_entries;}
179
180 private:
181 std::vector<Entry>* m_entries;
182 size_t m_first;
183 size_t m_last;
184 size_t m_num;
185 };
186
187
208
209
210 void perform_bisection(int numTargetProcs, int minLvl, int maxLvl,
211 int partitionLvl, ANumber aWeight,
213
214 void control_bisection(ISubsetHandler& partitionSH,
215 std::vector<TreeNode>& treeNodes, ANumber aWeight,
216 number maxChildWeight, pcl::ProcessCommunicator& com);
217
220 void bisect_elements(std::vector<TreeNode>& childNodesOut,
221 std::vector<TreeNode>& parentNodes,
222 ANumber aWeight, number maxChildWeight,
224 int cutRecursion, int splitAxis);
225
227
233
235 int get_next_split_axis(int lastAxis) const;
236
237
238 void copy_partitions_to_children(ISubsetHandler& partitionSH, int lvl);
239
240 void calculate_global_dimensions(std::vector<TreeNode>& treeNodes,
241 number maxChildWeight, ANumber aWeight,
243
244 void gather_weights_from_level(int baseLvl, int childLvl, ANumber aWeight,
245 bool copyToVMastersOnBaseLvl, bool markedElemsOnly);
246
247 int classify_elem(elem_t* e, int splitAxis, number splitValue);
248
249 void improve_split_values(std::vector<TreeNode>& treeNodes,
250 size_t maxIterations, ANumber aWeight,
252
253
261 std::vector<Entry> m_entries;
262
266
268
271
278
279 // the following parameters are only used if the partitioner operates in
280 // static mode
281 std::vector<int> m_procMap;
283};
284
286
287}// end of namespace
288
289#endif
Definition smart_pointer.h:108
Performs communication between interfaces on different processes.
Definition pcl_interface_communicator.h:68
Definition pcl_process_communicator.h:70
A generic specialization of IAttachment.
Definition attachment_pipe.h:263
Partitions elements of a grid into several subsets.
Definition subset_handler_grid.h:53
Partitioners can be used inside a LoadBalancer or separately to create partition maps.
Definition partitioner.h:162
Definition subset_handler_interface.h:223
a mathematical Vector with N entries.
Definition math_vector.h:97
Definition multi_grid.h:72
Parallel bisection partitioner.
Definition partitioner_dynamic_bisection.h:57
std::vector< Entry > m_entries
Definition partitioner_dynamic_bisection.h:261
int m_startSplitAxis
Definition partitioner_dynamic_bisection.h:273
virtual ConstSPProcessHierarchy current_process_hierarchy() const
Definition partitioner_dynamic_bisection.cpp:156
void perform_bisection(int numTargetProcs, int minLvl, int maxLvl, int partitionLvl, ANumber aWeight, pcl::ProcessCommunicator com)
Definition partitioner_dynamic_bisection.cpp:421
int m_longestSplitAxisEnabled
Definition partitioner_dynamic_bisection.h:272
TElem::side side_t
Definition partitioner_dynamic_bisection.h:61
virtual void set_next_process_hierarchy(SPProcessHierarchy procHierarchy)
Definition partitioner_dynamic_bisection.cpp:122
virtual bool partition(size_t baseLvl, size_t elementThreshold)
Definition partitioner_dynamic_bisection.cpp:229
void enable_split_axis(int axis, bool enable)
enable or disable splits along a certain axis.
Definition partitioner_dynamic_bisection.cpp:103
int m_numSplitAxisEnabled
Definition partitioner_dynamic_bisection.h:276
constants
Definition partitioner_dynamic_bisection.h:123
@ NUM_CONSTANTS
Definition partitioner_dynamic_bisection.h:131
@ RIGHT
Definition partitioner_dynamic_bisection.h:126
@ CUTTING_CENTER_LEFT
Definition partitioner_dynamic_bisection.h:128
@ LEFT
Definition partitioner_dynamic_bisection.h:125
@ CUTTING_CENTER_RIGHT
Definition partitioner_dynamic_bisection.h:129
@ CUTTING
Definition partitioner_dynamic_bisection.h:127
@ UNCLASSIFIED
Definition partitioner_dynamic_bisection.h:124
@ TOTAL
Definition partitioner_dynamic_bisection.h:130
virtual ConstSPProcessHierarchy next_process_hierarchy() const
Definition partitioner_dynamic_bisection.cpp:164
virtual bool supports_balance_weights() const
Definition partitioner_dynamic_bisection.cpp:172
Attachment< vector_t > apos_t
Definition partitioner_dynamic_bisection.h:63
void control_bisection(ISubsetHandler &partitionSH, std::vector< TreeNode > &treeNodes, ANumber aWeight, number maxChildWeight, pcl::ProcessCommunicator &com)
Definition partitioner_dynamic_bisection.cpp:558
int classify_elem(elem_t *e, int splitAxis, number splitValue)
Definition partitioner_dynamic_bisection.cpp:1051
SPProcessHierarchy m_nextProcessHierarchy
Definition partitioner_dynamic_bisection.h:259
void enable_longest_split_axis(bool enable)
enables automatical determination of split-axis by longest geometry extension
Definition partitioner_dynamic_bisection.h:81
SPProcessHierarchy m_processHierarchy
Definition partitioner_dynamic_bisection.h:258
int num_split_improvement_iterations() const
the maximum number of iterations performed to find a good split plane
Definition partitioner_dynamic_bisection.h:93
TElem elem_t
Definition partitioner_dynamic_bisection.h:60
void gather_weights_from_level(int baseLvl, int childLvl, ANumber aWeight, bool copyToVMastersOnBaseLvl, bool markedElemsOnly)
Definition partitioner_dynamic_bisection.cpp:940
void improve_split_values(std::vector< TreeNode > &treeNodes, size_t maxIterations, ANumber aWeight, pcl::ProcessCommunicator &com)
Definition partitioner_dynamic_bisection.cpp:1145
virtual void set_balance_weights(SPBalanceWeights balanceWeights)
Definition partitioner_dynamic_bisection.cpp:129
void calculate_global_dimensions(std::vector< TreeNode > &treeNodes, number maxChildWeight, ANumber aWeight, pcl::ProcessCommunicator &com)
Definition partitioner_dynamic_bisection.cpp:1075
void set_tolerance(number tol)
sets the tolerance threshold. 1: no tolerance, 0: full tolerance.
Definition partitioner_dynamic_bisection.h:77
int m_highestRedistLevel
Definition partitioner_dynamic_bisection.h:282
void bisect_elements(std::vector< TreeNode > &childNodesOut, std::vector< TreeNode > &parentNodes, ANumber aWeight, number maxChildWeight, pcl::ProcessCommunicator &com, int cutRecursion, int splitAxis)
Definition partitioner_dynamic_bisection.cpp:652
void set_num_split_improvement_iterations(int num)
Definition partitioner_dynamic_bisection.h:94
void set_subset_handler(SmartPtr< SubsetHandler > sh)
allows to optionally specify a subset-handler on which the balancer shall operate
Definition partitioner_dynamic_bisection.cpp:94
int m_firstSplitAxisEnabled
Definition partitioner_dynamic_bisection.h:277
MultiGrid * m_mg
Definition partitioner_dynamic_bisection.h:254
number m_tolerance
Definition partitioner_dynamic_bisection.h:269
pcl::InterfaceCommunicator< layout_t > m_intfcCom
Definition partitioner_dynamic_bisection.h:260
bool static_partitioning_enabled() const
Definition partitioner_dynamic_bisection.cpp:218
void copy_partitions_to_children(ISubsetHandler &partitionSH, int lvl)
Definition partitioner_dynamic_bisection.cpp:905
virtual const std::vector< int > * get_process_map() const
returns the processes map. Updated during partitioning. may be NULL.
Definition partitioner_dynamic_bisection.cpp:199
std::vector< int > m_procMap
Definition partitioner_dynamic_bisection.h:281
virtual void set_partition_pre_processor(SPPartitionPreProcessor ppp)
Definition partitioner_dynamic_bisection.cpp:142
SPPartitionPostProcessor m_partitionPostProcessor
Definition partitioner_dynamic_bisection.h:265
Partitioner_DynamicBisection()
Definition partitioner_dynamic_bisection.cpp:50
aapos_t m_aaPos
Definition partitioner_dynamic_bisection.h:256
Grid::VertexAttachmentAccessor< apos_t > aapos_t
Definition partitioner_dynamic_bisection.h:64
IPartitioner base_class
Definition partitioner_dynamic_bisection.h:59
virtual ~Partitioner_DynamicBisection()
Definition partitioner_dynamic_bisection.cpp:74
GridLayoutMap::Types< elem_t >::Layout::LevelLayout layout_t
Definition partitioner_dynamic_bisection.h:65
void set_start_split_axis(int axis)
sets the axis with which bisection is started.
Definition partitioner_dynamic_bisection.h:90
SPBalanceWeights m_balanceWeights
Definition partitioner_dynamic_bisection.h:263
SPPartitionPreProcessor m_partitionPreProcessor
Definition partitioner_dynamic_bisection.h:264
void enable_static_partitioning(bool enable)
Definition partitioner_dynamic_bisection.cpp:210
apos_t m_aPos
Definition partitioner_dynamic_bisection.h:255
int m_lastSplitAxis
Definition partitioner_dynamic_bisection.h:274
int get_next_split_axis()
returns the next valid split axis to m_lastSplitAxis.
Definition partitioner_dynamic_bisection.cpp:876
size_t m_splitImproveIterations
Definition partitioner_dynamic_bisection.h:270
virtual SubsetHandler & get_partitions()
Definition partitioner_dynamic_bisection.cpp:186
void set_grid(MultiGrid *mg, Attachment< MathVector< dim > > aPos)
Definition partitioner_dynamic_bisection.cpp:83
bool m_staticPartitioning
Definition partitioner_dynamic_bisection.h:267
SmartPtr< SubsetHandler > m_sh
Definition partitioner_dynamic_bisection.h:257
static const size_t s_invalidIndex
Definition partitioner_dynamic_bisection.h:134
virtual bool supports_connection_weights() const
Definition partitioner_dynamic_bisection.cpp:179
virtual bool supports_repartitioning() const
Definition partitioner_dynamic_bisection.h:108
MathVector< dim > vector_t
Definition partitioner_dynamic_bisection.h:62
bool m_splitAxisEnabled[dim]
Definition partitioner_dynamic_bisection.h:275
virtual void set_partition_post_processor(SPPartitionPostProcessor ppp)
Definition partitioner_dynamic_bisection.cpp:149
double number
Definition types.h:124
the ug namespace
ConstSmartPtr< ProcessHierarchy > ConstSPProcessHierarchy
Definition process_hierarchy.h:48
defines the types that are used by a LayoutMap for a given TType.
Definition parallel_grid_layout.h:159
Definition partitioner_dynamic_bisection.h:142
size_t size() const
Definition partitioner_dynamic_bisection.h:170
bool empty() const
Definition partitioner_dynamic_bisection.h:171
ElemList(std::vector< Entry > *entries)
Definition partitioner_dynamic_bisection.h:145
size_t last() const
Definition partitioner_dynamic_bisection.h:174
std::vector< Entry > * entries()
Definition partitioner_dynamic_bisection.h:178
size_t m_first
Definition partitioner_dynamic_bisection.h:182
size_t m_last
Definition partitioner_dynamic_bisection.h:183
size_t first() const
Definition partitioner_dynamic_bisection.h:173
void add(size_t entryInd)
Definition partitioner_dynamic_bisection.h:150
size_t m_num
Definition partitioner_dynamic_bisection.h:184
std::vector< Entry > * m_entries
Definition partitioner_dynamic_bisection.h:181
ElemList()
Definition partitioner_dynamic_bisection.h:143
elem_t * elem(size_t entryInd) const
Definition partitioner_dynamic_bisection.h:176
void set_entry_list(std::vector< Entry > *entries)
Definition partitioner_dynamic_bisection.h:148
size_t next(size_t entryInd) const
Definition partitioner_dynamic_bisection.h:175
void clear()
Definition partitioner_dynamic_bisection.h:164
Definition partitioner_dynamic_bisection.h:136
elem_t * elem
Definition partitioner_dynamic_bisection.h:137
Entry(elem_t *e)
Definition partitioner_dynamic_bisection.h:139
size_t next
Definition partitioner_dynamic_bisection.h:138
Definition partitioner_dynamic_bisection.h:188
int splitAxis
Definition partitioner_dynamic_bisection.h:202
number minSplitValue
Definition partitioner_dynamic_bisection.h:203
number splitValue
Definition partitioner_dynamic_bisection.h:201
vector_t center
Definition partitioner_dynamic_bisection.h:196
number ratioLeft
Definition partitioner_dynamic_bisection.h:193
int numTargetProcs
Definition partitioner_dynamic_bisection.h:191
ElemList elems
Definition partitioner_dynamic_bisection.h:189
vector_t boxMax
Definition partitioner_dynamic_bisection.h:198
bool bisectionComplete
Definition partitioner_dynamic_bisection.h:206
int firstProc
Definition partitioner_dynamic_bisection.h:190
size_t firstChildNode
Definition partitioner_dynamic_bisection.h:194
vector_t boxMin
Definition partitioner_dynamic_bisection.h:197
number maxSplitValue
Definition partitioner_dynamic_bisection.h:204
number totalWeight
Definition partitioner_dynamic_bisection.h:199