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

fix bug, add 3 strategies, and more

parent 0a397870
No related branches found
No related tags found
No related merge requests found
......@@ -491,31 +491,31 @@ void GetOptions(int argc, char *argv[])
Msg::Fatal("Missing number of lloyd iterations");
}
#if defined(HAVE_MESH)
else if(!strcmp(argv[i] + 1, "microstructure")) {
i++;
int j;
int radical;
double max;
std::vector<double> properties;
if(argv[i]){
std::ifstream file(argv[i++]);
file >> max;
file >> radical;
properties.clear();
properties.resize(4*max);
for(j=0;j<max;j++){
file >> properties[4*j];
file >> properties[4*j+1];
file >> properties[4*j+2];
file >> properties[4*j+3];
}
voroMetal3D vm1;
vm1.execute(properties,radical,0.1);
GModel::current()->load("MicrostructurePolycrystal3D.geo");
voroMetal3D vm2;
vm2.correspondance(0.00001);
}
}
else if(!strcmp(argv[i] + 1, "microstructure")) {
i++;
int j;
int radical;
double max;
std::vector<double> properties;
if(argv[i]){
std::ifstream file(argv[i++]);
file >> max;
file >> radical;
properties.clear();
properties.resize(4*max);
for(j=0;j<max;j++){
file >> properties[4*j];
file >> properties[4*j+1];
file >> properties[4*j+2];
file >> properties[4*j+3];
}
voroMetal3D vm1;
vm1.execute(properties,radical,0.1);
GModel::current()->load("MicrostructurePolycrystal3D.geo");
voroMetal3D vm2;
vm2.correspondance(0.00001);
}
}
#endif
else if(!strcmp(argv[i] + 1, "nopopup")) {
CTX::instance()->noPopup = 1;
......@@ -821,6 +821,31 @@ void GetOptions(int argc, char *argv[])
else
Msg::Fatal("Missing algorithm");
}
else if(!strcmp(argv[i] + 1, "rec")) {
i++;
if(argv[i]) {
CTX::instance()->mesh.doRecombinationTest = 1;
CTX::instance()->mesh.recTestName = argv[i];
i++;
}
else
Msg::Fatal("Missing file name for recomb");
}
else if(!strcmp(argv[i] + 1, "beg")) {
i++;
if(argv[i])
CTX::instance()->mesh.recombinationTestStart = atoi(argv[i++]);
else
Msg::Fatal("Missing number for begin recTest");
}
else if(!strcmp(argv[i] + 1, "nogreedy")) {
i++;
CTX::instance()->mesh.recombinationTestNoGreedyStrat = 1;
}
else if(!strcmp(argv[i] + 1, "newstrat")) {
i++;
CTX::instance()->mesh.recombinationTestNewStrat = 1;
}
else if(!strcmp(argv[i] + 1, "format") || !strcmp(argv[i] + 1, "f")) {
i++;
if(argv[i]) {
......
......@@ -31,6 +31,11 @@ struct contextMeshOptions {
int dual, voronoi, drawSkinOnly, colorCarousel, labelSampling;
int fileFormat, nbSmoothing, algo2d, algo3d, algoSubdivide;
int algoRecombine, recombineAll, recombine3DAll;
//-- for recombination test (amaury) --
int doRecombinationTest, recombinationTestStart;
int recombinationTestNoGreedyStrat, recombinationTestNewStrat;
std::string recTestName;
//-------------------------------------
int remeshParam, remeshAlgo;
int order, secondOrderLinear, secondOrderIncomplete;
int secondOrderExperimental, meshOnlyVisible;
......
......@@ -1055,6 +1055,14 @@ StringXNumber MeshOptions_Number[] = {
"Apply recombination algorithm to all surfaces, ignoring per-surface spec" },
{ F|O, "Recombine3DAll" , opt_mesh_recombine3d_all , 0 ,
"Apply recombination3D algorithm to all volumes, ignoring per-volume spec" },
{ F|O, "DoRecombinationTest" , opt_mesh_do_recombination_test , 0 ,
"Apply recombination algorithm for test" },
{ F|O, "RecombinationTestHorizStart" , opt_mesh_recombination_test_start , 1 ,
"Depth start" },
{ F|O, "RecombinationTestNoGreedyStrat" , opt_mesh_recombination_no_greedy_strat , 0 ,
"No greedy (global) strategies" },
{ F|O, "RecombinationTestNewStrat" , opt_mesh_recombination_new_strat , 0 ,
"New strategies" },
{ F|O, "RemeshAlgorithm" , opt_mesh_remesh_algo , 0 ,
"Remeshing algorithm (0=no split, 1=automatic, 2=automatic only with metis)" },
{ F|O, "RemeshParametrization" , opt_mesh_remesh_param , 4 ,
......
......@@ -5304,6 +5304,38 @@ double opt_mesh_recombine3d_all(OPT_ARGS_NUM)
return CTX::instance()->mesh.recombine3DAll;
}
double opt_mesh_do_recombination_test(OPT_ARGS_NUM)
{
if(action & GMSH_SET){
CTX::instance()->mesh.doRecombinationTest = (int)val;
}
return CTX::instance()->mesh.doRecombinationTest;
}
double opt_mesh_recombination_test_start(OPT_ARGS_NUM)
{
if(action & GMSH_SET){
CTX::instance()->mesh.recombinationTestStart = (int)val;
}
return CTX::instance()->mesh.recombinationTestStart;
}
double opt_mesh_recombination_no_greedy_strat(OPT_ARGS_NUM)
{
if(action & GMSH_SET){
CTX::instance()->mesh.recombinationTestNoGreedyStrat = (int)val;
}
return CTX::instance()->mesh.recombinationTestNoGreedyStrat;
}
double opt_mesh_recombination_new_strat(OPT_ARGS_NUM)
{
if(action & GMSH_SET){
CTX::instance()->mesh.recombinationTestNewStrat = (int)val;
}
return CTX::instance()->mesh.recombinationTestNewStrat;
}
double opt_mesh_remesh_algo(OPT_ARGS_NUM)
{
if(action & GMSH_SET){
......
......@@ -415,6 +415,10 @@ double opt_mesh_algo3d(OPT_ARGS_NUM);
double opt_mesh_algo_recombine(OPT_ARGS_NUM);
double opt_mesh_recombine_all(OPT_ARGS_NUM);
double opt_mesh_recombine3d_all(OPT_ARGS_NUM);
double opt_mesh_do_recombination_test(OPT_ARGS_NUM);
double opt_mesh_recombination_test_start(OPT_ARGS_NUM);
double opt_mesh_recombination_no_greedy_strat(OPT_ARGS_NUM);
double opt_mesh_recombination_new_strat(OPT_ARGS_NUM);
double opt_mesh_remesh_algo(OPT_ARGS_NUM);
double opt_mesh_remesh_param(OPT_ARGS_NUM);
double opt_mesh_algo_subdivide(OPT_ARGS_NUM);
......
This diff is collapsed.
......@@ -41,6 +41,7 @@
#ifdef REC2D_RECO_BLOS
#include "meshGFaceOptimize.h"
#endif
#include <fstream>
class Rec2DNode;
......@@ -83,6 +84,8 @@ class Recombine2D {
backgroundMesh *_bgm;
static Recombine2D *_cur;
int _numChange;
double _lastRunTime;
Rec2DNode *_curNode;
// Parameter :
const bool _collapses;
......@@ -126,24 +129,26 @@ class Recombine2D {
const Rec2DNode *node = NULL);
// Revert recombinations
static void clearChanges();
void clearChanges();
// Save mesh & stats
void saveMesh(std::string);
void saveStats(std::fstream*);
// Get/Set methods
inline void setHorizon(int h) {_horizon = h;}
inline void setStrategy(int s) {_strategy = s;}
inline void setQualCriterion(Rec2DQualCrit c) {
Msg::Info("--3--%d----- %d", c, _qualCriterion);_qualCriterion = c;
Msg::Info("--4--%d----- %d", c, _qualCriterion);}
inline void setQualCriterion(int a) {
Msg::Info("--1--%d----- %d", a, _qualCriterion);_qualCriterion = (Rec2DQualCrit)a;
Msg::Info("--2--%d----- %d", a, _qualCriterion);} /////////////
inline void setHorizon(int h) {_horizon = h;} //1
inline void setStrategy(int s) {_strategy = s;} //0->6
inline void setQualCriterion(Rec2DQualCrit c) {_qualCriterion = c;}
inline void setQualCriterion(int a) {_qualCriterion = (Rec2DQualCrit)a;} //0
static inline GFace const *const getGFace() {return _cur->_gf;}
static inline backgroundMesh const *const bgm() {return _cur->_bgm;}
static inline int getNumChange() {return _cur->_numChange;}
static inline void incNumChange() {++_cur->_numChange;}
static inline Rec2DQualCrit getQualCrit() {return _cur->_qualCriterion;}
static inline void setNewTreeNode(Rec2DNode *rn) {_cur->_curNode = rn;}
// What is asked ?
static inline bool dynamicTree() {return _cur->_strategy == 6;}
static inline bool blossomRec() {return _cur->_recombineWithBlossom;}
static inline bool blossomQual() {return _cur->_qualCriterion == 0;}
static inline bool verticesQual() {return _cur->_qualCriterion == 1;}
......@@ -182,6 +187,8 @@ class Recombine2D {
// Miscellaneous
void compareWithBlossom();
int computeQualBlossom() const;
inline int getNumElemBlossom() const {return elist[0];}
static void add(MQuadrangle *q);
static void add(MTriangle *t);
static void colorFromBlossom(const Rec2DElement *tri1,
......@@ -286,6 +293,7 @@ class Rec2DData {
#ifdef REC2D_RECO_BLOS
static inline int getBlosQual() {return _cur->_0blossomQuality;}
#endif
static inline unsigned int getNumElements() {return _cur->_elements.size();}
// Add/Remove Entities
static void add(const Rec2DEdge*);
......@@ -864,10 +872,7 @@ class Rec2DVertex {
const Rec2DEdge *adjacent1 = NULL,
const Rec2DEdge *adjacent2 = NULL) const;
#endif
inline void updateWAQualEdges(double d, int a = 0) {
_sumWQualEdge += d;
_sumWeightEdge += a;
}
void updateWAQualEdges(double d, int a = 0);
// Miscellaneous
void relocate(SPoint2 p);
......@@ -986,7 +991,7 @@ class Rec2DElement {
inline bool isQuad() const {return _numEdge == 4;}
inline MElement* getMElement() const {return _mEl;}
bool hasIdenticalNeighbour() const;
#ifdef REC2D_DRAW
#if 1//def REC2D_DRAW
MTriangle* getMTriangle() const {
if (_numEdge == 3) {
if (_mEl)
......@@ -1052,6 +1057,9 @@ class Rec2DNode {
bool operator<(Rec2DNode&);
bool canBeDeleted() const;
inline bool isInSequence() const {return _father && _father->_depth != _depth;}
inline bool notInSubTree() const {return hasOneSon() && _son[0]->_depth == _depth;}
inline bool hasOneSon() const {return _son[0] && !_son[1];}
inline Rec2DNode* getSon() const {return _son[0];}
// Debug
void draw(double dx, double dy) {
......@@ -1081,7 +1089,7 @@ class Rec2DNode {
return i < REC2D_NUMB_SONS;
}*/
inline int _getNumSon() const;
void _delSons();
void _delSons(bool alsoFirst);
void _orderSons();
bool _rmvSon(Rec2DNode *n);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment