From fdc867f49e746af9258af668acda364743f278ec Mon Sep 17 00:00:00 2001 From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be> Date: Tue, 5 Apr 2011 12:13:11 +0000 Subject: [PATCH] --- Mesh/HighOrder.cpp | 3 ++- Mesh/highOrderTools.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Mesh/HighOrder.cpp b/Mesh/HighOrder.cpp index 6c8b2a0918..ab6ad3ff14 100644 --- a/Mesh/HighOrder.cpp +++ b/Mesh/HighOrder.cpp @@ -1350,6 +1350,8 @@ void SetOrderN(GModel *m, int order, bool linear, bool incomplete) setHighOrder(*it, edgeVertices, faceVertices, linear, incomplete, nPts, displ2D, displ3D); + highOrderTools hot (m); + // now we smooth mesh the internal vertices of the faces // we do that model face by model face std::vector<MElement*> bad; @@ -1383,7 +1385,6 @@ void SetOrderN(GModel *m, int order, bool linear, bool incomplete) double t2 = Cpu(); if (!linear){ - highOrderTools hot (m); hot.ensureMinimumDistorsion(0.1); checkHighOrderTriangles("final mesh", m, bad, worst); } diff --git a/Mesh/highOrderTools.cpp b/Mesh/highOrderTools.cpp index 5c8df2bf57..cf46a8b496 100644 --- a/Mesh/highOrderTools.cpp +++ b/Mesh/highOrderTools.cpp @@ -73,8 +73,10 @@ void highOrderTools::ensureMinimumDistorsion(MElement *e, double threshold) } // a == 0 -> straight // a == 1 -> curved + int ITER = 1; while(1){ double a = 0.5*(a1+a2); + if (ITER > 10) a = 0.; for(int i = 0; i < e->getNumVertices(); i++){ MVertex *v = e->getVertex(i); v->x() = a * x[i][0] + (1.-a) * X[i][0]; @@ -87,6 +89,8 @@ void highOrderTools::ensureMinimumDistorsion(MElement *e, double threshold) if (dist > 0 && fabs(dist-threshold) < .05)break; if (dist < threshold)a2 = a; else a1 = a; + if (a > .99 || a < .01) break; + ++ITER; } // printf("element done\n"); } @@ -612,11 +616,14 @@ double highOrderTools::apply_incremental_displacement (double max_incr, // uncurve elements that are invalid void highOrderTools::ensureMinimumDistorsion (std::vector<MElement*> &all, double threshold){ + int num = 0; while(1){ double minD; std::vector<MElement*> disto; getDistordedElements(all, threshold, disto, minD); + if (num == disto.size())break; if (!disto.size())break; + num = disto.size(); Msg::Info("fixing %d bad curved elements (worst disto %g)",disto.size(),minD); for (int i=0;i<disto.size();i++){ ensureMinimumDistorsion(disto[i],threshold); -- GitLab