33#ifndef __H__UG__domain_distribution_impl__
34#define __H__UG__domain_distribution_impl__
52template <
typename TDomain>
54 int numCellsX,
int numCellsY,
int numCellsZ,
67 if(!domain.distributed_grid_manager()){
68 UG_LOG(
"A distributed grid manager is required in the given domain.\n");
72 typedef typename TDomain::position_attachment_type TAPos;
74 domain.position_attachment());
85 if(bucketSubset == -1)
89 if(pMG->num<
Volume>() > 0){
91 PartitionElements_RegularGrid<Volume>(
94 numCellsX, numCellsY, numCellsZ, aaPos,
97 PartitionElements_RegularGrid<Volume>(
100 numCellsX, numCellsY, numCellsZ, aaPos,
101 cbConsiderElem, bucketSubset);
103 else if(pMG->num<
Face>() > 0){
105 PartitionElements_RegularGrid<Face>(
107 pMG->begin<
Face>(), pMG->end<
Face>(),
108 numCellsX, numCellsY, numCellsZ, aaPos,
111 PartitionElements_RegularGrid<Face>(
113 pMG->begin<
Face>(), pMG->end<
Face>(),
114 numCellsX, numCellsY, numCellsZ, aaPos,
115 cbConsiderElem, bucketSubset);
117 else if(pMG->num<
Edge>() > 0){
119 PartitionElements_RegularGrid<Edge>(
121 pMG->begin<
Edge>(), pMG->end<
Edge>(),
122 numCellsX, numCellsY, numCellsZ, aaPos,
125 PartitionElements_RegularGrid<Edge>(
127 pMG->begin<
Edge>(), pMG->end<
Edge>(),
128 numCellsX, numCellsY, numCellsZ, aaPos,
129 cbConsiderElem, bucketSubset);
131 else if(pMG->num<
Vertex>() > 0){
133 PartitionElements_RegularGrid<Vertex>(
136 numCellsX, numCellsY, numCellsZ, aaPos,
139 PartitionElements_RegularGrid<Vertex>(
142 numCellsX, numCellsY, numCellsZ, aaPos,
143 cbConsiderElem, bucketSubset);
146 LOG(
"partitioning could not be performed - "
147 <<
"grid doesn't contain any elements!\n");
153 if(!partitionHandler.
empty(bucketSubset)){
161 UG_LOG(
"WARNING: PartitionDomain_RegularGrid is currently only implemented for");
162 UG_LOG(
" parallel environments.\n");
166template <
typename TDomain>
169 int numPartitions,
size_t baseLevel,
170 int hWeight,
int vWeight)
187 if(bucketSubset == -1)
191 if(pMG->num<
Volume>() > 0){
193 baseLevel, hWeight, vWeight);
195 for(
size_t lvl = 0; lvl < baseLevel; ++lvl)
199 else if(pMG->num<
Face>() > 0){
201 baseLevel, hWeight, vWeight);
203 for(
size_t lvl = 0; lvl < baseLevel; ++lvl)
207 else if(pMG->num<
Edge>() > 0){
209 baseLevel, hWeight, vWeight);
211 for(
size_t lvl = 0; lvl < baseLevel; ++lvl)
216 if(!partitionHandler.
empty(bucketSubset)){
223 UG_LOG(
"WARNING in PartitionDomain_MetisKWay: Only available in parallel builds.\n");
228template <
typename TDomain>
231 int numPartitions,
size_t baseLevel,
251 if(bucketSubset == -1)
255 if(pMG->num<
Volume>() > 0){
258 std::function<int (
Volume*,
Volume*)> f = std::ref(wFct);
261 for(
size_t lvl = 0; lvl < baseLevel; ++lvl)
265 else if(pMG->num<
Face>() > 0){
266 std::function<int (
Face*,
Face*)> f = std::ref(wFct);
269 for(
size_t lvl = 0; lvl < baseLevel; ++lvl)
273 else if(pMG->num<
Edge>() > 0){
274 std::function<int (
Edge*,
Edge*)> f = std::ref(wFct);
277 for(
size_t lvl = 0; lvl < baseLevel; ++lvl)
282 if(!partitionHandler.
empty(bucketSubset)){
289 UG_LOG(
"WARNING in PartitionDomain_MetisKWay: Only available in parallel builds.\n");
295template <
typename TDomain>
298 int numPartitions,
size_t level)
307 switch(domain.domain_info().element_type()){
321 UG_THROW(
"Partitioning only works for element types EDGE, FACE, and VOLUME!");
329template <
typename TDomain>
332 int numPartitions,
size_t level)
341 switch(domain.domain_info().element_type()){
355 UG_THROW(
"Partitioning only works for element types EDGE, FACE, and VOLUME!");
363template <
typename TDomain>
366 bool createVerticalInterfaces)
372 typedef typename TDomain::grid_type GridType;
376 if(partitionHandler.
grid() != pGrid.
get()){
382 typedef typename TDomain::position_attachment_type position_attachment_type;
415 create(*pGrid, domainOut.position_attachment());
418 create(*domainOut.subset_handler());
421 serializer.
add(posSerializer);
422 serializer.
add(shSerializer);
424 std::vector<std::string> additionalSHNames = domainOut.additional_subset_handler_names();
425 for(
size_t i = 0; i < additionalSHNames.size(); ++i){
429 serializer.
add(shSerializer);
434 DistributeGrid(*pGrid, partitionHandler, serializer, createVerticalInterfaces,
Definition smart_pointer.h:107
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
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:331
#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