From ed321104367c1238536aadb32f90ef4bcd6d73ce Mon Sep 17 00:00:00 2001 From: Amaury Johnan <amjohnen@gmail.com> Date: Fri, 20 Jul 2012 16:27:25 +0000 Subject: [PATCH] fix bug computation qual when degree is zero --- Mesh/meshGFaceRecombine.cpp | 30 ++++++++++++++++++++++-------- Mesh/meshGFaceRecombine.h | 3 +++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Mesh/meshGFaceRecombine.cpp b/Mesh/meshGFaceRecombine.cpp index dc2f2c873f..7e2c17dd8d 100644 --- a/Mesh/meshGFaceRecombine.cpp +++ b/Mesh/meshGFaceRecombine.cpp @@ -7,7 +7,7 @@ // Amaury Johnen (a.johnen@ulg.ac.be) // -#define REC2D_WAIT_TIME .02 +#define REC2D_WAIT_TIME .5 #define REC2D_NUM_ACTIO 1000 // #define REC2D_SMOOTH @@ -356,7 +356,7 @@ double Recombine2D::recombine(int depth) while (currentNode) { //_data->checkQuality(); FlGui::instance()->check(); -#if 0//def REC2D_DRAW // draw state at origin +#ifdef REC2D_DRAW // draw state at origin drawStateOrigin(); while (Cpu()-time < REC2D_WAIT_TIME) FlGui::instance()->check(); @@ -3124,6 +3124,7 @@ double Rec2DVertex::getQualDegree(int numEl) const return _qualVSnum[_onWhat][nEl]; if (nEl == 0) { Msg::Error("[Rec2DVertex] I don't want this anymore !"); + crash(); return -10.; } return std::max(1. - fabs(2./M_PI * _angle/(double)nEl - 1.), .0); @@ -3156,9 +3157,13 @@ double Rec2DVertex::getQual(int numAngl, double valAngl, void Rec2DVertex::addEdgeQual(double val, int num) { - double oldQual = getQual(); + double oldQual = .0; + if (_elements.size()) + oldQual = getQual(); _sumQualEdge += val; _sumEdge += num; + if (_sumEdge < 0 || _sumQualEdge < -1e12) + Msg::Error("[Rec2DVertex] Negative sum edge"); if (_elements.size()) Rec2DData::addVertQual(getQual()-oldQual); _lastUpdate = Recombine2D::getNumChange(); @@ -3352,7 +3357,9 @@ void Rec2DVertex::add(const Rec2DEdge *re) } } #ifdef REC2D_VERT_ONLY - double oldQual = getQual(); + double oldQual = .0; + if (_elements.size()) + oldQual = getQual(); #endif _edges.push_back((Rec2DEdge*)re); #ifdef REC2D_VERT_ONLY @@ -3379,13 +3386,17 @@ void Rec2DVertex::rmv(const Rec2DEdge *re) while (i < _edges.size()) { if (_edges[i] == re) { #ifdef REC2D_VERT_ONLY - double oldQual = getQual(); + double oldQual = .0; + if (_elements.size()) + oldQual = getQual(); #endif _edges[i] = _edges.back(); _edges.pop_back(); #ifdef REC2D_VERT_ONLY _sumQualEdge -= re->getWeightedQual(); _sumEdge -= re->getWeight(); + if (_sumEdge < 0 || _sumQualEdge < -1e12) + Msg::Error("[Rec2DVertex] Negative sum edge"); if (_elements.size()) Rec2DData::addVertQual(getQual()-oldQual); _lastUpdate = Recombine2D::getNumChange(); @@ -4118,6 +4129,7 @@ Rec2DNode* Rec2DNode::selectBestNode() static int a = -1; if (++a < 1) Msg::Warning("FIXME !!!"); if (_son[i]) _son[i]->rmvFather(this); + if (_son[i]) _son[i]->_ra->printTypeRew(); delete _son[i]; _son[i] = NULL; } @@ -4205,11 +4217,13 @@ bool Rec2DNode::makeChanges() if (_dataChange || !_ra) return false; _dataChange = Rec2DData::getNewDataChange(); -#if 0//def REC2D_DRAW // draw state at origin +#ifdef REC2D_DRAW // draw state at origin double time = Cpu(); - //_ra->color(0, 0, 200); + _ra->color(0, 0, 200); + _ra->printTypeRew(); + Msg::Info(" "); Recombine2D::drawStateOrigin(); - while (Cpu()-time < REC2D_WAIT_TIME) + while (Cpu()-time < REC2D_WAIT_TIME*2) FlGui::instance()->check(); #endif _ra->apply(_dataChange, _createdActions); diff --git a/Mesh/meshGFaceRecombine.h b/Mesh/meshGFaceRecombine.h index 6ec9d2ee85..d06417ed09 100644 --- a/Mesh/meshGFaceRecombine.h +++ b/Mesh/meshGFaceRecombine.h @@ -342,6 +342,7 @@ class Rec2DAction { virtual void swap(Rec2DEdge*, Rec2DEdge*) = 0; virtual void printAdress() = 0; virtual void printReward() const = 0; + virtual void printTypeRew() const = 0; virtual void printVertices() const = 0; inline void addPointing() {++_numPointing;} inline void rmvPointing() {--_numPointing;} @@ -392,6 +393,7 @@ class Rec2DTwoTri2Quad : public Rec2DAction { virtual void swap(Rec2DEdge*, Rec2DEdge*); virtual void printAdress() {Msg::Info(" %d", this);} virtual void printReward() const; + virtual void printTypeRew() const {Msg::Info("Recombine %g", _globQualIfExecuted);} virtual void printVertices() const; virtual void printIdentity() const; @@ -445,6 +447,7 @@ class Rec2DCollapse : public Rec2DAction { inline virtual void swap(Rec2DEdge *re0, Rec2DEdge *re1) {_rec->swap(re0, re1);} virtual void printAdress() {_rec->printAdress();} virtual void printReward() const; + virtual void printTypeRew() const {Msg::Info("Collapse %g", _globQualIfExecuted);} virtual void printVertices() const {_rec->printVertices();} virtual void printIdentity() const; -- GitLab