Skip to content
Snippets Groups Projects
Commit cbe3bdc7 authored by Amaury Johnen's avatar Amaury Johnen
Browse files

clean up

parent 8c73c5cc
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// Amaury Johnen (a.johnen@ulg.ac.be) // Amaury Johnen (a.johnen@ulg.ac.be)
// //
#define REC2D_WAIT_TIME .05 #define REC2D_WAIT_TIME .01
#define REC2D_NUM_ACTIO 1000 #define REC2D_NUM_ACTIO 1000
// #define REC2D_SMOOTH // #define REC2D_SMOOTH
...@@ -154,7 +154,6 @@ Recombine2D::Recombine2D(GFace *gf) : _gf(gf), _strategy(0), _numChange(0) ...@@ -154,7 +154,6 @@ Recombine2D::Recombine2D(GFace *gf) : _gf(gf), _strategy(0), _numChange(0)
double angle = _geomAngle(it->first, double angle = _geomAngle(it->first,
it->second._gEdges, it->second._gEdges,
it->second._mElements); it->second._mElements);
Msg::Info("ang %g", angle);
new Rec2DVertex(it->second._rv, angle); new Rec2DVertex(it->second._rv, angle);
} }
} }
...@@ -259,58 +258,47 @@ bool Recombine2D::recombine() ...@@ -259,58 +258,47 @@ bool Recombine2D::recombine()
double Recombine2D::recombine(int depth) double Recombine2D::recombine(int depth)
{ {
Rec2DData::checkAngle();
//return .0;
Rec2DData::clearChanges(); Rec2DData::clearChanges();
double bestGlobalQuality; double bestGlobalQuality;
_data->sortActions(); Rec2DNode *root = new Rec2DNode(NULL, NULL, bestGlobalQuality, depth);
_data->printActions();
_numChange++;
_data->printActions();
//Rec2DNode *root = new Rec2DNode(NULL, NULL, bestGlobalQuality, depth);
//_data->printActions();
/*Rec2DNode *root = new Rec2DNode(NULL, NULL, bestGlobalQuality, depth);
Rec2DNode *currentNode = root->selectBestNode(); Rec2DNode *currentNode = root->selectBestNode();
double time = Cpu(); double time = Cpu();
//int num = 20, i = 0; //int num = 20, i = 0;
//double dx = .0, dy = .0; //double dx = .0, dy = .0;
int k = 0; while (currentNode) {
while (currentNode && ++k < 90) {
_data->printActions();
FlGui::instance()->check(); FlGui::instance()->check();
#if 0 //def REC2D_DRAW // draw state at origin #ifdef REC2D_DRAW // draw state at origin
//_gf->triangles = _data->_tri; _gf->triangles = _data->_tri;
//_gf->quadrangles = _data->_quad; _gf->quadrangles = _data->_quad;
CTX::instance()->mesh.changed = ENT_ALL; CTX::instance()->mesh.changed = ENT_ALL;
drawContext::global()->draw(); drawContext::global()->draw();
while (Cpu()-time < REC2D_WAIT_TIME) while (Cpu()-time < REC2D_WAIT_TIME)
FlGui::instance()->check(); FlGui::instance()->check();
time = Cpu(); time = Cpu();
#endif #endif
//#ifdef REC2D_DRAW #if 0//def REC2D_DRAW // draw all states
// if ( !((i+1) % ((int)std::sqrt(num)+1)) ) { if ( !((i+1) % ((int)std::sqrt(num)+1)) ) {
// dx = .0; dx = .0;
// dy -= 1.1; dy -= 1.1;
// } }
// else else
// dx += 1.1; dx += 1.1;
// drawState(dx, dy); drawState(dx, dy);
// CTX::instance()->mesh.changed = ENT_ALL; CTX::instance()->mesh.changed = ENT_ALL;
// drawContext::global()->draw(); drawContext::global()->draw();
// while (Cpu()-time < REC2D_WAIT_TIME) while (Cpu()-time < REC2D_WAIT_TIME)
// FlGui::instance()->check(); FlGui::instance()->check();
// ++i; ++i;
// time = Cpu(); time = Cpu();
//#endif #endif
currentNode->develop(depth, bestGlobalQuality); currentNode->develop(depth, bestGlobalQuality);
currentNode = currentNode->selectBestNode(); currentNode = currentNode->selectBestNode();
} }
return Rec2DData::getGlobalQuality(); return Rec2DData::getGlobalQuality();
//_data->printState();*/ //_data->printState();
} }
void Recombine2D::clearChanges() void Recombine2D::clearChanges()
...@@ -786,19 +774,6 @@ void Rec2DData::printActions() ...@@ -786,19 +774,6 @@ void Rec2DData::printActions()
} }
new PView("Jmin_bad", "ElementData", Recombine2D::getGFace()->model(), data); new PView("Jmin_bad", "ElementData", Recombine2D::getGFace()->model(), data);
Msg::Info(" "); Msg::Info(" ");
_actions.front()->print();
it = _actions.end();
(*(--it))->print();
(*(--it))->print();
(*(--it))->print();
}
void Rec2DData::checkAngle()
{
iter_rel it = firstElement();
for (; it != lastElement(); ++it) {
(*it)->printAngles();
}
} }
int Rec2DData::getNewParity() int Rec2DData::getNewParity()
...@@ -1571,38 +1546,8 @@ int Rec2DTwoTri2Quad::getNum(double shiftx, double shifty) ...@@ -1571,38 +1546,8 @@ int Rec2DTwoTri2Quad::getNum(double shiftx, double shifty)
return quad->getNum(); return quad->getNum();
} }
void Rec2DTwoTri2Quad::print()
{
Msg::Info("Printing Action %d (%d,%d)...", this, _triangles[0]->getNum(), _triangles[1]->getNum());
Msg::Info("edge0 %g", _edges[0]->getQual());
Msg::Info("edge1 %g", _edges[1]->getQual());
Msg::Info("edge2 %g", _edges[2]->getQual());
Msg::Info("edge3 %g", _edges[3]->getQual());
Msg::Info("edge4 %g", _edges[4]->getQual());
Msg::Info("angles %g - %g", _vertices[0]->getAngle(), _vertices[1]->getAngle());
Msg::Info("merge0 %g", _vertices[0]->getGainMerge(_triangles[0], _triangles[1]));
Msg::Info("merge1 %g", _vertices[1]->getGainMerge(_triangles[0], _triangles[1]));
_vertices[0]->printGainMerge(_triangles[0], _triangles[1]);
_vertices[1]->printGainMerge(_triangles[0], _triangles[1]);
}
void Rec2DTwoTri2Quad::printCoord()
{
Msg::Info("(%g %g) (%g %g) (%g %g) (%g %g) %d %d", _vertices[0]->u(),
_vertices[0]->v(),
_vertices[1]->u(),
_vertices[1]->v(),
_vertices[2]->u(),
_vertices[2]->v(),
_vertices[3]->u(),
_vertices[3]->v(),
_vertices[0]->getNumElements(),
_vertices[1]->getNumElements() );
}
Rec2DElement* Rec2DTwoTri2Quad::getRandomElement() Rec2DElement* Rec2DTwoTri2Quad::getRandomElement()
{ {
return _triangles[0];
return _triangles[rand() % 2]; return _triangles[rand() % 2];
} }
...@@ -2074,23 +2019,6 @@ double Rec2DVertex::getGainMerge(Rec2DElement *rel1, Rec2DElement *rel2) ...@@ -2074,23 +2019,6 @@ double Rec2DVertex::getGainMerge(Rec2DElement *rel1, Rec2DElement *rel2)
+ getGainDegree(-1); + getGainDegree(-1);
} }
void Rec2DVertex::printGainMerge(Rec2DElement *rel1, Rec2DElement *rel2)
{
double qualAngle = _sumQualAngle;
Msg::Info("qualAngle %g", getQualAngle());
Msg::Info("sumAngle %g", qualAngle);
Msg::Info("- %g (ang %g)", _angle2Qual(rel1->getAngle(this)), rel1->getAngle(this));
Msg::Info("- %g (ang %g)", _angle2Qual(rel2->getAngle(this)), rel2->getAngle(this));
Msg::Info("+ %g (ang %g)", _angle2Qual(rel1->getAngle(this) + rel2->getAngle(this)), rel1->getAngle(this) + rel2->getAngle(this));
qualAngle -= _angle2Qual(rel1->getAngle(this));
qualAngle -= _angle2Qual(rel2->getAngle(this));
qualAngle += _angle2Qual(rel1->getAngle(this) + rel2->getAngle(this));
Msg::Info("= %g", qualAngle);
Msg::Info("gainDegree %g", getGainDegree(-1));
Msg::Info("return %g", qualAngle / (double)(_elements.size()-1) - getQualAngle()
+ getGainDegree(-1));
}
void Rec2DVertex::add(Rec2DEdge *re) void Rec2DVertex::add(Rec2DEdge *re)
{ {
for (unsigned int i = 0; i < _edges.size(); ++i) { for (unsigned int i = 0; i < _edges.size(); ++i) {
...@@ -2391,8 +2319,6 @@ double Rec2DElement::getAngle(Rec2DVertex *rv) ...@@ -2391,8 +2319,6 @@ double Rec2DElement::getAngle(Rec2DVertex *rv)
int i1 = (index+_numEdge-1)%_numEdge; int i1 = (index+_numEdge-1)%_numEdge;
int i0 = (index+1)%_numEdge; int i0 = (index+1)%_numEdge;
Msg::Info("atan2 %g %g (%g %g | %g %g | %g %g)", atan2(vert[i0]->v() - rv->v(), vert[i0]->u() - rv->u()), atan2(vert[i1]->v() - rv->v(), vert[i1]->u() - rv->u()),
vert[i1]->u(), vert[i1]->v(), rv->u(), rv->v(), vert[i0]->u(), vert[i0]->v());
double ang = atan2(vert[i0]->v() - rv->v(), vert[i0]->u() - rv->u()) double ang = atan2(vert[i0]->v() - rv->v(), vert[i0]->u() - rv->u())
- atan2(vert[i1]->v() - rv->v(), vert[i1]->u() - rv->u()); - atan2(vert[i1]->v() - rv->v(), vert[i1]->u() - rv->u());
...@@ -2404,18 +2330,6 @@ double Rec2DElement::getAngle(Rec2DVertex *rv) ...@@ -2404,18 +2330,6 @@ double Rec2DElement::getAngle(Rec2DVertex *rv)
return ang; return ang;
} }
void Rec2DElement::printAngles()
{
std::vector<Rec2DVertex*> vert;
getVertices(vert);
Msg::Info("ELEMENT %d (%g %g | %g %g | %g %g)", getNum(),
vert[0]->u(), vert[0]->v(), vert[1]->u(), vert[1]->v(), vert[2]->u(), vert[2]->v());
for (int i = 0; i < _numEdge; ++i) {
Msg::Info("%g", getAngle(vert[i]));
}
}
void Rec2DElement::getAssumedParities(int *p) const void Rec2DElement::getAssumedParities(int *p) const
{ {
if (_numEdge == 4) { if (_numEdge == 4) {
......
...@@ -195,8 +195,6 @@ class Rec2DData { ...@@ -195,8 +195,6 @@ class Rec2DData {
std::vector<Rec2DVertex*>&); std::vector<Rec2DVertex*>&);
static inline void clearAssumedParities() {_current->_oldParity.clear();} static inline void clearAssumedParities() {_current->_oldParity.clear();}
static void revertAssumedParities(); static void revertAssumedParities();
static void checkAngle();
}; };
class Rec2DDataChange { class Rec2DDataChange {
...@@ -254,8 +252,6 @@ class Rec2DAction { ...@@ -254,8 +252,6 @@ class Rec2DAction {
virtual void getNeighbourElements(std::vector<Rec2DElement*>&) = 0; virtual void getNeighbourElements(std::vector<Rec2DElement*>&) = 0;
virtual int getNum(double shiftx, double shifty) = 0; virtual int getNum(double shiftx, double shifty) = 0;
virtual Rec2DElement* getRandomElement() = 0; virtual Rec2DElement* getRandomElement() = 0;
virtual void printCoord() = 0;
virtual void print() = 0;
private : private :
virtual void _computeGlobQual() = 0; virtual void _computeGlobQual() = 0;
...@@ -290,9 +286,6 @@ class Rec2DTwoTri2Quad : public Rec2DAction { ...@@ -290,9 +286,6 @@ class Rec2DTwoTri2Quad : public Rec2DAction {
virtual int getNum(double shiftx, double shifty); virtual int getNum(double shiftx, double shifty);
virtual Rec2DElement* getRandomElement(); virtual Rec2DElement* getRandomElement();
virtual void printCoord();
virtual void print();
private : private :
virtual void _computeGlobQual(); virtual void _computeGlobQual();
void _doWhatYouHaveToDoWithParity(Rec2DDataChange*); void _doWhatYouHaveToDoWithParity(Rec2DDataChange*);
...@@ -362,7 +355,6 @@ class Rec2DVertex { ...@@ -362,7 +355,6 @@ class Rec2DVertex {
void hide(); void hide();
void reveal(); void reveal();
void printGainMerge(Rec2DElement *rel1, Rec2DElement *rel2);
inline double getAngle() const {return _angle;} inline double getAngle() const {return _angle;}
inline double getQual() const {return getQualDegree() + getQualAngle();} inline double getQual() const {return getQualDegree() + getQualAngle();}
inline double getQualAngle() const {return _sumQualAngle/(double)_elements.size();} inline double getQualAngle() const {return _sumQualAngle/(double)_elements.size();}
...@@ -463,7 +455,6 @@ class Rec2DElement { ...@@ -463,7 +455,6 @@ class Rec2DElement {
void createElement(double shiftx, double shifty) const; void createElement(double shiftx, double shifty) const;
double getAngle(Rec2DVertex*); double getAngle(Rec2DVertex*);
void printAngles();
inline int getNumActions() const {return _actions.size();} inline int getNumActions() const {return _actions.size();}
inline Rec2DAction* getAction(int i) const {return _actions[i];} inline Rec2DAction* getAction(int i) const {return _actions[i];}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment