From 883a7a78e3d670a79542dab6fe158b39778c7b13 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Tue, 12 Aug 2008 22:23:46 +0000 Subject: [PATCH] small fixes --- Geo/GEntity.cpp | 15 --------------- Geo/GEntity.h | 6 ------ Geo/GModel.cpp | 41 +++++++++++++++++++++-------------------- Geo/GModelIO_Mesh.cpp | 2 +- 4 files changed, 22 insertions(+), 42 deletions(-) diff --git a/Geo/GEntity.cpp b/Geo/GEntity.cpp index 582bb18b9a..083d6d1afe 100644 --- a/Geo/GEntity.cpp +++ b/Geo/GEntity.cpp @@ -77,18 +77,3 @@ std::string GEntity::getInfoString() return out; } - -void GEntity::recomputeMeshPartitions() -{ - for(unsigned int i = 0; i < getNumMeshElements(); i++) { - int part = getMeshElement(i)->getPartition(); - if(part) model()->getMeshPartitions().insert(part); - } -} - -void GEntity::deleteMeshPartitions() -{ - for(unsigned int i = 0; i < getNumMeshElements(); i++) - getMeshElement(i)->setPartition(0); -} - diff --git a/Geo/GEntity.h b/Geo/GEntity.h index 78634c68b3..5476df2cc7 100644 --- a/Geo/GEntity.h +++ b/Geo/GEntity.h @@ -245,12 +245,6 @@ class GEntity { // get the mesh vertex at the given index MVertex *getMeshVertex(unsigned int index) { return mesh_vertices[index]; } - - // recompute the mesh partitions defined on this entity - void recomputeMeshPartitions(); - - // delete the mesh partitions defined on this entity - void deleteMeshPartitions(); }; class GEntityLessThan { diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index c9965077cd..5ae903f499 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -3,7 +3,7 @@ // See the LICENSE.txt file for license information. Please report all // bugs and problems to <gmsh@geuz.org>. -#include <string.h> +#include <sstream> #include "GModel.h" #include "MElement.h" #include "discreteRegion.h" @@ -463,6 +463,7 @@ MVertex *GModel::getMeshVertexByTag(int n) std::vector<GEntity*> entities; getEntities(entities); if(dense){ + Msg::Debug("Good: we have a dense vertex numbering in the cache"); // numbering starts at 1 _vertexVectorCache.resize(MVertex::getGlobalNumber() + 1); for(unsigned int i = 0; i < entities.size(); i++) @@ -593,8 +594,12 @@ void GModel::recomputeMeshPartitions() meshPartitions.clear(); std::vector<GEntity*> entities; getEntities(entities); - for(unsigned int i = 0; i < entities.size(); i++) - entities[i]->recomputeMeshPartitions(); + for(unsigned int i = 0; i < entities.size(); i++){ + for(unsigned int j = 0; j < entities[i]->getNumMeshElements(); j++){ + int part = entities[i]->getMeshElement(j)->getPartition(); + if(part) meshPartitions.insert(part); + } + } } void GModel::deleteMeshPartitions() @@ -602,7 +607,8 @@ void GModel::deleteMeshPartitions() std::vector<GEntity*> entities; getEntities(entities); for(unsigned int i = 0; i < entities.size(); i++) - entities[i]->deleteMeshPartitions(); + for(unsigned int j = 0; j < entities[i]->getNumMeshElements(); j++) + entities[i]->getMeshElement(j)->setPartition(0); meshPartitions.clear(); } @@ -658,22 +664,17 @@ void GModel::checkMeshCoherence() pos.insert(e); } else{ - char temp[256], temp2[256]; - sprintf(temp, "Element %d ( ", (*it)->getNum()); - for (int k = 0; k < (*it)->getNumVertices(); k++){ - sprintf(temp2, "%d ", (*it)->getVertex(k)->getNum()); - strcat(temp, temp2); - } - sprintf(temp2, ") on entity %d has same barycenter as element %d ( ", - entities[i]->tag(), e->getNum()); - strcat(temp, temp2); - for (int k = 0; k < e->getNumVertices(); k++){ - sprintf(temp2, "%d ", e->getVertex(k)->getNum()); - strcat(temp, temp2); - } - sprintf(temp2, ")"); - strcat(temp, temp2); - Msg::Info("%s", temp); + std::ostringstream sstream; + sstream << "Element " << e->getNum() << " [ "; + for (int k = 0; k < e->getNumVertices(); k++) + sstream << e->getVertex(k)->getNum() << " "; + sstream << "] on entity " << entities[i]->tag() + << " has same barycenter as element " << (*it)->getNum() + << " [ "; + for (int k = 0; k < (*it)->getNumVertices(); k++) + sstream << (*it)->getVertex(k)->getNum() << " "; + sstream << "]"; + Msg::Info("%s", sstream.str().c_str()); num++; } } diff --git a/Geo/GModelIO_Mesh.cpp b/Geo/GModelIO_Mesh.cpp index 8b88b8622d..cb40ae8281 100644 --- a/Geo/GModelIO_Mesh.cpp +++ b/Geo/GModelIO_Mesh.cpp @@ -76,7 +76,7 @@ static bool getVertices(int num, int *indices, std::vector<MVertex*> &vec, static void createElementMSH(GModel *m, int num, int type, int physical, int reg, int part, std::vector<MVertex*> &v, - std::map<int, std::vector<MElement*> > elements[7], + std::map<int, std::vector<MElement*> > elements[8], std::map<int, std::map<int, std::string> > physicals[4]) { MElementFactory factory; -- GitLab