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

Optimized Partitions with weights on edges

parent 8983ea9b
No related branches found
No related tags found
No related merge requests found
......@@ -488,7 +488,7 @@ int PartitionGraph(Graph &graph, meshPartitionOptions &options)
break;
case 4: // Vertices Multi-Contrained Recursive
Msg::Info("Vertices Multi-Constrained Recursive Algorithm Used");
wgtflag = 2;
wgtflag = 3;
metisOptions[0] = 1;
metisOptions[1] = options.edge_matching;
metisOptions[2] = 1;
......@@ -497,13 +497,13 @@ int PartitionGraph(Graph &graph, meshPartitionOptions &options)
graph.fillWithMultipleWeights(options.ncon,options.getWeightMap());
METIS_mCPartGraphRecursive
(&n,&options.ncon,&graph.xadj[graph.section[iSec]],
&graph.adjncy[graph.section[iSec]], &graph.vwgts[graph.section[iSec]], NULL, &wgtflag, &numflag,
&graph.adjncy[graph.section[iSec]], &graph.vwgts[graph.section[iSec]], &graph.adjwgts[graph.section[iSec]], &wgtflag, &numflag,
&options.num_partitions, metisOptions, &edgeCut,
&graph.partition[graph.section[iSec]]);
break;
case 5: // Vertices Multi-Constrained K-way
Msg::Info("Vertices Multi-Constrained K-way Algorithm Used");
wgtflag = 2;
wgtflag = 3;
metisOptions[0] = 1;
metisOptions[1] = options.edge_matching;
metisOptions[2] = 1;
......@@ -511,9 +511,9 @@ int PartitionGraph(Graph &graph, meshPartitionOptions &options)
metisOptions[4] = 0;
printf("Tolerance for Constraints:[");
for(int u=0;u<options.ncon;u++){
ubvec[u]=1.0;
ubvec[u]=1.03;
if(options.tolerance[u]%options.num_partitions>0){
ubvec[u] = (float) ceil((float)options.tolerance[u]/options.num_partitions)/((float)options.tolerance[u]/options.num_partitions);
//ubvec[u] = (float) ceil((float)options.tolerance[u]/options.num_partitions)/((float)options.tolerance[u]/options.num_partitions);
}
printf(" %f", ubvec[u]);
}
......@@ -522,7 +522,7 @@ int PartitionGraph(Graph &graph, meshPartitionOptions &options)
if (options.num_partitions > 1) {
METIS_mCPartGraphKway
(&n,&options.ncon,&graph.xadj[graph.section[iSec]],
&graph.adjncy[graph.section[iSec]], &graph.vwgts[graph.section[iSec]], NULL, &wgtflag, &numflag,
&graph.adjncy[graph.section[iSec]], &graph.vwgts[graph.section[iSec]], &graph.adjwgts[graph.section[iSec]], &wgtflag, &numflag,
&options.num_partitions,&ubvec[0], metisOptions, &edgeCut,
&graph.partition[graph.section[iSec]]);
}
......
......@@ -91,6 +91,8 @@ class Graph
// vertices.
std::vector<int> vwgts; // Weights assigned for each
// vertex
std::vector<int> adjwgts; // Weights assigned for each
// edge
std::vector<int> section; // For separate partitioning of
// different parts of the mesh
std::vector<int> partition; // The partitions output from the
......@@ -136,6 +138,7 @@ class Graph
xadj.resize(_totalGrVert + 1);
adjncy.reserve(2*totalGrEdge);
vwgts.resize(_totalGrVert);
adjwgts.reserve(2*totalGrEdge);
partition.resize(_totalGrVert);
element.resize(_totalGrVert);
c2w = new int[_totalGrVert];
......@@ -187,11 +190,15 @@ class Graph
{
std::vector<MElement*>::iterator eIt;
vwgts.resize(element.size()*ncon);
adjwgts.resize(adjncy.size());
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];
}
for(int j=xadj[localElNum];j<xadj[localElNum+1];j++){
adjwgts[j]+=weightMap[(*eIt)->getNum()][0];
}
localElNum+=1;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment