diff --git a/Common/Octree.cpp b/Common/Octree.cpp index 055a8ccb346a2d54e618f005731809c7f7dd70fa..4bcdc092ef8e7c71938e607d9e25f7b6903cd668 100644 --- a/Common/Octree.cpp +++ b/Common/Octree.cpp @@ -14,8 +14,8 @@ Octree* Octree_Create(int maxElements, double origin[3], double size[3], int (*InEle)(void *, double *)) { Octree *myOctree = new Octree; - initializeOctantBuckets (origin, size, maxElements, - &(myOctree->root), &(myOctree->info)); + initializeOctantBuckets(origin, size, maxElements, + &(myOctree->root), &(myOctree->info)); myOctree->function_BB = BB; myOctree->function_centroid = Centroid; myOctree->function_inElement = InEle; @@ -53,7 +53,7 @@ void Octree_Delete(Octree *myOctree) delete myOctree; } -void Octree_Insert(void * element, Octree *myOctree) +void Octree_Insert(void *element, Octree *myOctree) { if(!myOctree) return; double minBB[3], maxBB[3], centroid[3]; @@ -61,8 +61,9 @@ void Octree_Insert(void * element, Octree *myOctree) (*(myOctree->function_BB))(element, minBB, maxBB); (*(myOctree->function_centroid))(element, centroid); bucket = findElementBucket(myOctree->root, centroid); - addElement2Bucket(bucket, element, minBB, maxBB, - centroid, myOctree->info); + if(bucket) + addElement2Bucket(bucket, element, minBB, maxBB, + centroid, myOctree->info); } void Octree_Arrange(Octree *myOctree) diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp index ec953370ddfbe53a44266035258c38de870e5d4d..760ae369a7be46fc1f732d91a5ea8679e24ceac1 100644 --- a/Geo/GFace.cpp +++ b/Geo/GFace.cpp @@ -16,6 +16,7 @@ #include "fullMatrix.h" #include "Numeric.h" #include "GaussLegendre1D.h" +#include "ExtrudeParams.h" #include "Context.h" #include "meshGFaceLloyd.h" #include "Bindings.h" @@ -137,6 +138,13 @@ void GFace::resetMeshAttributes() meshAttributes.extrude = 0; } +bool GFace::isMeshExtruded() +{ + ExtrudeParams *ep = meshAttributes.extrude; + if(ep && ep->mesh.ExtrudeMesh) return true; + return false; +} + SBoundingBox3d GFace::bounds() const { SBoundingBox3d res; diff --git a/Geo/GFace.h b/Geo/GFace.h index 00aee5a100a99577dff8b6b3ceae1d0dc568a4bf..f9f3fef914ff7202c4ad3d39990bc6902396ebfa 100644 --- a/Geo/GFace.h +++ b/Geo/GFace.h @@ -235,6 +235,9 @@ class GFace : public GEntity // reset the mesh attributes to default values virtual void resetMeshAttributes(); + // tells if the mesh is obtained by extrusion + bool isMeshExtruded(); + // for periodic faces, move parameters into the range chosen // for that face void moveToValidRange(SPoint2 &pt) const; diff --git a/Geo/MVertexOctree.cpp b/Geo/MVertexOctree.cpp index 0dedfcd98f30af6883ecb9e134fce36901f77a76..9dcc936a8103e6ee8ac0b0f97463c8e8c559c913 100644 --- a/Geo/MVertexOctree.cpp +++ b/Geo/MVertexOctree.cpp @@ -9,10 +9,12 @@ #include "MVertexOctree.h" #include "SBoundingBox3d.h" +double MVertexOctree::tolerance = 1.e-6; + static void MVertexBB(void *a, double *min, double *max) { MVertex *v = (MVertex*)a; - double tol = MVertexLessThanLexicographic::tolerance; + double tol = MVertexOctree::tolerance; min[0] = v->x() - tol; max[0] = v->x() + tol; min[1] = v->y() - tol; @@ -35,12 +37,14 @@ static int MVertexInEle(void *a, double *x) double d = sqrt((x[0] - v->x()) * (x[0] - v->x()) + (x[1] - v->y()) * (x[1] - v->y()) + (x[2] - v->z()) * (x[2] - v->z())); - return (d < MVertexLessThanLexicographic::tolerance); + return (d < MVertexOctree::tolerance); } -MVertexOctree::MVertexOctree(GModel *m) +MVertexOctree::MVertexOctree(GModel *m, double tol) { + tolerance = tol; SBoundingBox3d bb = m->bounds(); + bb *= 1.2; double min[3] = {bb.min().x(), bb.min().y(), bb.min().z()}; double size[3] = {bb.max().x() - bb.min().x(), bb.max().y() - bb.min().y(), diff --git a/Geo/MVertexOctree.h b/Geo/MVertexOctree.h index e94e5b9104a35ac0a289b64e26f1380ce5556360..eb4b5d53c067285f734cc47113fe0c2dbf182a40 100644 --- a/Geo/MVertexOctree.h +++ b/Geo/MVertexOctree.h @@ -9,7 +9,9 @@ class MVertexOctree{ private: Octree *_octree; public: - MVertexOctree(GModel *); + static double tolerance; + public: + MVertexOctree(GModel *, double); ~MVertexOctree(); void insert(MVertex *); void finalize(); diff --git a/Mesh/Generator.cpp b/Mesh/Generator.cpp index e8fd0434382494c133d929ccde54ebf3ae6859fb..6ab042e0eb6cd064d23aeda0d2f2a4b674e64053 100644 --- a/Mesh/Generator.cpp +++ b/Mesh/Generator.cpp @@ -439,14 +439,18 @@ static void Mesh2D(GModel *m) // field generated from the surface mesh of the source surfaces if(!Mesh2DWithBoundaryLayers(m)){ - std::set<GFace*> faces, compoundFaces; + std::set<GFace*> compoundFaces, extrudedFaces, otherFaces; for(GModel::fiter it = m->firstFace(); it != m->lastFace(); ++it){ - if ((*it)->geomType() == GEntity::CompoundSurface) + GFace *gf = *it; + if (gf->geomType() == GEntity::CompoundSurface) compoundFaces.insert(*it); + else if(gf->isMeshExtruded()) + extrudedFaces.insert(gf); else - faces.insert(*it); + otherFaces.insert(gf); } - std::for_each(faces.begin(), faces.end(), meshGFace()); + std::for_each(otherFaces.begin(), otherFaces.end(), meshGFace()); + std::for_each(extrudedFaces.begin(), extrudedFaces.end(), meshGFace()); std::for_each(compoundFaces.begin(), compoundFaces.end(), meshGFace()); // lloyd optimization diff --git a/Mesh/meshGRegion.cpp b/Mesh/meshGRegion.cpp index 689d63208c76feba2435a64f98123e84eff5f994..008eb286dfc56b8654f0b8a5910490b5463cecd2 100644 --- a/Mesh/meshGRegion.cpp +++ b/Mesh/meshGRegion.cpp @@ -583,7 +583,6 @@ void meshGRegion::operator() (GRegion *gr) if(CTX::instance()->mesh.meshOnlyVisible && !gr->getVisibility()) return; ExtrudeParams *ep = gr->meshAttributes.extrude; - if(ep && ep->mesh.ExtrudeMesh) return; // destroy the mesh if it exists diff --git a/benchmarks/extrude/t1_boundary_layer_connection.geo b/benchmarks/extrude/t1_boundary_layer_connection.geo index 41a3643f92e50b74fb9a51b0b503b14dcd02028c..21f04bb8da472cbebccb6e83fa9af177b18e5f37 100644 --- a/benchmarks/extrude/t1_boundary_layer_connection.geo +++ b/benchmarks/extrude/t1_boundary_layer_connection.geo @@ -16,9 +16,10 @@ Extrude { Surface{6}; Layers{5, 0.01}; Recombine; } Point(100) = {0, 0, 0.15, lc} ; Point(101) = {.1, 0, 0.15, lc} ; - +/* Line(100) = {8, 100}; Line(101) = {12, 101}; Line(102) = {100, 101}; Line Loop(100) = {9,101,-102,-100}; Plane Surface(100) = 100; +*/