From a34aa3acf76d6b1155983b922ab3f2c72ddb0fa8 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Wed, 25 Aug 2010 10:20:17 +0000 Subject: [PATCH] cleanup logic for extrusions using PENDING attrib + fix bug in 1D/2D extrusions where we could try to copy a mesh before generating the source mesh --- Geo/GFace.cpp | 8 ----- Geo/GFace.h | 3 -- Mesh/Generator.cpp | 63 ++++++++++++++++++------------------ Mesh/meshGEdge.cpp | 1 + Mesh/meshGEdgeExtruded.cpp | 10 +++++- Mesh/meshGFace.cpp | 2 +- Mesh/meshGFaceExtruded.cpp | 4 +++ Mesh/meshGRegionExtruded.cpp | 23 ------------- 8 files changed, 46 insertions(+), 68 deletions(-) diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp index 3f2c4e2fe0..6600a4bb67 100644 --- a/Geo/GFace.cpp +++ b/Geo/GFace.cpp @@ -16,7 +16,6 @@ #include "fullMatrix.h" #include "Numeric.h" #include "GaussLegendre1D.h" -#include "ExtrudeParams.h" #include "Context.h" #include "meshGFaceLloyd.h" #include "Bindings.h" @@ -138,13 +137,6 @@ 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 f9f3fef914..00aee5a100 100644 --- a/Geo/GFace.h +++ b/Geo/GFace.h @@ -235,9 +235,6 @@ 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/Mesh/Generator.cpp b/Mesh/Generator.cpp index 6ab042e0eb..316cd00603 100644 --- a/Mesh/Generator.cpp +++ b/Mesh/Generator.cpp @@ -438,42 +438,25 @@ static void Mesh2D(GModel *m) // and curve meshes) is global as it depends on a smooth normal // field generated from the surface mesh of the source surfaces if(!Mesh2DWithBoundaryLayers(m)){ - - std::set<GFace*> compoundFaces, extrudedFaces, otherFaces; - for(GModel::fiter it = m->firstFace(); it != m->lastFace(); ++it){ - GFace *gf = *it; - if (gf->geomType() == GEntity::CompoundSurface) - compoundFaces.insert(*it); - else if(gf->isMeshExtruded()) - extrudedFaces.insert(gf); - else - otherFaces.insert(gf); - } - 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 - if (CTX::instance()->mesh.optimizeLloyd){ - for(GModel::fiter it = m->firstFace(); it != m->lastFace(); ++it){ - GFace *gf = *it; - if(gf->geomType() == GEntity::DiscreteSurface) continue; - if(gf->geomType() == GEntity::CompoundSurface) { - GFaceCompound *gfc = (GFaceCompound*) gf; - if(gfc->getNbSplit() != 0) continue; - } - int recombine = gf->meshAttributes.recombine; - Msg::StatusBar(2, true, "Lloyd optimization for face %d", gf->tag()); - gf->lloyd(25, recombine); - if(recombine) recombineIntoQuads(gf); - } - } + std::set<GFace*> cf, f; + for(GModel::fiter it = m->firstFace(); it != m->lastFace(); ++it) + if ((*it)->geomType() == GEntity::CompoundSurface) + cf.insert(*it); + else + f.insert(*it); + int nIter = 0; while(1){ meshGFace mesher; int nbPending = 0; - for(GModel::fiter it = m->firstFace(); it != m->lastFace(); ++it){ + for(GModel::fiter it = f.begin(); it != f.end(); ++it){ + if ((*it)->meshStatistics.status == GFace::PENDING){ + mesher(*it); + nbPending++; + } + } + for(GModel::fiter it = cf.begin(); it != cf.end(); ++it){ if ((*it)->meshStatistics.status == GFace::PENDING){ mesher(*it); nbPending++; @@ -483,7 +466,23 @@ static void Mesh2D(GModel *m) if(nIter++ > 10) break; } } - + + // lloyd optimization + if (CTX::instance()->mesh.optimizeLloyd){ + for(GModel::fiter it = m->firstFace(); it != m->lastFace(); ++it){ + GFace *gf = *it; + if(gf->geomType() == GEntity::DiscreteSurface) continue; + if(gf->geomType() == GEntity::CompoundSurface) { + GFaceCompound *gfc = (GFaceCompound*) gf; + if(gfc->getNbSplit() != 0) continue; + } + int recombine = gf->meshAttributes.recombine; + Msg::StatusBar(2, true, "Lloyd optimization for face %d", gf->tag()); + gf->lloyd(25, recombine); + if(recombine) recombineIntoQuads(gf); + } + } + // collapseSmallEdges(*m); double t2 = Cpu(); diff --git a/Mesh/meshGEdge.cpp b/Mesh/meshGEdge.cpp index ecb0ae8336..34601dc6e6 100644 --- a/Mesh/meshGEdge.cpp +++ b/Mesh/meshGEdge.cpp @@ -451,5 +451,6 @@ void meshGEdge::operator() (GEdge *ge) v0->y() = beg_p.y(); v0->z() = beg_p.z(); } + ge->meshStatistics.status = GEdge::DONE; } diff --git a/Mesh/meshGEdgeExtruded.cpp b/Mesh/meshGEdgeExtruded.cpp index c06de9aaf2..b2e6b59abf 100644 --- a/Mesh/meshGEdgeExtruded.cpp +++ b/Mesh/meshGEdgeExtruded.cpp @@ -54,6 +54,8 @@ int MeshExtrudedCurve(GEdge *ge) if(!ep || !ep->mesh.ExtrudeMesh) return 0; + Msg::StatusBar(2, true, "Meshing curve %d (extruded)", ge->tag()); + GEdge *from = ge->model()->getEdgeByTag(std::abs(ep->geo.Source)); if(ep->geo.Mode == EXTRUDED_ENTITY) { // curve is extruded from a point @@ -65,6 +67,10 @@ int MeshExtrudedCurve(GEdge *ge) Msg::Error("Unknown source curve %d for extrusion", ep->geo.Source); return 0; } + else if(from->meshStatistics.status != GEdge::DONE){ + // cannot mesh this edge yet: will do it later + return 1; + } copyMesh(from, ge); } @@ -80,8 +86,10 @@ int MeshExtrudedCurve(GEdge *ge) // Extrusion information is only stored for copied edges // (the source of extruded edge is a vertex, not an element) MElement* sourceElem = from->getMeshElement(i); - ep->elementMap.addExtrudedElem(sourceElem,newElem); + ep->elementMap.addExtrudedElem(sourceElem, newElem); } } + + ge->meshStatistics.status = GEdge::DONE; return 1; } diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index c656a985b4..d43aa11379 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -1671,7 +1671,7 @@ void partitionAndRemesh(GFaceCompound *gf) GFaceCompound *gfc = new GFaceCompound(gf->model(), num_gfc, f_compound, b[0], b[1], b[2], b[3], 0, gf->getTypeOfMapping()); - gfc->meshAttributes.recombine = gf->meshAttributes.recombine; + gfc->meshAttributes.recombine = gf->meshAttributes.recombine; gf->model()->add(gfc); gfc->parametrize(); diff --git a/Mesh/meshGFaceExtruded.cpp b/Mesh/meshGFaceExtruded.cpp index 00c8761086..9d22d9f7c9 100644 --- a/Mesh/meshGFaceExtruded.cpp +++ b/Mesh/meshGFaceExtruded.cpp @@ -231,6 +231,10 @@ int MeshExtrudedSurface(GFace *gf, Msg::Error("Unknown source surface %d for extrusion", ep->geo.Source); return 0; } + else if(from->meshStatistics.status != GFace::DONE){ + // cannot mesh this face yet: will do it later + return 1; + } copyMesh(from, gf, pos); } diff --git a/Mesh/meshGRegionExtruded.cpp b/Mesh/meshGRegionExtruded.cpp index f4d658099d..50c76ae6dc 100644 --- a/Mesh/meshGRegionExtruded.cpp +++ b/Mesh/meshGRegionExtruded.cpp @@ -523,29 +523,6 @@ int SubdivideExtrudedMesh(GModel *m) } } -// std::set<GFace*> faces; -// for(unsigned int i = 0; i < regions.size(); i++){ -// std::list<GFace*> f = regions[i]->faces(); -// faces.insert(f.begin(), f.end()); -// } -// for(std::set<GFace*>::iterator it = faces.begin(); it != faces.end(); it++){ -// ExtrudeParams *ep = (*it)->meshAttributes.extrude; -// if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY && -// !ep->mesh.Recombine){ -// GFace *gf = *it; -// Msg::Info("Remeshing surface %d", gf->tag()); -// for(unsigned int i = 0; i < gf->triangles.size(); i++) -// delete gf->triangles[i]; -// gf->triangles.clear(); -// for(unsigned int i = 0; i < gf->quadrangles.size(); i++) -// delete gf->quadrangles[i]; -// gf->quadrangles.clear(); -// ep->elementMap.clear(); // reconstruct extrusion info -// MeshExtrudedSurface(gf, &edges); -// } -// } - - // carve holes if any // TODO: update extrusion information for(unsigned int i = 0; i < regions.size(); i++){ -- GitLab