ug4
load_balancer.h
Go to the documentation of this file.
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__UG__load_balancer__
34 #define __H__UG__load_balancer__
35 
36 #include <vector>
37 #include "lib_grid/multi_grid.h"
39 #include "common/util/table.h"
40 #include "partitioner.h"
41 
42 #ifdef UG_PARALLEL
44 #endif
45 
46 
47 namespace ug{
48 
49 
52  public:
53  LoadBalancer();
54 
55  virtual ~LoadBalancer();
56 
57  virtual void set_grid(MultiGrid* mg);
58 
59  virtual void enable_vertical_interface_creation(bool enable);
60 
63 
65 
68  virtual void set_balance_weights(SPBalanceWeights balanceWeights);
69 
71 
74 // virtual void set_connection_weights(SmartPtr<IConnectionWeights> conWeights);
75 
76 // /// Inserts a new distribution level on which the grid may be redistributed
77 // /** Use this method to map a region of levels to a subset of the active processes.
78 // * Very useful for hierarchical distribution. Elements between the given level
79 // * and the level specified in the next cut are distributed between the given
80 // * number of processes only.
81 // * The new level has to lie above the level added before.*/
82 // virtual void add_distribution_level(size_t lvl, size_t numProcsPerProc);
83 
85  virtual void set_next_process_hierarchy(SPProcessHierarchy procHierarchy);
86 
88 
89  virtual void set_balance_threshold(number threshold);
90 
94  virtual void set_element_threshold(size_t threshold);
95 
96 // /// returns the quality of the current distribution
97 // virtual number distribution_quality();
98 
100 
116  virtual bool rebalance();
117 
118 
127  virtual number estimate_distribution_quality(std::vector<number>* pLvlQualitiesOut);
132 
143 
148  bool problems_occurred();
149 
150  void create_quality_record(const char* label);
151  void print_quality_records() const;
152  void print_last_quality_record() const;
153 
154  private:
155  template <class TElem>
156  number estimate_distribution_quality_impl(std::vector<number>* pLvlQualitiesOut);
157 
164 // SPConnectionWeights m_connectionWeights;
168 };
169 
171 } // end of namespace
172 
173 #endif
parameterString partitioner
Serialization of data associated with grid elements.
Definition: serialization.h:186
void add(SPVertexDataSerializer cb)
Adds a callback class for serialization and deserialization.
Definition: serialization.cpp:69
A load-balancer redistributes grids using the specified partitioner and process-hierarchy.
Definition: load_balancer.h:51
virtual void set_next_process_hierarchy(SPProcessHierarchy procHierarchy)
Sets a callback class which provides connection weights between two neighbor elements.
Definition: load_balancer.cpp:307
void print_last_quality_record() const
Definition: load_balancer.cpp:565
virtual void set_balance_weights(SPBalanceWeights balanceWeights)
Sets a callback class which provides the balance weight for a given element.
Definition: load_balancer.cpp:287
number estimate_distribution_quality()
Definition: load_balancer.cpp:453
StringStreamTable m_qualityRecords
Definition: load_balancer.h:166
virtual void add_serializer(SPGridDataSerializer cb)
add serialization callbacks.
Definition: load_balancer.h:139
GridDataSerializationHandler m_serializer
Definition: load_balancer.h:165
virtual void set_balance_threshold(number threshold)
If the balance falls below the given threshold, then rebalance will perform redistribution.
Definition: load_balancer.cpp:313
virtual void set_grid(MultiGrid *mg)
Definition: load_balancer.cpp:269
bool m_createVerticalInterfaces
Definition: load_balancer.h:167
LoadBalancer()
Definition: load_balancer.cpp:253
number estimate_distribution_quality_impl(std::vector< number > *pLvlQualitiesOut)
Definition: load_balancer.cpp:364
virtual void add_serializer(SPFaceDataSerializer cb)
add serialization callbacks.
Definition: load_balancer.h:137
virtual void add_serializer(SPVertexDataSerializer cb)
add serialization callbacks.
Definition: load_balancer.h:135
size_t m_elementThreshold
Definition: load_balancer.h:160
virtual void enable_vertical_interface_creation(bool enable)
Definition: load_balancer.cpp:275
void create_quality_record(const char *label)
Definition: load_balancer.cpp:527
bool problems_occurred()
indicates whether problems occurred during the last rebalancing.
Definition: load_balancer.cpp:325
virtual ~LoadBalancer()
Definition: load_balancer.cpp:264
virtual bool rebalance()
performs load balancing if the balance is too bad or if a distribution level has been reached.
Definition: load_balancer.cpp:460
virtual void set_partitioner(SPPartitioner partitioner)
Sets the partitioner which is used to partition the grid into balanced parts.
Definition: load_balancer.cpp:281
SPPartitioner m_partitioner
Definition: load_balancer.h:162
SPBalanceWeights m_balanceWeights
Definition: load_balancer.h:163
MultiGrid * m_mg
Definition: load_balancer.h:158
virtual void add_serializer(SPEdgeDataSerializer cb)
add serialization callbacks.
Definition: load_balancer.h:136
SPProcessHierarchy m_processHierarchy
Definition: load_balancer.h:161
void print_quality_records() const
Definition: load_balancer.cpp:560
virtual void add_serializer(SPVolumeDataSerializer cb)
add serialization callbacks.
Definition: load_balancer.h:138
number m_balanceThreshold
Definition: load_balancer.h:159
virtual void set_element_threshold(size_t threshold)
Definition: load_balancer.cpp:319
Definition: multi_grid.h:72
double number
Definition: types.h:124
the ug namespace