From 674fe0e368168e0f37f2c9591e6636f9c210560c Mon Sep 17 00:00:00 2001 From: Koen Hillewaert <koen.hillewaert@cenaero.be> Date: Thu, 14 Sep 2017 13:08:50 +0200 Subject: [PATCH] add physical classification, cleaned std::cout messages --- Geo/GModel.cpp | 6 ++++++ Geo/GModelCreateTopologyFromMesh.cpp | 24 ++++++--------------- Geo/GModelIO_CGNS.cpp | 32 ++++++++++++++++++++++++---- 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 743ab8e731..26f053ae17 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -1687,6 +1687,7 @@ void GModel::_storePhysicalTagsInEntities(int dim, case 2: ge = getFaceByTag(it->first); break; case 3: ge = getRegionByTag(it->first); break; } + if(ge){ std::map<int, std::string>::const_iterator it2 = it->second.begin(); for(; it2 != it->second.end(); ++it2){ @@ -1696,6 +1697,11 @@ void GModel::_storePhysicalTagsInEntities(int dim, } } } + + else { + std::cout << "Could not find entity " << std::endl; + } + } } diff --git a/Geo/GModelCreateTopologyFromMesh.cpp b/Geo/GModelCreateTopologyFromMesh.cpp index 63f40a10f7..ab4b0ed643 100644 --- a/Geo/GModelCreateTopologyFromMesh.cpp +++ b/Geo/GModelCreateTopologyFromMesh.cpp @@ -252,21 +252,9 @@ void createTopologyFromMesh1D(GModel *gm, int &num) if (gEdges.size() > 1) { - - if (gEdges.size() > 3) { - std::cout << "Vertex " << mv->getNum() - << " is connected to " << gEdges.size() - << " geometric edges " << std::endl; - } - + if (gEdgesToGVertex.find(gEdges) == gEdgesToGVertex.end()) { num++; - std::cout << "Creating a vertex " << gm->getMaxElementaryNumber(0) + 1 - << " for connection of edges "; - for (std::set<GEdge*>::iterator gg = gEdges.begin();gg!=gEdges.end();++gg) { - std::cout << " " << (*gg)->tag(); - } - std::cout << std::endl; discreteVertex *dv = new discreteVertex(gm, gm->getMaxElementaryNumber(0) + 1); gm->add(dv); @@ -630,10 +618,12 @@ void createTopologyFromMesh3D(GModel *gm, int &num) if (!r1) { const std::set<int>& vtx = it->first.getVertices(); - std::cout << "Could not find pair of regions for face "; - for (std::set<int>::const_iterator vIter=vtx.begin();vIter!=vtx.end();++vIter) { - std::cout << " " << *vIter; - } + std::ostringstream faceVtcs; + std::set<int>::const_iterator vIt=vtx.begin(); + for (;vIt!=vtx.end();++vIt) faceVtcs << " " << *vIt; + Msg::Error("Could not find pair of regions for face %s", + faceVtcs.str().c_str()); + } else if (r1 != r2) { diff --git a/Geo/GModelIO_CGNS.cpp b/Geo/GModelIO_CGNS.cpp index 2c9896754b..1fa7a1efca 100644 --- a/Geo/GModelIO_CGNS.cpp +++ b/Geo/GModelIO_CGNS.cpp @@ -419,7 +419,6 @@ createElementMSH(GModel *m, int num, switch(e->getType()){ case TYPE_PNT : - std::cout << "Adding a point " << std::endl; elements[0][reg].push_back(e); break; case TYPE_LIN : elements[1][reg].push_back(e); break; @@ -1555,6 +1554,11 @@ int GModel::readCGNSUnstructured(const std::string& fileName) std::map<std::string,int> zoneIndices; std::map<std::string,int> zoneOffsets; + // retain boundary conditions + + std::map<int,std::string> bcToName; + std::map<int,std::string> zoneToName; + int classIndex = nbZones + 1; for (int zoneIndex=1;zoneIndex<=nbZones;zoneIndex++) { @@ -1589,6 +1593,7 @@ int GModel::readCGNSUnstructured(const std::string& fileName) return 0; } + zoneToName[zoneIndex] = zoneName; zoneIndices[zoneName] = zoneIndex; zoneOffsets[zoneName] = vtxOffset; @@ -1643,7 +1648,6 @@ int GModel::readCGNSUnstructured(const std::string& fileName) // --- provide a finer classification based on boundary conditions std::map<int,int> eltToBC; - std::map<int,std::string> bcToName; bool topologyDefined = readCGNSBoundaryConditions(fileIndex,baseIndex, zoneIndex,classIndex, @@ -1762,7 +1766,6 @@ int GModel::readCGNSUnstructured(const std::string& fileName) delete [] elts; } - // readCGNSPeriodicConnections(fileIndex,baseIndex,zoneIndex,zoneName,zoneType,periodic); @@ -1782,11 +1785,32 @@ int GModel::readCGNSUnstructured(const std::string& fileName) _associateEntityWithMeshVertices(); _storeVerticesInEntities(vertices); + // add physical entities corresponding to the bc and zones + std::map<int,std::map<int,std::string> > physicalSurfaces; + + std::map<int,std::string>::iterator bIter = bcToName.begin(); + for (;bIter!=bcToName.end();bIter++) { + int tag = bIter->first; + std::string name = bIter->second; + physicalSurfaces[tag][tag] = name; + } - + _storePhysicalTagsInEntities(meshDim-1,physicalSurfaces); + std::map<int,std::map<int,std::string> > physicalZones; + std::map<int,std::string>::iterator zIter = zoneToName.begin(); + for (;zIter!=zoneToName.end();zIter++) { + int tag = zIter->first; + std::string name = zIter->second; + physicalZones[tag][tag] = name; + } + + _storePhysicalTagsInEntities(meshDim,physicalZones); + + //_createGeometryOfDiscreteEntities(); + return 1; } -- GitLab