Commit 8865487f by Christophe Geuzaine

pp

parent 842de351
Pipeline #1098 passed with stage
in 36 minutes 51 seconds
......@@ -2824,29 +2824,30 @@ int UnpartitionMesh(GModel *const model)
// Create the partition according to the element split given by elmToPartition
// Returns: 0 = success, 1 = no elements found.
int PartitionUsingThisSplit(GModel *const model, unsigned int npart, hashmap<MElement*, unsigned int> &elmToPartition)
int PartitionUsingThisSplit(GModel *const model, unsigned int npart,
hashmap<MElement*, unsigned int> &elmToPartition)
{
Graph graph(model);
if(MakeGraph(model, graph)) return 1;
createDualGraph(graph, false);
graph.nparts(npart);
if(elmToPartition.size() != graph.ne()){
Msg::Error("All elements are not partitioned.");
return 1;
}
unsigned int *part = new unsigned int[graph.ne()];
for(unsigned int i = 0; i < graph.ne(); i++){
if(graph.element(i)){
part[i] = elmToPartition[graph.element(i)]-1;
}
}
// Check and correct the topology
for(unsigned int i = 0; i < graph.ne(); i++){
if(graph.element(i)->getDim() == (int)graph.dim()) continue;
for(unsigned int j = graph.xadj(i); j < graph.xadj(i+1); j++){
if(graph.element(graph.adjncy(j))->getDim() == graph.element(i)->getDim()+1){
if(part[i] != part[graph.adjncy(j)]){
......@@ -2855,7 +2856,7 @@ int PartitionUsingThisSplit(GModel *const model, unsigned int npart, hashmap<MEl
break;
}
}
if(graph.element(graph.adjncy(j))->getDim() == graph.element(i)->getDim()+2){
if(part[i] != part[graph.adjncy(j)]){
part[i] = part[graph.adjncy(j)];
......@@ -2863,7 +2864,7 @@ int PartitionUsingThisSplit(GModel *const model, unsigned int npart, hashmap<MEl
break;
}
}
if(graph.element(graph.adjncy(j))->getDim() == graph.element(i)->getDim()+3){
if(part[i] != part[graph.adjncy(j)]){
part[i] = part[graph.adjncy(j)];
......@@ -2874,13 +2875,13 @@ int PartitionUsingThisSplit(GModel *const model, unsigned int npart, hashmap<MEl
}
}
graph.partition(part);
std::vector< std::set<MElement*> > boundaryElements = graph.getBoundaryElements();
model->setNumPartitions(graph.nparts());
CreateNewEntities(model, elmToPartition);
elmToPartition.clear();
if(CTX::instance()->mesh.partitionCreateTopology){
Msg::StatusBar(true, "Creating partition topology...");
CreatePartitionBoundaries(model, boundaryElements);
......@@ -2888,7 +2889,7 @@ int PartitionUsingThisSplit(GModel *const model, unsigned int npart, hashmap<MEl
BuildTopology(model);
Msg::StatusBar(true, "Done creating partition topology");
}
AssignMeshVertices(model);
movePeriodicNodesFromParentToPartitionEntities(model);
......@@ -2920,7 +2921,7 @@ int ConvertOldPartitioningToNewOne(GModel *const model)
partitions.insert(e->getPartition());
}
}
return PartitionUsingThisSplit(model, partitions.size(), elmToPartition);
}
......
......@@ -10,6 +10,7 @@
#include <unordered_map>
#define hashmap std::unordered_map
#else
#include <map>
#define hashmap std::map
#endif
......@@ -18,6 +19,9 @@ class GModel;
int PartitionMesh(GModel *const model);
int UnpartitionMesh(GModel *const model);
int ConvertOldPartitioningToNewOne(GModel *const model);
int PartitionUsingThisSplit(GModel *const model, unsigned int npart, hashmap<MElement*, unsigned int> &elmToPartition);
int PartitionUsingThisSplit(GModel *const model, unsigned int npart,
hashmap<MElement*, unsigned int> &elmToPartition);
#undef hashmap
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment