33 #ifndef __H__UG__domain_distribution_impl__
34 #define __H__UG__domain_distribution_impl__
51 template <
typename TDomain>
53 int numCellsX,
int numCellsY,
int numCellsZ,
66 if(!domain.distributed_grid_manager()){
67 UG_LOG(
"A distributed grid manager is required in the given domain.\n");
71 typedef typename TDomain::position_attachment_type TAPos;
73 domain.position_attachment());
84 if(bucketSubset == -1)
90 PartitionElements_RegularGrid<Volume>(
93 numCellsX, numCellsY, numCellsZ, aaPos,
96 PartitionElements_RegularGrid<Volume>(
99 numCellsX, numCellsY, numCellsZ, aaPos,
100 cbConsiderElem, bucketSubset);
104 PartitionElements_RegularGrid<Face>(
107 numCellsX, numCellsY, numCellsZ, aaPos,
110 PartitionElements_RegularGrid<Face>(
113 numCellsX, numCellsY, numCellsZ, aaPos,
114 cbConsiderElem, bucketSubset);
118 PartitionElements_RegularGrid<Edge>(
121 numCellsX, numCellsY, numCellsZ, aaPos,
124 PartitionElements_RegularGrid<Edge>(
127 numCellsX, numCellsY, numCellsZ, aaPos,
128 cbConsiderElem, bucketSubset);
132 PartitionElements_RegularGrid<Vertex>(
135 numCellsX, numCellsY, numCellsZ, aaPos,
138 PartitionElements_RegularGrid<Vertex>(
141 numCellsX, numCellsY, numCellsZ, aaPos,
142 cbConsiderElem, bucketSubset);
145 LOG(
"partitioning could not be performed - "
146 <<
"grid doesn't contain any elements!\n");
152 if(!partitionHandler.
empty(bucketSubset)){
160 UG_LOG(
"WARNING: PartitionDomain_RegularGrid is currently only implemented for");
161 UG_LOG(
" parallel environments.\n");
165 template <
typename TDomain>
168 int numPartitions,
size_t baseLevel,
169 int hWeight,
int vWeight)
186 if(bucketSubset == -1)
192 baseLevel, hWeight, vWeight);
194 for(
size_t lvl = 0; lvl < baseLevel; ++lvl)
200 baseLevel, hWeight, vWeight);
202 for(
size_t lvl = 0; lvl < baseLevel; ++lvl)
208 baseLevel, hWeight, vWeight);
210 for(
size_t lvl = 0; lvl < baseLevel; ++lvl)
215 if(!partitionHandler.
empty(bucketSubset)){
222 UG_LOG(
"WARNING in PartitionDomain_MetisKWay: Only available in parallel builds.\n");
227 template <
typename TDomain>
230 int numPartitions,
size_t baseLevel,
250 if(bucketSubset == -1)
257 boost::function<int (
Volume*,
Volume*)> f = boost::ref(wFct);
260 for(
size_t lvl = 0; lvl < baseLevel; ++lvl)
265 boost::function<int (
Face*,
Face*)> f = boost::ref(wFct);
268 for(
size_t lvl = 0; lvl < baseLevel; ++lvl)
273 boost::function<int (
Edge*,
Edge*)> f = boost::ref(wFct);
276 for(
size_t lvl = 0; lvl < baseLevel; ++lvl)
281 if(!partitionHandler.
empty(bucketSubset)){
288 UG_LOG(
"WARNING in PartitionDomain_MetisKWay: Only available in parallel builds.\n");
294 template <
typename TDomain>
297 int numPartitions,
size_t level)
306 switch(domain.domain_info().element_type()){
320 UG_THROW(
"Partitioning only works for element types EDGE, FACE, and VOLUME!");
328 template <
typename TDomain>
331 int numPartitions,
size_t level)
340 switch(domain.domain_info().element_type()){
354 UG_THROW(
"Partitioning only works for element types EDGE, FACE, and VOLUME!");
362 template <
typename TDomain>
365 bool createVerticalInterfaces)
371 typedef typename TDomain::grid_type GridType;
375 if(partitionHandler.
grid() != pGrid.
get()){
381 typedef typename TDomain::position_attachment_type position_attachment_type;
414 create(*pGrid, domainOut.position_attachment());
417 create(*domainOut.subset_handler());
420 serializer.
add(posSerializer);
421 serializer.
add(shSerializer);
423 std::vector<std::string> additionalSHNames = domainOut.additional_subset_handler_names();
424 for(
size_t i = 0; i < additionalSHNames.size(); ++i){
428 serializer.
add(shSerializer);
433 DistributeGrid(*pGrid, partitionHandler, serializer, createVerticalInterfaces,
T * get()
returns encapsulated pointer
Definition: smart_pointer.h:197
bool valid() const
returns true if the pointer is valid, false if not.
Definition: smart_pointer.h:206
callback that always returns true
Definition: basic_callbacks.h:50
Base-class for edges.
Definition: grid_base_objects.h:397
Faces are 2-dimensional objects.
Definition: grid_base_objects.h:510
static SmartPtr< GeomObjDataSerializer< TGeomObj > > create(Grid &g, TAttachment a)
Definition: serialization.h:293
the generic attachment-accessor for access to grids attachment pipes.
Definition: grid.h:182
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
Partitions elements of a grid into several subsets.
Definition: subset_handler_grid.h:53
bool empty() const
returns true if the subset-handler contains no elements of the given type.
Definition: subset_handler_grid_impl.hpp:190
void assign_subset(Vertex *elem, int subsetIndex)
assigns a vertex to a subset.
Definition: subset_handler_grid.cpp:204
Grid * grid() const
returns a pointer to the grid on which the subset-handler works.
Definition: subset_handler_interface.cpp:304
Returns true if an element is a regular surface element.
Definition: parallel_callbacks.h:48
size_t num(int level) const
Definition: multi_grid.h:154
geometry_traits< TElem >::iterator end(int level)
Definition: multi_grid.h:168
geometry_traits< TElem >::iterator begin(int level)
Definition: multi_grid.h:158
Used to describe how a domain shall be distributed in a parallel environment.
Definition: partition_map.h:54
SmartPtr< SubsetHandler > get_partition_handler()
Definition: partition_map.cpp:58
size_t num_target_procs()
Definition: partition_map.cpp:70
void assign_grid(Grid &grid)
Definition: partition_map.cpp:52
std::vector< int > & get_target_proc_vec()
Definition: partition_map.cpp:90
void add_target_proc(int tarProcRank)
Definition: partition_map.cpp:61
int find_target_proc(int procRank)
returns the index at which the given process lies. -1 if it doesn't exist.
Definition: partition_map.cpp:105
Definition: partition_weighting_callbacks.h:50
void set_subset_handler(MGSubsetHandler *sh)
Definition: partition_weighting_callbacks.h:59
static SPGridDataSerializer create(ISubsetHandler &sh)
Definition: serialization.h:314
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition: grid_base_objects.h:754
int ProcRank()
returns the rank of the process
Definition: pcl_base.cpp:83
#define LOG(msg)
Definition: common.h:60
#define UG_THROW(msg)
Definition: error.h:57
#define UG_LOG(msg)
Definition: log.h:367
template bool PartitionMultiGridLevel_MetisKway< Edge >(SubsetHandler &, MultiGrid &, int, size_t)
template bool PartitionMultiGrid_MetisKway< Face >(SubsetHandler &, MultiGrid &, int, size_t, int, int)
bool DistributeGrid(MultiGrid &mg, SubsetHandler &shPartition, GridDataSerializationHandler &serializer, bool createVerticalInterfaces, const std::vector< int > *processMap, const pcl::ProcessCommunicator &procComm)
distributes/redistributes parts of possibly distributed grids.
Definition: distribution.cpp:1802
template bool PartitionMultiGridLevel_ParmetisKway< Edge >(SubsetHandler &, MultiGrid &, int, size_t)
static bool PartitionDomain_MetisKWay(TDomain &domain, PartitionMap &partitionMap, int numPartitions, size_t baseLevel=0, int hWeight=1, int vWeight=1)
partitions a domain by using graph-based partitioning by METIS
template bool PartitionMultiGrid_MetisKway< Edge >(SubsetHandler &, MultiGrid &, int, size_t, int, int)
static bool PartitionDomain_LevelBased(TDomain &domain, PartitionMap &partitionMap, int numPartitions, size_t level)
Partitions a domain based on the elements of one level.
template bool PartitionMultiGridLevel_ParmetisKway< Volume >(SubsetHandler &, MultiGrid &, int, size_t)
template bool PartitionMultiGrid_MetisKway< Volume >(SubsetHandler &, MultiGrid &, int, size_t, int, int)
@ VOLUME
Definition: grid_base_objects.h:63
@ EDGE
Definition: grid_base_objects.h:61
@ FACE
Definition: grid_base_objects.h:62
static bool PartitionDomain_RegularGrid(TDomain &domain, PartitionMap &partitionMap, int numCellsX, int numCellsY, int numCellsZ, bool surfaceOnly)
partitions a domain by sorting all elements into a regular grid
static bool DistributeDomain(TDomain &domainOut, PartitionMap &partitionMap, bool createVerticalInterfaces)
distributes a already distributed domain onto the specified processes
template bool PartitionMultiGridLevel_ParmetisKway< Face >(SubsetHandler &, MultiGrid &, int, size_t)
template bool PartitionMultiGridLevel_MetisKway< Volume >(SubsetHandler &, MultiGrid &, int, size_t)
template bool PartitionMultiGridLevel_MetisKway< Face >(SubsetHandler &, MultiGrid &, int, size_t)
static bool PartitionDistributedDomain_LevelBased(TDomain &domain, PartitionMap &partitionMap, int numPartitions, size_t level)
Definition: domain_distribution_impl.hpp:330
#define PCL_PROFILE(name)
Definition: pcl_profiling.h:49
#define PCL_PROFILE_END()
Definition: pcl_profiling.h:50
#define PROFILE_FUNC_GROUP(groups)
Definition: profiler.h:258