Commit f9c97148 authored by Christophe Geuzaine's avatar Christophe Geuzaine

cleanup

parent e87f3289
......@@ -34,7 +34,7 @@ public:
};
static gmshSurface *getSurface(int tag);
virtual Range<double> parBounds(int i) const = 0;
/// Underlying geometric representation of this entity.
// Underlying geometric representation of this entity.
enum gmshSurfaceType {
Plane,
Nurbs,
......
......@@ -140,12 +140,8 @@ public:
BDS_GeomEntity *g;
std::vector<BDS_Edge *> edges;
// just a transition
double &lcBGM() { return _lcBGM; }
/// \return Point characteristic length
double &lc() { return _lcPTS; }
/// \return Point characteristic length
double const &lc() const { return _lcPTS; }
bool operator<(const BDS_Point &other) const { return iD < other.iD; }
......
......@@ -37,7 +37,7 @@ struct IPT {
: _x1(x1), _x2(x2), _x3(x3), _x4(x4), _x5(0.0){};
};
////int C_COUNT = 0;
// int C_COUNT = 0;
// double _C1, _C2, _C3, _C4;
static double GMSHSIZE(const SPoint3 &p, Field *f, double lc_nodal)
......
......@@ -205,12 +205,12 @@ void filterColumns(std::vector<MElement *> &elem,
c[i]->reverse();
toKeep.push_back(c[i]);
}
// for (unsigned int i=MAX;i<c.size();i++){
/// FIXME !!!
// delete c[i];
// }
// for (unsigned int i=MAX;i<c.size();i++){
// FIXME !!!
// delete c[i];
// }
}
// printf("%d --> %d\n", (int)elem.size(), (int)toKeep.size());
// printf("%d --> %d\n", (int)elem.size(), (int)toKeep.size());
elem = toKeep;
}
......
......@@ -131,8 +131,8 @@ bool pointInsideParametricDomain(std::vector<SPoint2> &bnd, SPoint2 &p,
void trueBoundary(const char *iii, GFace *gf, std::vector<SPoint2> &bnd)
{
/// FILE* view_t = Fopen(iii,"w");
// fprintf(view_t,"View \"True Boundary\"{\n");
// FILE* view_t = Fopen(iii,"w");
// fprintf(view_t,"View \"True Boundary\"{\n");
std::vector<GEdge *> edg = gf->edges();
std::set<GEdge *> edges(edg.begin(), edg.end());
......@@ -149,16 +149,16 @@ void trueBoundary(const char *iii, GFace *gf, std::vector<SPoint2> &bnd)
double xi = r.low() + (r.high() - r.low()) * t;
p[k] = ge->reparamOnFace(gf, xi, i);
if(k > 0) {
// fprintf(view_t,"SL(%g,%g,%g,%g,%g,%g){1,1};\n",p[k-1].x(),p[k-1].y(),0.0,
// p[k].x(),p[k].y(),0.0);
// fprintf(view_t,"SL(%g,%g,%g,%g,%g,%g){1,1};\n",p[k-1].x(),p[k-1].y(),0.0,
// p[k].x(),p[k].y(),0.0);
bnd.push_back(p[k - 1]);
bnd.push_back(p[k]);
}
}
}
}
// fprintf(view_t,"};\n");
// fclose(view_t);
// fprintf(view_t,"};\n");
// fclose(view_t);
}
static void computeElementShapes(GFace *gf, double &worst, double &avg,
......@@ -192,8 +192,6 @@ public:
// only do it if a recombination has to be done
if((CTX::instance()->mesh.recombineAll || gf->meshAttributes.recombine) &&
CTX::instance()->mesh.algoRecombine == 2) {
// printf("GFace %d removing half of the points in the 1D
// mesh\n",gf->tag());
std::vector<GEdge *> const &edges = gf->edges();
std::vector<GEdge *>::const_iterator ite = edges.begin();
while(ite != edges.end()) {
......@@ -216,8 +214,6 @@ public:
_middle[MEdge(v1, v3)] = v2;
}
_backup[*ite] = (*ite)->lines;
// printf("line %d goes from %d to %d\n",
// (*ite)->tag(), (*ite)->lines.size()-1, temp.size()-1);
(*ite)->lines = temp;
}
++ite;
......@@ -319,8 +315,6 @@ public:
delete _gf->quadrangles[i];
}
_gf->quadrangles = qnew;
// printf("%d triangles %d
// quads\n",_gf->triangles.size(),_gf->quadrangles.size());
}
void finish()
{
......@@ -865,7 +859,6 @@ static void modifyInitialMeshForBoundaryLayers(
const BoundaryLayerData &c1 = _columns->getColumn(v, i);
const BoundaryLayerData &c2 = _columns->getColumn(v, i + 1);
int N = std::min(c1._column.size(), c2._column.size());
// printf("%d %d\n",c1._column.size(),c2._column.size());
std::vector<MElement *> myCol;
for(int l = 0; l < N; ++l) {
MVertex *v11, *v12, *v21, *v22;
......@@ -1202,7 +1195,6 @@ bool meshGenerator(GFace *gf, int RECUR_ITER, bool repairSelfIntersecting1dMesh,
(double)RAND_MAX;
double YY = CTX::instance()->mesh.randFactor * LC2D * (double)rand() /
(double)RAND_MAX;
// printf("%22.15E %22.15E \n",XX,YY);
doc.points[i].where.h = points[i]->u + XX;
doc.points[i].where.v = points[i]->v + YY;
doc.points[i].data = points[i];
......@@ -1598,8 +1590,6 @@ bool meshGenerator(GFace *gf, int RECUR_ITER, bool repairSelfIntersecting1dMesh,
gf->meshStatistics.smallest_edge_length,
gf->meshStatistics.nbEdge,
gf->meshStatistics.nbGoodLength);
printf("=== Efficiency index is tau=%g\n",
gf->meshStatistics.efficiency_index);
*/
gf->meshStatistics.status = GFace::DONE;
......@@ -1653,9 +1643,9 @@ bool meshGenerator(GFace *gf, int RECUR_ITER, bool repairSelfIntersecting1dMesh,
if(debug) {
char name[256];
// sprintf(name, "trueBoundary%d.pos", gf->tag());
// std::vector<SPoint2> bnd;
// trueBoundary(name, gf,bnd);
// sprintf(name, "trueBoundary%d.pos", gf->tag());
// std::vector<SPoint2> bnd;
// trueBoundary(name, gf,bnd);
sprintf(name, "real%d.pos", gf->tag());
outputScalarField(m->triangles, name, 0, gf);
sprintf(name, "param%d.pos", gf->tag());
......@@ -1962,7 +1952,8 @@ static bool buildConsecutiveListOfVertices(
return true;
}
static bool meshGeneratorPeriodic(GFace *gf, bool repairSelfIntersecting1dMesh, bool debug = true)
static bool meshGeneratorPeriodic(GFace *gf, bool repairSelfIntersecting1dMesh,
bool debug = true)
{
if(CTX::instance()->debugSurface > 0 &&
gf->tag() != CTX::instance()->debugSurface) {
......@@ -2034,7 +2025,6 @@ static bool meshGeneratorPeriodic(GFace *gf, bool repairSelfIntersecting1dMesh,
if(it2 != INV.end()) {
it->first->_periodicCounterpart = it2->second;
it2->second->_periodicCounterpart = it->first;
// printf("%d --> %d\n", it2->second->iD,it->first->iD);
}
INV[it->second] = it->first;
}
......@@ -2071,7 +2061,6 @@ static bool meshGeneratorPeriodic(GFace *gf, bool repairSelfIntersecting1dMesh,
{
int count = 0;
/////////////////////////////////////////////////////////////////
// Embedded Vertices
// add embedded vertices
std::list<GVertex *> emb_vertx = gf->embeddedVertices();
......@@ -2115,7 +2104,6 @@ static bool meshGeneratorPeriodic(GFace *gf, bool repairSelfIntersecting1dMesh,
pp->g = m->get_geom(-(*itvx)->tag(), 0);
pp->lcBGM() = BGM_MeshSize(*itvx, 0, 0, v->x(), v->y(), v->z());
pp->lc() = pp->lcBGM();
// printf("%g\n",pp->lc());
recoverMap[pp] = v;
double XX = CTX::instance()->mesh.randFactor * LC2D * (double)rand() /
(double)RAND_MAX;
......@@ -2128,7 +2116,6 @@ static bool meshGeneratorPeriodic(GFace *gf, bool repairSelfIntersecting1dMesh,
count++;
++itvx;
}
// nbPointsTotal += count;
std::vector<GEdge *> const &emb_edges = gf->embeddedEdges();
std::vector<GEdge *>::const_iterator ite = emb_edges.begin();
......@@ -2199,7 +2186,6 @@ static bool meshGeneratorPeriodic(GFace *gf, bool repairSelfIntersecting1dMesh,
pp->lcBGM() = BGM_MeshSize(*ite, uu, 0, v->x(), v->y(), v->z());
}
pp->lc() = pp->lcBGM();
// printf("%g\n",pp->lc());
recoverMap[pp] = v;
facile[v] = pp;
double XX = CTX::instance()->mesh.randFactor * LC2D *
......@@ -2223,8 +2209,6 @@ static bool meshGeneratorPeriodic(GFace *gf, bool repairSelfIntersecting1dMesh,
++ite;
}
/////////////////////////////////////////////////////////////////
for(unsigned int i = 0; i < edgeLoops_BDS.size(); i++) {
std::vector<BDS_Point *> &edgeLoop_BDS = edgeLoops_BDS[i];
for(unsigned int j = 0; j < edgeLoop_BDS.size(); j++) {
......@@ -2246,7 +2230,7 @@ static bool meshGeneratorPeriodic(GFace *gf, bool repairSelfIntersecting1dMesh,
// vertices
if(du / dv < 1200 && dv / du < 1200) {
// FIX A BUG HERE IF THE SIZE OF THE BOX IS ZERO
// Fix a bug here if the size of the box is zero
bbox.makeCube();
}
......@@ -2298,8 +2282,8 @@ static bool meshGeneratorPeriodic(GFace *gf, bool repairSelfIntersecting1dMesh,
}
#else
{
/// FIXME FOR PERIODIC : some MVertices should be duplicated...
/// Still to be done...
// FIXME for periodic: some MVertices should be duplicated... Still to be
// done
std::vector<MVertex *> v;
std::map<MVertex *, BDS_Point *> recoverMapInv;
for(unsigned int i = 0; i < edgeLoops_BDS.size(); i++) {
......@@ -2311,7 +2295,6 @@ static bool meshGeneratorPeriodic(GFace *gf, bool repairSelfIntersecting1dMesh,
}
}
// printf("coucou2 %d verices\n",v.size());
std::map<MVertex *, SPoint3> pos;
for(unsigned int i = 0; i < v.size(); i++) {
MVertex *v0 = v[i];
......@@ -2552,7 +2535,7 @@ static bool meshGeneratorPeriodic(GFace *gf, bool repairSelfIntersecting1dMesh,
gf->meshStatistics.longest_edge_length,
gf->meshStatistics.smallest_edge_length,
gf->meshStatistics.nbEdge,
gf->meshStatistics.nbGoodLength);*/
gf->meshStatistics.nbGoodLength); */
gf->meshStatistics.status = GFace::DONE;
if(debug) {
......
......@@ -297,8 +297,6 @@ bool edges_sort(std::pair<double, BDS_Edge *> a,
static bool middlePoint(GFace *gf, BDS_Edge *e, double &u, double &v)
{
// try that
double u1 = e->p1->u;
double u2 = e->p2->u;
double v1 = e->p1->v;
......@@ -324,12 +322,10 @@ static bool middlePoint(GFace *gf, BDS_Edge *e, double &u, double &v)
(Z - Z2) * (Z - Z2));
// 1 ------ p -- 2
if(l1 > 1.2 * l2) {
// printf("1 %g 2 %g \n",l1,l2);
u2 = u;
v2 = v;
}
else if(l2 > 1.2 * l1) {
// printf("1 %g 2 %g \n",l1,l2);
u1 = u;
v1 = v;
}
......@@ -363,10 +359,6 @@ static void splitEdgePass(GFace *gf, BDS_Mesh &m, double MAXE_, int &nb_split,
p->edges[j]->p1 == p ? p->edges[j]->p2 : p->edges[j]->p1;
if(!p1->degenerated && !p2->degenerated && p1->_periodicCounterpart &&
p1->_periodicCounterpart == p2) {
// printf("splitting %d %d\n",
//p->edges[i]->p1->iD,p->edges[i]->p2->iD);
// printf("splitting %d %d\n",
//p->edges[j]->p1->iD,p->edges[j]->p2->iD);
edges.push_back(std::make_pair(-10.0, p->edges[i]));
edges.push_back(std::make_pair(-10.0, p->edges[j]));
}
......@@ -410,11 +402,11 @@ static void splitEdgePass(GFace *gf, BDS_Mesh &m, double MAXE_, int &nb_split,
int N;
if(!pointInsideParametricDomain(*true_boundary, pp, out, N)) {
inside = false;
// printf("%d %d %g %g\n",e->p1->iD,e->p2->iD,U1,U2);
// printf("%g %g OUTSIDE ??\n",pp.x(),pp.y());
// FILE *f = fopen("TOTO.pos","a");
// fprintf(f,"SP(%g,%g,0){%d};\n",pp.x(),pp.y(),N);
// fclose(f);
// printf("%d %d %g %g\n",e->p1->iD,e->p2->iD,U1,U2);
// printf("%g %g OUTSIDE ??\n",pp.x(),pp.y());
// FILE *f = fopen("TOTO.pos","a");
// fprintf(f,"SP(%g,%g,0){%d};\n",pp.x(),pp.y(),N);
// fclose(f);
}
}
if(inside && gpp.succeeded()) {
......@@ -491,7 +483,7 @@ double getMaxLcWhenCollapsingEdge(GFace *gf, BDS_Mesh &m, BDS_Edge *e,
double dz = center.z() - o->Z;
double ps = dx*norm[0]+dy*norm[1]+dz*norm[2];
if (ps < 0){
// printf("FLIIIP\n");
// printf("FLIIIP\n");
return true;
}
++it;
......@@ -499,6 +491,7 @@ double getMaxLcWhenCollapsingEdge(GFace *gf, BDS_Mesh &m, BDS_Edge *e,
return false;
}
*/
void collapseEdgePass(GFace *gf, BDS_Mesh &m, double MINE_, int MAXNP,
int &nb_collaps)
{
......@@ -578,7 +571,7 @@ void CHECK_STRANGE(const char *c, BDS_Mesh &m)
}
}
}
if (strange)printf("strange(%s) = %d\n",c,strange);
if (strange) printf("strange(%s) = %d\n",c,strange);
return;
for (size_t int i=0;i<m.triangles.size();++i){
......@@ -701,7 +694,6 @@ void modifyInitialMeshToRemoveDegeneracies(
std::set<MVertex *, MVertexLessThanNum> degenerated;
std::vector<BDS_Edge *> degenerated_edges;
getDegeneratedVertices(m, recoverMap, degenerated, degenerated_edges);
// printf("%d degenerated vertices\n",degenerated.size());
for(std::map<BDS_Point *, MVertex *, PointLessThan>::iterator it =
recoverMap->begin();
it != recoverMap->end(); ++it) {
......@@ -785,20 +777,20 @@ void refineMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT,
double maxE = MAXE_;
double minE = MINE_;
double t1 = Cpu();
// outputScalarField(m.triangles, "0.pos", 1, gf);
// outputScalarField(m.triangles, "0.pos", 1, gf);
splitEdgePass(gf, m, maxE, nb_split, true_boundary);
// outputScalarField(m.triangles, "a.pos", 1, gf);
// outputScalarField(m.triangles, "a.pos", 1, gf);
CHECK_STRANGE("split", m);
double t2 = Cpu();
swapEdgePass(gf, m, nb_swap);
CHECK_STRANGE("swap", m);
// outputScalarField(m.triangles, "b.pos", 1, gf);
// outputScalarField(m.triangles, "b.pos", 1, gf);
double t3 = Cpu();
collapseEdgePass(gf, m, minE, MAXNP, nb_collaps);
CHECK_STRANGE("collapse", m);
// outputScalarField(m.triangles, "c.pos", 1, gf);
// outputScalarField(m.triangles, "c.pos", 1, gf);
double t4 = Cpu();
swapEdgePass(gf, m, nb_swap);
CHECK_STRANGE("swap", m);
......@@ -809,10 +801,10 @@ void refineMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT,
swapEdgePass(gf, m, nb_swap);
CHECK_STRANGE("swap", m);
double t7 = Cpu();
// char name[256]; sprintf(name,"iter%d.pos",IT);
// outputScalarField(m.triangles, name, 1, gf);
// getchar();
// }
// char name[256]; sprintf(name,"iter%d.pos",IT);
// outputScalarField(m.triangles, name, 1, gf);
// getchar();
// clean up the mesh
t_spl += t2 - t1;
t_sw += t3 - t2;
......@@ -821,20 +813,21 @@ void refineMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT,
t_col += t4 - t3;
t_sm += t6 - t5;
m.cleanup();
// char nn[256];
// sprintf(nn,"ITER%d.pos",IT);
// outputScalarField(m.triangles, nn, 1, gf);
// getchar();
// char nn[256];
// sprintf(nn,"ITER%d.pos",IT);
// outputScalarField(m.triangles, nn, 1, gf);
// getchar();
IT++;
Msg::Debug(" iter %3d minL %8.3f/%8.3f maxL %8.3f/%8.3f : "
"%6d splits, %6d swaps, %6d collapses, %6d moves",
IT, minL, minE, maxL, maxE, nb_split, nb_swap, nb_collaps,
nb_smooth);
// getchar();
// getchar();
if(nb_split == 0 && nb_collaps == 0) break;
}
// outputScalarField(m.triangles, "before.pos", 1, gf);
// outputScalarField(m.triangles, "before.pos", 1, gf);
int ITER = 0;
int bad = 0;
......@@ -849,10 +842,10 @@ void refineMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT,
}
double orientation = invalid > (int)m.triangles.size() / 2 ? -1.0 : 1.0;
// printf("NOW FIXING BAD ELEMENTS\n");
// printf("NOW FIXING BAD ELEMENTS\n");
while(1) {
// printf("ITERATION %d\n",ITER);
// printf("ITERATION %d\n",ITER);
bad = 0;
invalid = 0;
for(size_t i = 0; i < m.triangles.size(); i++) {
......@@ -867,8 +860,7 @@ void refineMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT,
for(size_t i = 0; i < m.triangles.size(); i++) {
BDS_Point *pts[4];
m.triangles[i]->getNodes(pts);
// if (pts[0]->degenerated + pts[1]->degenerated +
// pts[2]->degenerated < 2){
// if (pts[0]->degenerated + pts[1]->degenerated + pts[2]->degenerated < 2){
double val = orientation * BDS_Face_Validity(gf, m.triangles[i]);
if(val <= 0.2) {
if(!m.triangles[i]->deleted && val <= 0) invalid++;
......@@ -877,12 +869,11 @@ void refineMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT,
pts[2]->config_modified = true;
bad++;
if(val < 0) {
// printf("%d %d %d
//invalid\n",pts[0]->iD,pts[1]->iD,pts[2]->iD);
// printf("%d %d %d invalid\n",pts[0]->iD,pts[1]->iD,pts[2]->iD);
invalid++;
}
}
// }
// }
}
if(++ITER == 10) {
if(invalid && !computeNodalSizeField)
......@@ -893,13 +884,13 @@ void refineMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT,
if(bad != 0) {
int nb_swap = 0;
//int nb_smooth = 0;
// int nb_smooth = 0;
swapEdgePass(gf, m, nb_swap, 1, orientation);
// smoothVertexPass(gf, m, nb_smooth, true);
// smoothVertexPass(gf, m, nb_smooth, true);
}
else {
// Msg::Info("Meshing surface %d : all elements are oriented
// properly\n", gf->tag());
// Msg::Info("Meshing surface %d : all elements are oriented
// properly\n", gf->tag());
break;
}
}
......@@ -1039,7 +1030,6 @@ void invalidEdgesPeriodic(
}
}
Msg::Debug("%d similar edges should be split", toSplit.size() - aa);
// printf("%d splits\n",toSplit.size());
}
// consider p1 and p2, 2 vertices that are different in the parametric
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment