diff --git a/Geo/GEntity.h b/Geo/GEntity.h index c989dd6579669df1f0aa45962a8bb4d738abb114..7d90397f25f10e667415426730ee3c9bf966090f 100644 --- a/Geo/GEntity.h +++ b/Geo/GEntity.h @@ -14,6 +14,8 @@ #include "SBoundingBox3d.h" #include "SOrientedBoundingBox.h" +#define MAX_LC 1.e22 + class GModel; class GVertex; class GEdge; @@ -299,6 +301,9 @@ class GEntity { // reset the mesh attributes to default values virtual void resetMeshAttributes() { return; } + // global mesh size constraint for the entity + virtual double getMeshSize() const { return MAX_LC; } + // number of types of elements virtual int getNumElementTypes() const { return 0; } diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp index e66356eb3f584d49a2d977b07be0b9034dddea21..2b362254c9f4399596ca491ffb8ea66672f55f5f 100644 --- a/Geo/GFace.cpp +++ b/Geo/GFace.cpp @@ -53,7 +53,7 @@ GFace::~GFace() deleteMesh(); } -int GFace::getCurvatureControlParameter () const +int GFace::getCurvatureControlParameter() const { std::map<int,int>::iterator it = CTX::instance()->mesh.curvature_control_per_face.find(tag()); @@ -61,19 +61,19 @@ int GFace::getCurvatureControlParameter () const CTX::instance()->mesh.minCircPoints : it->second ; } -void GFace::setCurvatureControlParameter (int n) +void GFace::setCurvatureControlParameter(int n) { CTX::instance()->mesh.curvature_control_per_face[tag()] = n; } -int GFace::getMeshingAlgo () const +int GFace::getMeshingAlgo() const { std::map<int,int>::iterator it = CTX::instance()->mesh.algo2d_per_face.find(tag()); return it == CTX::instance()->mesh.algo2d_per_face.end() ? CTX::instance()->mesh.algo2d : it->second ; } -void GFace::setMeshingAlgo (int algo) +void GFace::setMeshingAlgo(int algo) { CTX::instance()->mesh.algo2d_per_face[tag()] = algo; } @@ -196,6 +196,7 @@ void GFace::resetMeshAttributes() meshAttributes.transfiniteSmoothing = -1; meshAttributes.extrude = 0; meshAttributes.reverseMesh = false; + meshAttributes.meshSize = MAX_LC; } SBoundingBox3d GFace::bounds() const @@ -1860,13 +1861,13 @@ void GFace::setMeshMaster(GFace* master,const std::map<int,int>& edgeCopies) tfo[2*4+0] = ux*uz*(1.-cos(ANGLE)) - uy * sin(ANGLE); tfo[2*4+1] = uy*uz*(1.-cos(ANGLE)) + ux * sin(ANGLE); tfo[2*4+2] = cos (ANGLE) + uz*uz*(1.-cos(ANGLE)); - + double origin[3] = {LINE.p.x(),LINE.p.y(),LINE.p.z()}; - + for (int i=0;i<3;i++) tfo[i*4+3] = origin[i]; for (int i=0;i<3;i++) for (int j=0;j<3;j++) tfo[i*4+3] -= tfo[i*4+j] * origin[j]; for (int i=0;i<4;i++) tfo[12+i] = 0; - + } else { Msg::Error("Only rotations or translations can currently be computed " diff --git a/Geo/GFace.h b/Geo/GFace.h index 3886c4308e037d8f708aa5b73875a52d0e1df500..93b55f9a2d27cae84b9f3e60d3f8fdbc8e95d129 100644 --- a/Geo/GFace.h +++ b/Geo/GFace.h @@ -285,16 +285,16 @@ class GFace : public GEntity{ std::vector<SVector3> *normals=0); // apply Lloyd's algorithm to the mesh - void lloyd (int nIter, int infNorm = 0); + void lloyd(int nIter, int infNorm = 0); // replace edges (gor gluing) void replaceEdges(std::list<GEdge*> &); // tells if it's a sphere, and if it is, returns parameters - virtual bool isSphere (double &radius, SPoint3 ¢er) const {return false;} + virtual bool isSphere(double &radius, SPoint3 ¢er) const { return false; } // add layers of quads - void addLayersOfQuads (int nLayers, GVertex *start, double hmin, double factor); + void addLayersOfQuads(int nLayers, GVertex *start, double hmin, double factor); struct { // do we recombine the triangles of the mesh? @@ -314,12 +314,15 @@ class GFace : public GEntity{ ExtrudeParams *extrude; // reverse mesh orientation bool reverseMesh; + // global mesh size constraint for the surface + double meshSize; } meshAttributes ; - int getMeshingAlgo () const; - void setMeshingAlgo (int) ; + int getMeshingAlgo() const; + void setMeshingAlgo(int); int getCurvatureControlParameter () const; - void setCurvatureControlParameter (int) ; + void setCurvatureControlParameter(int); + virtual double getMeshSize() const { return meshAttributes.meshSize; } struct { mutable GEntity::MeshGenerationStatus status; diff --git a/Geo/GVertex.h b/Geo/GVertex.h index 0326dd835993589b6a48ac7990b5dc33757ca145..7d2c853024f51335a5d719e480d586bee10024b2 100644 --- a/Geo/GVertex.h +++ b/Geo/GVertex.h @@ -15,8 +15,6 @@ #include "SPoint2.h" #include "SPoint3.h" -#define MAX_LC 1.e22 - class MElement; class MPoint; diff --git a/Mesh/BackgroundMeshTools.cpp b/Mesh/BackgroundMeshTools.cpp index 2c499992d00dd99f43d68e17b175eabccaa1d4f8..4b8ea57804d681d40988aa768556e784a741eca8 100644 --- a/Mesh/BackgroundMeshTools.cpp +++ b/Mesh/BackgroundMeshTools.cpp @@ -273,8 +273,11 @@ double BGM_MeshSize(GEntity *ge, double U, double V, if(f) l4 = (*f)(X, Y, Z, ge); } + // global lc from entity + double l5 = ge->getMeshSize(); + // take the minimum, then constrain by lcMin and lcMax - double lc = std::min(std::min(std::min(l1, l2), l3), l4); + double lc = std::min(std::min(std::min(std::min(l1, l2), l3), l4), l5); lc = std::max(lc, CTX::instance()->mesh.lcMin); lc = std::min(lc, CTX::instance()->mesh.lcMax); @@ -284,12 +287,6 @@ double BGM_MeshSize(GEntity *ge, double U, double V, lc = l1; } - //Msg::Debug("BGM X,Y,Z=%g,%g,%g L4=%g L3=%g L2=%g L1=%g LC=%g LFINAL=%g DIM =%d ", - //X, Y, Z, l4, l3, l2, l1, lc, lc * CTX::instance()->mesh.lcFactor, ge->dim()); - - //Emi fix - //if (lc == l1) lc /= 10.; - return lc * CTX::instance()->mesh.lcFactor; } @@ -304,7 +301,9 @@ SMetric3 BGM_MeshMetric(GEntity *ge, // Element size = min. between default lc and lc from point (if applicable), // constrained by lcMin and lcMax double lc = CTX::instance()->lc; - if(CTX::instance()->mesh.lcFromPoints && ge->dim() < 2) lc = std::min(lc, LC_MVertex_PNTS(ge, U, V)); + if(CTX::instance()->mesh.lcFromPoints && ge->dim() < 2) + lc = std::min(lc, LC_MVertex_PNTS(ge, U, V)); + lc = std::min(lc, ge->getMeshSize()); lc = std::max(lc, CTX::instance()->mesh.lcMin); lc = std::min(lc, CTX::instance()->mesh.lcMax); if(lc <= 0.){