diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 948394586f35e5e9fce5c1f74fc6da73e689bc43..fee9c0864eafe6a11eb755178f4fd2deaf17e351 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -430,7 +430,7 @@ int GModel::getMaxPhysicalNumber(int dim) getEntities(entities); int num = 0; for(unsigned int i = 0; i < entities.size(); i++) - if(entities[i]->dim() == dim) + if(dim < 0 || entities[i]->dim() == dim) for(unsigned int j = 0; j < entities[i]->physicals.size(); j++) num = std::max(num, std::abs(entities[i]->physicals[j])); return num; @@ -839,7 +839,7 @@ MVertex* GModel::getMeshVertexByCoordinates(double x, double y, double z, double entities[i]->mesh_vertices[j]; } } - + for (int i=1; i< _vertexVectorCache.size(); i++){ MVertex* v = _vertexVectorCache[i]; double l = sqrt((v->x() -x)*(v->x()-x)+ (v->y()-y)*(v->y()-y)+ (v->z()-z)*(v->z()-z)); @@ -856,7 +856,7 @@ MVertex* GModel::getMeshVertexByCoordinates(double x, double y, double z, double _vertexVectorCache.push_back(v); _vertexMapCache[v->getNum()] = v; - return v; + return v; }; void GModel::getMeshVerticesForPhysicalGroup(int dim, int num, std::vector<MVertex*> &v) diff --git a/Geo/GModel.h b/Geo/GModel.h index 6b1f52917fd013bed097d85eadc087e702d84cb3..77e53530e3a02795e7df361900da8d98ce9f6c50 100644 --- a/Geo/GModel.h +++ b/Geo/GModel.h @@ -304,7 +304,7 @@ class GModel void deletePhysicalGroup(int dim, int num); // return the highest number associated with a physical entity of a - // given dimension + // given dimension (or highest for all dimenions if dim < 0) int getMaxPhysicalNumber(int dim); // elementary/physical name iterator @@ -371,10 +371,10 @@ class GModel // access a mesh vertex by tag, using the vertex cache MVertex *getMeshVertexByTag(int n); - + // get a mesh vertex by coordinate, using the vertex cache MVertex *getMeshVertexByCoordinates(double x, double y, double z, double tol); - + // get all the mesh vertices associated with the physical group // of dimension "dim" and id number "num" void getMeshVerticesForPhysicalGroup(int dim, int num, std::vector<MVertex*> &); diff --git a/Geo/GModelIO_MED.cpp b/Geo/GModelIO_MED.cpp index 6420c7ea778e62e435c3c033c2efdec1b18e3e9a..959d32982d3eaaa006c86a39f2aeb7407bca32d3 100644 --- a/Geo/GModelIO_MED.cpp +++ b/Geo/GModelIO_MED.cpp @@ -442,7 +442,9 @@ int GModel::readMED(const std::string &name, int meshIndex) char tmp[MED_TAILLE_LNOM + 1]; strncpy(tmp, &groupNames[j * MED_TAILLE_LNOM], MED_TAILLE_LNOM); tmp[MED_TAILLE_LNOM] = '\0'; - int pnum = setPhysicalName(tmp, ge->dim()); + // don't use same physical number across dimensions, as e.g. getdp + // does not support this + int pnum = setPhysicalName(tmp, ge->dim(), getMaxPhysicalNumber(-1) + 1); if(std::find(ge->physicals.begin(), ge->physicals.end(), pnum) == ge->physicals.end()) ge->physicals.push_back(pnum);