From ec3890db4eb1990a0e672e7c2dfd6bd428c589f1 Mon Sep 17 00:00:00 2001 From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be> Date: Tue, 11 Oct 2016 14:21:28 +0000 Subject: [PATCH] removed call from msh2 --- Geo/GModelCreateTopologyFromMesh.cpp | 39 +++++++++++++++++++++------- Geo/GModelIO_MSH2.cpp | 4 +-- benchmarks/2d/Square-01.geo | 2 ++ 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Geo/GModelCreateTopologyFromMesh.cpp b/Geo/GModelCreateTopologyFromMesh.cpp index 24d2cfbe9d..00061ffc9b 100644 --- a/Geo/GModelCreateTopologyFromMesh.cpp +++ b/Geo/GModelCreateTopologyFromMesh.cpp @@ -147,8 +147,23 @@ void createTopologyFromMesh2D ( GModel *gm ) { for (int i = 0; i < (*it)->lines.size(); i++)_existingEdges[(*it)->lines[i]->getEdge(0)] = *it; } - // printf("%d mesh edges aere already classified\n",_existingEdges.size()); + printf("%d mesh edges are already classified\n",_existingEdges.size()); + std::map<MEdge,int,Less_Edge> _bnd; + for(GModel::fiter it = gm->firstFace(); it != gm->lastFace(); it++) { + for (int i=0;i<(*it)->getNumMeshElements();i++){ + MElement *e = (*it)->getMeshElement(i); + for (int j=0;j<e->getNumEdges();j++){ + MEdge ed = e->getEdge(j); + std::map<MEdge,int,Less_Edge>::iterator it2 = _bnd.find(ed); + if (it2 == _bnd.end())_bnd[ed] = 1; + else it2->second++; + } + } + } + + discreteFace OUT (gm, 1000010200); + // create inverse dictionary for all other edges for(GModel::fiter it = gm->firstFace(); it != gm->lastFace(); it++) { for (int i=0;i<(*it)->getNumMeshElements();i++){ @@ -158,14 +173,18 @@ void createTopologyFromMesh2D ( GModel *gm ) { GEdge *ge = _existingEdges[ed]; if (ge) _topology[*it].insert(ge); - else + else { _temp[ed].insert(*it); + if (_bnd[ed] == 1)_temp[ed].insert(&OUT); + } } } } + printf("%d internal edges\n",_temp.size()); + // create unique instances - for (std::map<MEdge, myBundle<GFace*>, Less_Face >::iterator it = _temp.begin(); it != _temp.end() ; it++){ + for (std::map<MEdge, myBundle<GFace*>, Less_Edge >::iterator it = _temp.begin(); it != _temp.end() ; it++){ _bundles.insert (it->second); } @@ -176,11 +195,11 @@ void createTopologyFromMesh2D ( GModel *gm ) { for (; it != _bundles.end(); ++it) { // it->print(); if (it->stuff.size() > 1){ - printf("creation of a new discrete edge !\n"); + printf("creation of a new discrete edge (%d neighbors)!\n",it->stuff.size()); discreteEdge *de = new discreteEdge ( gm , NEWREG(), NULL, NULL); _f2e [*it] = de; for (std::set<GFace*>::iterator it2 = it->stuff.begin(); it2 != it->stuff.end();++it2) - _topology[*it2].insert(de); + if ((*it2) != &OUT)_topology[*it2].insert(de); } } } @@ -204,10 +223,12 @@ void createTopologyFromMesh2D ( GModel *gm ) { { std::map<GFace*, std::set<GEdge*> >::iterator it = _topology.begin(); for ( ; it != _topology.end() ; ++it){ - std::list<GEdge*> l ; l.insert (l.begin(), it->second.begin(), it->second.end()); - it->first->set(l); - // printf("Face %d has %d edges\n",it->first->tag(), l.size()); - for (std::list<GEdge*>::iterator it2 = l.begin() ; it2 != l.end() ; ++it2)(*it2)->addFace(it->first); + if (it->first){ + std::list<GEdge*> l ; l.insert (l.begin(), it->second.begin(), it->second.end()); + it->first->set(l); + // printf("Face %d has %d edges\n",it->first->tag(), l.size()); + for (std::list<GEdge*>::iterator it2 = l.begin() ; it2 != l.end() ; ++it2)(*it2)->addFace(it->first); + } } } diff --git a/Geo/GModelIO_MSH2.cpp b/Geo/GModelIO_MSH2.cpp index bcfae5b106..2db6802c8a 100644 --- a/Geo/GModelIO_MSH2.cpp +++ b/Geo/GModelIO_MSH2.cpp @@ -689,13 +689,13 @@ int GModel::_readMSH2(const std::string &name) _storeVerticesInEntities(vertexMap); // if no topology is given, create one - createTopologyFromMeshNew (this); + // createTopologyFromMeshNew (this); // store the physical tags for(int i = 0; i < 4; i++) _storePhysicalTagsInEntities(i, physicals[i]); - _createGeometryOfDiscreteEntities() ; + //_createGeometryOfDiscreteEntities() ; // copying periodic information from the mesh diff --git a/benchmarks/2d/Square-01.geo b/benchmarks/2d/Square-01.geo index e4bcca13d8..1b45c5b8be 100644 --- a/benchmarks/2d/Square-01.geo +++ b/benchmarks/2d/Square-01.geo @@ -12,3 +12,5 @@ Line Loop(5) = {1,2,3,4}; Plane Surface(6) = {5}; //Recombine Surface {6}; //Recombine Surface {6}; +//+ +Physical Surface(7) = {6}; -- GitLab