Skip to content
Snippets Groups Projects
Commit aca01fa6 authored by Bruno Seny's avatar Bruno Seny
Browse files

update multi-constraint partitioning

parent af362f91
No related branches found
No related tags found
No related merge requests found
......@@ -443,7 +443,7 @@ int PartitionGraph(Graph &graph, meshPartitionOptions &options)
metisOptions[2] = 1;
metisOptions[3] = 1;
metisOptions[4] = 0;
graph.fillWithMultipleWeights(options.ncon,options.getWeightMap());
graph.fillWithMultipleWeights(options.ncon,options.getWeightMapV(), options.getWeightMapE());
METIS_mCPartGraphRecursive
(&n,&options.ncon,&graph.xadj[graph.section[iSec]],
&graph.adjncy[graph.section[iSec]], &graph.vwgts[graph.section[iSec]], &graph.adjwgts[graph.section[iSec]], &wgtflag, &numflag,
......@@ -459,9 +459,9 @@ int PartitionGraph(Graph &graph, meshPartitionOptions &options)
metisOptions[3] = options.refine_algorithm;
metisOptions[4] = 0;
for(int u=0;u<options.ncon;u++){
ubvec[u]=1.03;
ubvec[u]=1.3;
}
graph.fillWithMultipleWeights(options.ncon,options.getWeightMap());
graph.fillWithMultipleWeights(options.ncon,options.getWeightMapV(), options.getWeightMapE());
if (options.num_partitions > 1) {
METIS_mCPartGraphKway
(&n,&options.ncon,&graph.xadj[graph.section[iSec]],
......
......@@ -154,29 +154,6 @@ class Graph
// Translated vertex numbers start from 1
c2w[grVertMapIt->second.index] = i + 1;
}
void computeLoads(int numParts, int numCon){
loads=new fullMatrix<int> (numParts,numCon);
for(int i=0; i<numParts;i++){
for(int j=0; j<partition.size(); j++){
if(partition[j]==i){
for(int k=0; k<numCon;k++){
(*loads)(i, k)+=vwgts[j*numCon+k];
}
}
}
}
}
void checkLoads(int numParts, int numCon){
printf("******************************************************* \n");
for(int i=0; i<numParts;i++){
printf("------- PARTITION %d: [", i+1);
for(int j=0; j<numCon; j++){
printf(" %d", (*loads)(i, j));
}
printf("] -------\n");
}
printf("******************************************************* \n");
}
void fillWeights(std::vector<int> wgts)
{
int num = 0;
......@@ -186,7 +163,7 @@ class Graph
}
}
// Add multiple weights on vertices of the graph given in a map between original element Numbers and their corresponding vector of weights
void fillWithMultipleWeights(int ncon, std::map<int, std::vector<int> > weightMap)
void fillWithMultipleWeights(int ncon, std::map<int, std::vector<int> > vWeightMap, std::map<int, int> eWeightMap)
{
std::vector<MElement*>::iterator eIt;
vwgts.resize(element.size()*ncon);
......@@ -194,10 +171,10 @@ class Graph
int localElNum=0;
for(eIt=element.begin();eIt !=element.end();eIt++){
for(int i=0; i<ncon; i++){
vwgts[localElNum*ncon+i]=weightMap[(*eIt)->getNum()][i+1];
vwgts[localElNum*ncon+i]=vWeightMap[(*eIt)->getNum()][i+1];
}
for(int j=xadj[localElNum];j<xadj[localElNum+1];j++){
adjwgts[j]+=weightMap[(*eIt)->getNum()][0];
adjwgts[j]+=eWeightMap[(*eIt)->getNum()];
}
localElNum+=1;
}
......
......@@ -81,7 +81,8 @@ class meshPartitionOptions
// NODAL WEIGHT
std::vector<int> nodalWeights;
std::map<int, std::vector<int> > weightMap;
std::map<int, std::vector<int> > vWeightMap;
std::map<int, int > eWeightMap;
std::vector<int> tolerance;
public:
......@@ -91,7 +92,8 @@ class meshPartitionOptions
int getNumOfPartitions(){ return num_partitions; }
void setNumConstraints(int numConst){ ncon = numConst; }
int getNumConstraints(){ return ncon; }
std::map<int, std::vector<int> > &getWeightMap(){ return weightMap; }
std::map<int, std::vector<int> > &getWeightMapV(){ return vWeightMap; }
std::map<int, int > &getWeightMapE(){ return eWeightMap; }
void setDefaults()
{
partitioner = 2;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment