Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
partitioner.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017: 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// NOTE: Classes in this file were originally defined in 'load_balancer.h'
34
35#ifndef __H__UG_partitioner
36#define __H__UG_partitioner
37
38#include "process_hierarchy.h"
39#include "lib_grid/multi_grid.h"
41
42namespace ug{
43
46
47class IPartitioner;
48
50 public:
51
52 virtual ~IBalanceWeights() {}
53 virtual void refresh_weights(int baseLevel) {};
54
55 virtual number get_weight(Vertex*) {return 1.;}
56 virtual number get_weight(Edge*) {return 1.;}
57 virtual number get_weight(Face*) {return 1.;}
58 virtual number get_weight(Volume*) {return 1.;}
59
60 virtual number get_refined_weight(Vertex* e) {return get_weight(e);}
61 virtual number get_refined_weight(Edge* e) {return 2. * get_weight(e);}
62 virtual number get_refined_weight(Face* e) {return 4. * get_weight(e);}
63 virtual number get_refined_weight(Volume* e) {return 8. * get_weight(e);}
64
65 virtual bool has_level_offsets() {return false;}
66
68
70 virtual bool consider_in_level_above(Vertex*) {return false;}
71 virtual bool consider_in_level_above(Edge*) {return false;}
72 virtual bool consider_in_level_above(Face*) {return false;}
73 virtual bool consider_in_level_above(Volume*) {return false;}
75};
76
78
79
91{
92 public:
94
100 virtual number get_weight(GridObject* conn) = 0;
101
109 virtual bool reweigh(GridObject* conn) {return false;}
110};
111
113
114
116
120 public:
122
123 virtual void partitioning_starts ( MultiGrid* mg,
124 IPartitioner* partitioner) = 0;
125 virtual void partitioning_done ( MultiGrid* mg,
126 IPartitioner* partitioner) = 0;
127};
128
130
131
132
134
147 public:
149
151 SubsetHandler* partitions) = 0;
152 virtual void post_process(int lvl) = 0;
153 virtual void partitioning_done() = 0;
154};
155
157
158
159
161
163 public:
165 m_problemsOccurred(false),
166 m_verbose(true),
167 m_clusteredSiblings(true) {}
168
169 virtual ~IPartitioner() {}
170
171 virtual void set_next_process_hierarchy(SPProcessHierarchy procHierarchy) = 0;
172
173 virtual void set_balance_weights(SPBalanceWeights balanceWeights) {
175 "This partitioner does not support balance weights.");
176 };
177
180 "This partitioner does not support communication weights.");
181 };
182
184 UG_THROW("Partition-Pre-Processing is currently not supported by the chosen partitioner.");
185 }
186
188 UG_THROW("Partition-Post-Processing is currently not supported by the chosen partitioner.");
189 }
190
193
194 virtual bool supports_balance_weights() const {return false;}
195 virtual bool supports_communication_weights() const {return false;}
196 virtual bool supports_repartitioning() const {return false;}
197
209 virtual void enable_clustered_siblings(bool bEnable) {m_clusteredSiblings = bEnable;}
218 virtual bool partition(size_t baseLvl, size_t elementThreshold) = 0;
219
221
223 UG_LOG("IPartitioner::set_subset_handler not implemented");
224 };
225 virtual void enable_static_partitioning(bool) {
226 UG_LOG("IPartitioner::enable_static_partitioning not implemented");
227 };
228
230
232 virtual const std::vector<int>* get_process_map() const = 0;
233
235
237 virtual bool problems_occurred() {return m_problemsOccurred;}
238
240 bool verbose() const {return m_verbose;}
241
242 protected:
244
245 private:
248};
249
251
253
254}// end of namespace
255
256#endif //__H__UG_partitioner
Definition smart_pointer.h:108
Base-class for edges.
Definition grid_base_objects.h:397
Faces are 2-dimensional objects.
Definition grid_base_objects.h:510
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition grid_base_objects.h:157
Partitions elements of a grid into several subsets.
Definition subset_handler_grid.h:53
Definition partitioner.h:49
virtual void refresh_weights(int baseLevel)
Definition partitioner.h:53
virtual number get_refined_weight(Edge *e)
Definition partitioner.h:61
virtual bool consider_in_level_above(Edge *)
Relative indicator in which level the specifed elements should be partitioned.
Definition partitioner.h:71
virtual number get_refined_weight(Volume *e)
todo: use a more sophisticated implementation
Definition partitioner.h:63
virtual bool consider_in_level_above(Face *)
Relative indicator in which level the specifed elements should be partitioned.
Definition partitioner.h:72
virtual number get_weight(Vertex *)
Definition partitioner.h:55
virtual number get_refined_weight(Face *e)
todo: use a more sophisticated implementation
Definition partitioner.h:62
virtual number get_weight(Volume *)
Definition partitioner.h:58
virtual number get_weight(Edge *)
Definition partitioner.h:56
virtual number get_refined_weight(Vertex *e)
Definition partitioner.h:60
virtual bool has_level_offsets()
Definition partitioner.h:65
virtual ~IBalanceWeights()
Definition partitioner.h:52
virtual number get_weight(Face *)
Definition partitioner.h:57
virtual bool consider_in_level_above(Vertex *)
Relative indicator in which level the specifed elements should be partitioned.
Definition partitioner.h:70
virtual bool consider_in_level_above(Volume *)
Relative indicator in which level the specifed elements should be partitioned.
Definition partitioner.h:73
Definition partitioner.h:91
virtual ~ICommunicationWeights()
Definition partitioner.h:93
virtual number get_weight(GridObject *conn)=0
virtual bool reweigh(GridObject *conn)
Definition partitioner.h:109
allows to post-process partitions
Definition partitioner.h:146
virtual void partitioning_done()=0
virtual void init_post_processing(MultiGrid *mg, SubsetHandler *partitions)=0
virtual void post_process(int lvl)=0
virtual ~IPartitionPostProcessor()
Definition partitioner.h:148
allows to pre-process data before partitioning starts
Definition partitioner.h:119
virtual ~IPartitionPreProcessor()
Definition partitioner.h:121
virtual void partitioning_starts(MultiGrid *mg, IPartitioner *partitioner)=0
virtual void partitioning_done(MultiGrid *mg, IPartitioner *partitioner)=0
Partitioners can be used inside a LoadBalancer or separately to create partition maps.
Definition partitioner.h:162
virtual void set_next_process_hierarchy(SPProcessHierarchy procHierarchy)=0
bool verbose() const
Definition partitioner.h:240
virtual ~IPartitioner()
Definition partitioner.h:169
virtual bool supports_repartitioning() const
Definition partitioner.h:196
virtual ConstSPProcessHierarchy next_process_hierarchy() const =0
virtual bool supports_balance_weights() const
Definition partitioner.h:194
virtual bool supports_communication_weights() const
Definition partitioner.h:195
bool m_problemsOccurred
Definition partitioner.h:243
void set_verbose(bool verbose)
Definition partitioner.h:239
virtual void set_partition_pre_processor(SPPartitionPreProcessor)
Definition partitioner.h:183
virtual void set_balance_weights(SPBalanceWeights balanceWeights)
Definition partitioner.h:173
virtual bool problems_occurred()
indicates whether problems occurred during the last partitioning
Definition partitioner.h:237
virtual bool clustered_siblings_enabled()
Definition partitioner.h:210
virtual void enable_static_partitioning(bool)
Definition partitioner.h:225
virtual SubsetHandler & get_partitions()=0
bool m_clusteredSiblings
Definition partitioner.h:247
virtual ConstSPProcessHierarchy current_process_hierarchy() const =0
virtual bool partition(size_t baseLvl, size_t elementThreshold)=0
virtual void enable_clustered_siblings(bool bEnable)
Definition partitioner.h:209
virtual void set_partition_post_processor(SPPartitionPostProcessor)
Definition partitioner.h:187
virtual void set_subset_handler(SmartPtr< SubsetHandler >)
Definition partitioner.h:222
bool m_verbose
Definition partitioner.h:246
IPartitioner()
Definition partitioner.h:164
virtual void set_communication_weights(SPCommunicationWeights commWeights)
Definition partitioner.h:178
virtual const std::vector< int > * get_process_map() const =0
returns the processes map. Updated during partitioning. may be NULL.
Definition multi_grid.h:72
Base-class for all vertex-types.
Definition grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition grid_base_objects.h:754
SmartPtr< IPartitionPreProcessor > SPPartitionPreProcessor
Definition partitioner.h:129
SmartPtr< ICommunicationWeights > SPCommunicationWeights
Definition partitioner.h:112
SmartPtr< IPartitionPostProcessor > SPPartitionPostProcessor
Definition partitioner.h:156
SmartPtr< IPartitioner > SPPartitioner
Definition partitioner.h:250
SmartPtr< IBalanceWeights > SPBalanceWeights
Definition partitioner.h:77
#define UG_THROW(msg)
Definition error.h:57
#define UG_LOG(msg)
Definition log.h:367
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition error.h:61
double number
Definition types.h:124
the ug namespace
ConstSmartPtr< ProcessHierarchy > ConstSPProcessHierarchy
Definition process_hierarchy.h:48