diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index e70c93f6d2041371cbe1788d65681a405a9d6924..e56a4395276b9ca5a8609d5ddf06f8c7a58b7aef 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -1709,16 +1709,6 @@ int GModel::convertOldPartitioningToNewOne() #endif } -void GModel::store(std::vector<MVertex *> &vertices, int dim, - std::map<int, std::vector<MElement *> > &entityMap, - std::map<int, std::map<int, std::string> > &physicalMap) -{ - _storeVerticesInEntities(vertices); - _storeElementsInEntities(entityMap); - _storePhysicalTagsInEntities(dim, physicalMap); - _associateEntityWithMeshVertices(); -} - void GModel::storeChain(int dim, std::map<int, std::vector<MElement *> > &entityMap, std::map<int, std::map<int, std::string> > &physicalMap) @@ -1987,207 +1977,6 @@ void GModel::_storePhysicalTagsInEntities( } } -static bool getMeshVertices(int num, int *indices, - std::map<int, MVertex *> &map, - std::vector<MVertex *> &vertices) -{ - for(int i = 0; i < num; i++) { - if(!map.count(indices[i])) { - Msg::Error("Wrong vertex index %d", indices[i]); - return false; - } - else - vertices.push_back(map[indices[i]]); - } - return true; -} - -static bool getMeshVertices(int num, int *indices, std::vector<MVertex *> &vec, - std::vector<MVertex *> &vertices, int minVertex = 0) -{ - for(int i = 0; i < num; i++) { - if(indices[i] < minVertex || - indices[i] > (int)(vec.size() - 1 + minVertex)) { - Msg::Error("Wrong vertex index %d", indices[i]); - return false; - } - else - vertices.push_back(vec[indices[i]]); - } - return true; -} - -GModel *GModel::createGModel(std::map<int, MVertex *> &vertexMap, - std::vector<int> &elementNum, - std::vector<std::vector<int> > &vertexIndices, - std::vector<int> &elementType, - std::vector<int> &physical, - std::vector<int> &elementary, - std::vector<int> &partition) -{ - int numVertices = (int)vertexMap.size(); - int numElement = (int)elementNum.size(); - - if(numElement != (int)vertexIndices.size()) { - Msg::Error("Dimension in vertices numbers"); - return 0; - } - if(numElement != (int)elementType.size()) { - Msg::Error("Dimension in elementType numbers"); - return 0; - } - if(numElement != (int)physical.size()) { - Msg::Error("Dimension in physical numbers"); - return 0; - } - if(numElement != (int)elementary.size()) { - Msg::Error("Dimension in elementary numbers"); - return 0; - } - if(numElement != (int)partition.size()) { - Msg::Error("Dimension in partition numbers"); - return 0; - } - - GModel *gm = new GModel(); - std::map<int, std::vector<MElement *> > elements[11]; - std::map<int, std::map<int, std::string> > physicals[4]; - std::vector<MVertex *> vertexVector; - - std::map<int, MVertex *>::const_iterator it = vertexMap.begin(); - std::map<int, MVertex *>::const_iterator end = vertexMap.end(); - - int maxVertex = std::numeric_limits<int>::min(); - int minVertex = std::numeric_limits<int>::max(); - int num; - - for(; it != end; ++it) { - num = it->first; - minVertex = std::min(minVertex, num); - maxVertex = std::max(maxVertex, num); - } - if(minVertex == std::numeric_limits<int>::max()) - Msg::Error("Could not determine the min index of vertices"); - - // if the vertex numbering is dense, transfer the map into a vector to speed - // up element creation - if((minVertex == 1 && maxVertex == numVertices) || - (minVertex == 0 && maxVertex == numVertices - 1)) { - Msg::Info("Vertex numbering is dense"); - vertexVector.resize(vertexMap.size() + 1); - if(minVertex == 1) - vertexVector[0] = 0; - else - vertexVector[numVertices] = 0; - std::map<int, MVertex *>::const_iterator it = vertexMap.begin(); - for(; it != vertexMap.end(); ++it) vertexVector[it->first] = it->second; - vertexMap.clear(); - } - - int *indices; - int nbVertices; - for(int i = 0; i < numElement; ++i) { - num = elementNum[i]; - std::vector<MVertex *> vertices; - nbVertices = (int)vertexIndices[i].size(); - indices = &vertexIndices[i][0]; - if(vertexVector.size()) { - if(!getMeshVertices(nbVertices, indices, vertexVector, vertices)) { - Msg::Error("Vertex not found aborting"); - delete gm; - return 0; - } - } - else { - if(!getMeshVertices(nbVertices, indices, vertexMap, vertices)) { - Msg::Error("Vertex not found aborting"); - delete gm; - return 0; - } - } - - MElementFactory f; - MElement *e = f.create(elementType[i], vertices, num, partition[i]); - if(!e) { - Msg::Error("Unknown type of element %d", elementType[i]); - delete gm; - return 0; - } - switch(e->getType()) { - case TYPE_PNT: elements[0][elementary[i]].push_back(e); break; - case TYPE_LIN: elements[1][elementary[i]].push_back(e); break; - case TYPE_TRI: elements[2][elementary[i]].push_back(e); break; - case TYPE_QUA: elements[3][elementary[i]].push_back(e); break; - case TYPE_TET: elements[4][elementary[i]].push_back(e); break; - case TYPE_HEX: elements[5][elementary[i]].push_back(e); break; - case TYPE_PRI: elements[6][elementary[i]].push_back(e); break; - case TYPE_PYR: elements[7][elementary[i]].push_back(e); break; - case TYPE_TRIH: elements[8][elementary[i]].push_back(e); break; - case TYPE_POLYG: elements[9][elementary[i]].push_back(e); break; - case TYPE_POLYH: elements[10][elementary[i]].push_back(e); break; - default: - Msg::Error("Wrong type of element"); - delete gm; - return 0; - } - int dim = e->getDim(); - if(physical[i] && (!physicals[dim].count(elementary[i]) || - !physicals[dim][elementary[i]].count(physical[i]))) - physicals[dim][elementary[i]][physical[i]] = "unnamed"; - } - - // store the elements in their associated elementary entity. If the - // entity does not exist, create a new (discrete) one. - for(int i = 0; i < (int)(sizeof(elements) / sizeof(elements[0])); i++) - gm->_storeElementsInEntities(elements[i]); - - // associate the correct geometrical entity with each mesh vertex - gm->_associateEntityWithMeshVertices(); - - // store the vertices in their associated geometrical entity - if(vertexVector.size()) - gm->_storeVerticesInEntities(vertexVector); - else - gm->_storeVerticesInEntities(vertexMap); - - // store the physical tags - for(int i = 0; i < 4; i++) gm->_storePhysicalTagsInEntities(i, physicals[i]); - - return gm; -} - -GModel *GModel::createGModel( - std::map<int, std::vector<MElement *> > &entityToElementsMap, - std::map<int, std::vector<int> > &entityToPhysicalsMap) -{ - GModel *gm = new GModel(); - - std::map<int, MVertex *> vertexMap; - std::map<int, std::map<int, std::string> > physicals[4]; - for(std::map<int, std::vector<MElement *> >::iterator it = - entityToElementsMap.begin(); - it != entityToElementsMap.end(); it++) { - int entity = it->first; - for(std::size_t iE = 0; iE < it->second.size(); iE++) { - MElement *me = it->second[iE]; - for(std::size_t iV = 0; iV < me->getNumVertices(); iV++) { - vertexMap[me->getVertex(iV)->getNum()] = me->getVertex(iV); - } - std::vector<int> entityPhysicals = entityToPhysicalsMap[entity]; - for(std::size_t i = 0; i < entityPhysicals.size(); i++) { - physicals[me->getDim()][entity][entityPhysicals[i]] = "unnamed"; - } - } - } - - gm->_storeElementsInEntities(entityToElementsMap); - gm->_associateEntityWithMeshVertices(); - gm->_storeVerticesInEntities(vertexMap); - for(int i = 0; i < 4; i++) gm->_storePhysicalTagsInEntities(i, physicals[i]); - - return gm; -} - void GModel::checkMeshCoherence(double tolerance) { int numEle = getNumMeshElements(); diff --git a/Geo/GModel.h b/Geo/GModel.h index 34bab7103f3941460cae91ab0497f301c5b63c42..2ace7f28fac89bd7977ec13915fedab2541a04c1 100644 --- a/Geo/GModel.h +++ b/Geo/GModel.h @@ -400,11 +400,6 @@ public: // get all tags of elementary entities associated with a given physical group // name std::vector<int> getTagsForPhysicalName(int dim, const std::string &name); - // deprecated - std::vector<int> getEdgesByStringTag(const std::string &name) - { - return getTagsForPhysicalName(1, name); - } // set physical tags to entities in a given bounding box void setPhysicalNumToEntitiesInBox(int EntityDimension, int PhysicalNumber, @@ -578,29 +573,6 @@ public: GModel *buildCutGModel(gLevelset *ls, bool cutElem = true, bool saveTri = false); - // create a GModel by importing a mesh (vertexMap has a dim equal to the - // number of vertices and all the other vectors have a dim equal to the number - // of elements) - static GModel *createGModel(std::map<int, MVertex *> &vertexMap, - std::vector<int> &numElement, - std::vector<std::vector<int> > &vertexIndices, - std::vector<int> &elementType, - std::vector<int> &physical, - std::vector<int> &elementary, - std::vector<int> &partition); - - // create a GModel from newly created mesh elements (with their own newly - // created mesh vertices), and let element entities have given physical group - // tags - static GModel * - createGModel(std::map<int, std::vector<MElement *> > &entityToElementsMap, - std::map<int, std::vector<int> > &entityToPhysicalsMap); - - // for elements cut having new vertices - void store(std::vector<MVertex *> &vertices, int dim, - std::map<int, std::vector<MElement *> > &entityMap, - std::map<int, std::map<int, std::string> > &physicalMap); - // store mesh elements of a chain in a new elementary and physical entity void storeChain(int dim, std::map<int, std::vector<MElement *> > &entityMap, std::map<int, std::map<int, std::string> > &physicalMap);