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

Several things for multi-constraint mesh partitioning + start circumscribed...

Several things for multi-constraint mesh partitioning + start circumscribed circle of MElement (need to be finished)
parent 78ba2114
No related branches found
No related tags found
No related merge requests found
......@@ -193,6 +193,11 @@ class MElement
// tangent to the most boundaries of the element.
virtual double getInnerRadius(){ return 0.; }
// get the radius of the circumscribed circle/sphere if it exists,
// otherwise get the maximum radius of all the circles/spheres
// tangent to the most boundaries of the element.
virtual double getOuterRadius(){ return 0.; }
// compute the barycenter
virtual SPoint3 barycenter();
......
......@@ -267,7 +267,11 @@ double MQuadrangle::angleShapeMeasure()
return 1.;
#endif
}
double MQuadrangle::getOuterRadius()
{
// TO DO!!!!!!!!!!!!! (BRUNO SENY)
return 1.0;
}
double MQuadrangle::getInnerRadius()
{
// get the coordinates (x, y, z) of the 4 points defining the Quad
......
......@@ -39,6 +39,7 @@ class MQuadrangle : public MElement {
v[2] = _v[2];
v[3] = _v[3];
}
void projectInMeanPlane(double *xn, double *yn);
public :
MQuadrangle(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, int num=0, int part=0)
: MElement(num, part)
......@@ -141,6 +142,7 @@ class MQuadrangle : public MElement {
// planar, we compute the mean plane due to the least-square
// criterion.
virtual double getInnerRadius();
virtual double getOuterRadius();
private:
int edges_quad(const int edge, const int vert) const
{
......
......@@ -44,7 +44,21 @@ double MTriangle::getInnerRadius()
dist[i] = e.getVertex(0)->distance(e.getVertex(1));
k += 0.5 * dist[i];
}
return sqrt(k * (k - dist[0]) * (k - dist[1]) * (k - dist[2])) / k;
double area = sqrt(k*(k-dist[0])*(k-dist[1])*(k-dist[2]));
return area/k;
}
double MTriangle::getOuterRadius()
{
// radius of circle circumscribing a triangle
double dist[3], k = 0.;
for (int i = 0; i < 3; i++){
MEdge e = getEdge(i);
dist[i] = e.getVertex(0)->distance(e.getVertex(1));
k += 0.5 * dist[i];
}
double area = sqrt(k*(k-dist[0])*(k-dist[1])*(k-dist[2]));
return dist[0]*dist[1]*dist[2]/(4*area);
}
double MTriangle::angleShapeMeasure()
......
......@@ -54,6 +54,7 @@ class MTriangle : public MElement {
virtual double gammaShapeMeasure();
virtual double distoShapeMeasure();
virtual double getInnerRadius();
virtual double getOuterRadius();
virtual double angleShapeMeasure();
virtual int getNumVertices() const { return 3; }
virtual MVertex *getVertex(int num){ return _v[num]; }
......
......@@ -59,7 +59,7 @@ extern "C" void METIS_mCPartGraphRecursive
(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *,
int *, idxtype *);
extern "C" void METIS_mCPartGraphKway
(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *,
(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *,
int *, idxtype *);
......@@ -437,6 +437,7 @@ int PartitionGraph(Graph &graph, meshPartitionOptions &options)
int numflag = 0;
// if metisOptions[0]=0 then default options
int metisOptions[5];
float ubvec[options.ncon];
int edgeCut;
const int iSec = 0;
switch(options.algorithm) {
......@@ -507,11 +508,21 @@ int PartitionGraph(Graph &graph, meshPartitionOptions &options)
metisOptions[2] = 1;
metisOptions[3] = options.refine_algorithm;
metisOptions[4] = 0;
printf("Tolerance for Constraints:[");
for(int u=0;u<options.ncon;u++){
ubvec[u]=1.0;
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);
}
printf(" %f", ubvec[u]);
}
printf("] \n");
graph.fillWithMultipleWeights(options.ncon,options.getWeightMap());
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,
&options.num_partitions, metisOptions, &edgeCut,
&options.num_partitions,ubvec, metisOptions, &edgeCut,
&graph.partition[graph.section[iSec]]);
}
break;
......
......@@ -97,6 +97,8 @@ class meshPartitionOptions
std::map<int, std::vector<int> > weightMap;
std::vector<int> tolerance;
public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment