Skip to content
Snippets Groups Projects
Commit 2222462f authored by Jean-François Remacle's avatar Jean-François Remacle
Browse files

Added some python access to adaptivity

Frontal mesher is less sensitive to small geometrical features (avoid obtuse triangles)
parent ed321104
No related branches found
No related tags found
No related merge requests found
...@@ -170,4 +170,11 @@ bool reparamMeshVertexOnEdge(MVertex *v, const GEdge *ge, double &param); ...@@ -170,4 +170,11 @@ bool reparamMeshVertexOnEdge(MVertex *v, const GEdge *ge, double &param);
double angle3Vertices(MVertex *p1, MVertex *p2, MVertex *p3); double angle3Vertices(MVertex *p1, MVertex *p2, MVertex *p3);
inline double distance (MVertex *v1, MVertex *v2){
const double dx = v1->x() - v2->x();
const double dy = v1->y() - v2->y();
const double dz = v1->z() - v2->z();
return sqrt(dx*dx+dy*dy+dz*dz);
}
#endif #endif
...@@ -387,11 +387,12 @@ void meshGEdge::operator() (GEdge *ge) ...@@ -387,11 +387,12 @@ void meshGEdge::operator() (GEdge *ge)
// force odd number of points for if blossom is used for recombination // force odd number of points for if blossom is used for recombination
if(ge->meshAttributes.Method != MESH_TRANSFINITE && if(ge->meshAttributes.Method != MESH_TRANSFINITE &&
CTX::instance()->mesh.algoRecombine == 1 && N % 2 == 0){ (CTX::instance()->mesh.algoRecombine == 1 || CTX::instance()->mesh.recombineAll) && N % 2 == 0){
if(CTX::instance()->mesh.recombineAll){ // if(CTX::instance()->mesh.recombineAll){
N++; N++;
// }
} }
else{ /* else{
std::list<GFace*> faces = ge->faces(); std::list<GFace*> faces = ge->faces();
for(std::list<GFace*>::iterator it = faces.begin(); it != faces.end(); it++){ for(std::list<GFace*>::iterator it = faces.begin(); it != faces.end(); it++){
if((*it)->meshAttributes.recombine){ if((*it)->meshAttributes.recombine){
...@@ -401,6 +402,7 @@ void meshGEdge::operator() (GEdge *ge) ...@@ -401,6 +402,7 @@ void meshGEdge::operator() (GEdge *ge)
} }
} }
} }
*/
// printFandPrimitive(ge->tag(),Points); // printFandPrimitive(ge->tag(),Points);
......
...@@ -574,19 +574,16 @@ bool insertVertex(bool force, GFace *gf, MVertex *v, double *param , MTri3 *t, ...@@ -574,19 +574,16 @@ bool insertVertex(bool force, GFace *gf, MVertex *v, double *param , MTri3 *t,
MTri3 *t4; MTri3 *t4;
t4 = new MTri3(t, LL,0,&Us,&Vs,gf); t4 = new MTri3(t, LL,0,&Us,&Vs,gf);
double d1 = sqrt((it->v[0]->x() - v->x()) * (it->v[0]->x() - v->x()) + // double din = t->getInnerRadius();
(it->v[0]->y() - v->y()) * (it->v[0]->y() - v->y()) +
(it->v[0]->z() - v->z()) * (it->v[0]->z() - v->z())); double d1 = distance(it->v[0],v);
double d2 = sqrt((it->v[1]->x() - v->x()) * (it->v[1]->x() - v->x()) + double d2 = distance(it->v[1],v);
(it->v[1]->y() - v->y()) * (it->v[1]->y() - v->y()) + double d3 = distance(it->v[0],it->v[1]);
(it->v[1]->z() - v->z()) * (it->v[1]->z() - v->z()));
const double MID[3] = {0.5*(it->v[0]->x()+it->v[1]->x()), // avoid angles that are too obtuse
0.5*(it->v[0]->y()+it->v[1]->y()), double cosv = ((d1*d1+d2*d2-d3*d3)/(2.*d1*d2));
0.5*(it->v[0]->z()+it->v[1]->z())};
double d3 = sqrt((MID[0] - v->x()) * (MID[0] - v->x()) + if ((d1 < LL * .25 || d2 < LL * .25 || cosv < -0.5) && !force) {
(MID[1] - v->y()) * (MID[1] - v->y()) +
(MID[2] - v->z()) * (MID[2] - v->z()));
if ((d1 < LL * .25 || d2 < LL * .25 || d3 < LL * .25) && !force) {
onePointIsTooClose = true; onePointIsTooClose = true;
} }
...@@ -746,35 +743,8 @@ static bool insertAPoint(GFace *gf, std::set<MTri3*,compareTri3Ptr>::iterator it ...@@ -746,35 +743,8 @@ static bool insertAPoint(GFace *gf, std::set<MTri3*,compareTri3Ptr>::iterator it
MTri3 *ptin = 0; MTri3 *ptin = 0;
bool inside = false; bool inside = false;
double uv[2]; double uv[2];
// FIXME !!! ----> FIXED (JFR)
if (0 && MTri3::radiusNorm == 2){
inside = invMapUV(worst->tri(), center, Us, Vs, uv, 1.e-8);
if (inside)ptin = worst;
if (!inside && worst->getNeigh(0)){
inside |= invMapUV(worst->getNeigh(0)->tri(), center, Us, Vs, uv, 1.e-8);
if (inside)ptin = worst->getNeigh(0);
}
if (!inside && worst->getNeigh(1)){
inside |= invMapUV(worst->getNeigh(1)->tri(), center, Us, Vs, uv, 1.e-8);
if (inside)ptin = worst->getNeigh(1);
}
if (!inside && worst->getNeigh(2)){
inside |= invMapUV(worst->getNeigh(2)->tri(), center, Us, Vs, uv, 1.e-8);
if (inside)ptin = worst->getNeigh(2);
}
if (!inside){
ptin = search4Triangle (worst, center, Us, Vs, AllTris,uv);
if (ptin)inside = true;
}
}
else {
ptin = search4Triangle (worst, center, Us, Vs, AllTris,uv); ptin = search4Triangle (worst, center, Us, Vs, AllTris,uv);
// if (!ptin){
// printf("strange : %g %g seems to be out of the domain for face %d\n",
// center[0],center[1],gf->tag());
// }
if (ptin) inside = true; if (ptin) inside = true;
}
if (inside) { if (inside) {
// we use here local coordinates as real coordinates // we use here local coordinates as real coordinates
...@@ -1025,24 +995,6 @@ double optimalPointFrontal (GFace *gf, ...@@ -1025,24 +995,6 @@ double optimalPointFrontal (GFace *gf,
2 * dir[1] * dir[0] * metric[1] + 2 * dir[1] * dir[0] * metric[1] +
dir[1] * dir[1] * metric[2]); dir[1] * dir[1] * metric[2]);
// const double p = 0.5 * lengthMetric(P, Q, metric); // / RATIO;
/*
const double rhoM1 = 0.5 *
(vSizes[base->getVertex(ip1)->getIndex()] +
vSizes[base->getVertex(ip2)->getIndex()] ) / sqrt(3.);// * RATIO;
const double rhoM2 = 0.5 *
(vSizesBGM[base->getVertex(ip1)->getIndex()] +
vSizesBGM[base->getVertex(ip2)->getIndex()] ) / sqrt(3.);// * RATIO;
const double rhoM = Extend1dMeshIn2dSurfaces() ? std::min(rhoM1, rhoM2) : rhoM2;
*/
// const double rhoM_hat = std::min(std::max(rhoM, p), (p * p + q * q) / (2 * q));
// double d = (rhoM_hat + sqrt (rhoM_hat * rhoM_hat - p * p)) / RATIO;
//const double d = 100./RATIO;
// printf("(%g %g) (%g %g) %g %g %g %g %g %g\n",
// P[0],P[1],Q[0],Q[1],RATIO,p,q,rhoM,rhoM_hat,d);
// printf("size %12.5E\n",vSizesBGM[base->getVertex(ip1)->getIndex()]);
const double rhoM1 = 0.5* const double rhoM1 = 0.5*
(vSizes[base->getVertex(ip1)->getIndex()] + (vSizes[base->getVertex(ip1)->getIndex()] +
vSizes[base->getVertex(ip2)->getIndex()] ) ;// * RATIO; vSizes[base->getVertex(ip2)->getIndex()] ) ;// * RATIO;
...@@ -1053,17 +1005,22 @@ double optimalPointFrontal (GFace *gf, ...@@ -1053,17 +1005,22 @@ double optimalPointFrontal (GFace *gf,
const double rhoM_hat = rhoM; const double rhoM_hat = rhoM;
const double q = lengthMetric(center, midpoint, metric); const double q = lengthMetric(center, midpoint, metric);
const double d = rhoM_hat * sqrt(3.)*0.5; const double d = rhoM_hat * sqrt(3.)*0.5;
// d is corrected in a way that the mesh size is computed at point newPoint
// printf("%12.5E %12.5E\n",d,RATIO); // printf("%12.5E %12.5E\n",d,RATIO);
// const double L = d ; // const double L = d ;
// avoid to go toooooo far // avoid to go toooooo far
const double L = d > q ? q : d; const double L = d > q ? q : d;
newPoint[0] = midpoint[0] + L * dir[0]/RATIO; newPoint[0] = midpoint[0] + L * dir[0]/RATIO;
newPoint[1] = midpoint[1] + L * dir[1]/RATIO; newPoint[1] = midpoint[1] + L * dir[1]/RATIO;
return L;// > q ? d : q; return L;// > q ? d : q;
} }
......
...@@ -3039,6 +3039,8 @@ void recombineIntoQuads(GFace *gf, ...@@ -3039,6 +3039,8 @@ void recombineIntoQuads(GFace *gf,
} }
double t2 = Cpu(); double t2 = Cpu();
Msg::Info("Blossom recombination algorithm completed (%g s)", t2 - t1); Msg::Info("Blossom recombination algorithm completed (%g s)", t2 - t1);
quadsToTriangles(gf, 0.01);
// if(haveParam) laplaceSmoothing(gf,CTX::instance()->mesh.nbSmoothing);
return; return;
} }
......
...@@ -12,6 +12,7 @@ double PViewEvaluator::operator() (const double x, const double y, const double ...@@ -12,6 +12,7 @@ double PViewEvaluator::operator() (const double x, const double y, const double
PViewData * pvd = _pv->getData(); PViewData * pvd = _pv->getData();
double value; double value;
bool found = pvd->searchScalar(x, y, z, &value, _step); bool found = pvd->searchScalar(x, y, z, &value, _step);
printf("found %d %g %g %g %g\n",found,x,y,value,x*x+y*y);
if (found) return value; if (found) return value;
return 1.e22; return 1.e22;
} }
...@@ -39,7 +39,6 @@ namespace std { ...@@ -39,7 +39,6 @@ namespace std {
%template(DoubleVector) std::vector<double, std::allocator<double> >; %template(DoubleVector) std::vector<double, std::allocator<double> >;
%template(DoubleVectorVector) std::vector<std::vector<double, std::allocator<double> > >; %template(DoubleVectorVector) std::vector<std::vector<double, std::allocator<double> > >;
%template(StringVector) std::vector<std::string, std::allocator<std::string> >; %template(StringVector) std::vector<std::string, std::allocator<std::string> >;
%template(IntDoubleMap) std::map < int , double >;
} }
%pointer_functions(double,doublep) %pointer_functions(double,doublep)
%pointer_functions(int,intp) %pointer_functions(int,intp)
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
%module gmshPost %module gmshPost
%include typemaps.i %include typemaps.i
%include std_string.i %include std_string.i
%include std_vector.i
%include std_map.i
%{ %{
#include "GmshConfig.h" #include "GmshConfig.h"
...@@ -14,11 +16,20 @@ ...@@ -14,11 +16,20 @@
#endif #endif
%} %}
namespace std {
%template(DoubleVector) std::vector<double, std::allocator<double> >;
%template(IntDoubleVectorMap) std::map < int , std::vector<double, std::allocator<double> > >;
}
%include "GmshConfig.h" %include "GmshConfig.h"
#if defined(HAVE_POST) #if defined(HAVE_POST)
%include "PView.h" %include "PView.h"
%include "PViewFactory.h" %include "PViewFactory.h"
%apply double &OUTPUT { double &val} %apply double &OUTPUT { double &val}
%include "PViewData.h" %include "PViewData.h"
%include "simpleFunction.h"
%template(simpleFunctionDouble) simpleFunction<double>;
%include "PViewAsSimpleFunction.h"
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment