Commit ee83ae71 by Anthony Royer

- Delete Ghostentities during unpartitioning - ghostcells for msh2 and msh3

parent 717aa5f3
Pipeline #1075 passed with stage
in 15 minutes 25 seconds
...@@ -263,7 +263,7 @@ void CreateOutputFile(const std::string &fileName, int format, ...@@ -263,7 +263,7 @@ void CreateOutputFile(const std::string &fileName, int format,
break; break;
case FORMAT_MSH: case FORMAT_MSH:
if(GModel::current()->getMeshPartitions().size() && if(GModel::current()->getNumPartitions() &&
CTX::instance()->mesh.partitionSplitMeshFiles){ CTX::instance()->mesh.partitionSplitMeshFiles){
std::vector<std::string> splitName = SplitFileName(name); std::vector<std::string> splitName = SplitFileName(name);
splitName[0] += splitName[1]; splitName[0] += splitName[1];
...@@ -278,7 +278,7 @@ void CreateOutputFile(const std::string &fileName, int format, ...@@ -278,7 +278,7 @@ void CreateOutputFile(const std::string &fileName, int format,
CTX::instance()->mesh.saveAll, CTX::instance()->mesh.saveParametric, CTX::instance()->mesh.saveAll, CTX::instance()->mesh.saveParametric,
CTX::instance()->mesh.scalingFactor); CTX::instance()->mesh.scalingFactor);
} }
if(GModel::current()->getMeshPartitions().size() && if(GModel::current()->getNumPartitions() &&
CTX::instance()->mesh.partitionSaveTopologyFile){ CTX::instance()->mesh.partitionSaveTopologyFile){
std::vector<std::string> splitName = SplitFileName(name); std::vector<std::string> splitName = SplitFileName(name);
splitName[0] += splitName[1] + "_topology.pro"; splitName[0] += splitName[1] + "_topology.pro";
......
...@@ -85,6 +85,11 @@ class GModel { ...@@ -85,6 +85,11 @@ class GModel {
std::vector<MElement*> _elementVectorCache; std::vector<MElement*> _elementVectorCache;
std::map<int, MElement*> _elementMapCache; std::map<int, MElement*> _elementMapCache;
std::map<int, int> _elementIndexCache; std::map<int, int> _elementIndexCache;
// ghost cell information (stores partitions for each element acting
// as a ghost cell)
// /!\ Use only for compatibility with mesh format msh2 and msh3
std::multimap<MElement*, short> _ghostCells;
// an octree for fast mesh element lookup // an octree for fast mesh element lookup
MElementOctree *_octree; MElementOctree *_octree;
...@@ -461,6 +466,10 @@ class GModel { ...@@ -461,6 +466,10 @@ class GModel {
int convertOldPartitioningToNewOne(); int convertOldPartitioningToNewOne();
// write the partitioned topology file // write the partitioned topology file
int writePartitionedTopology(std::string &name); int writePartitionedTopology(std::string &name);
// /!\ Use only for compatibility with mesh format msh2 and msh3
std::multimap<MElement*, short> &getGhostCells(){ return _ghostCells; }
void addGhostCells(MElement* elm, short partition) { _ghostCells.insert(std::pair<MElement*,short>(elm, partition)); }
// perform various coherence tests on the mesh // perform various coherence tests on the mesh
void checkMeshCoherence(double tolerance); void checkMeshCoherence(double tolerance);
......
...@@ -391,7 +391,7 @@ int GModel::_readMSH2(const std::string &name) ...@@ -391,7 +391,7 @@ int GModel::_readMSH2(const std::string &name)
elemreg[num] = elementary; elemreg[num] = elementary;
elemphy[num] = physical; elemphy[num] = physical;
for(unsigned int j = 0; j < ghosts.size(); j++) for(unsigned int j = 0; j < ghosts.size(); j++)
//_ghostCells.insert(std::pair<MElement*, short>(e, ghosts[j])); _ghostCells.insert(std::pair<MElement*, short>(e, ghosts[j]));
if(numElements > 100000) if(numElements > 100000)
Msg::ProgressMeter(i + 1, numElements, true, "Reading elements"); Msg::ProgressMeter(i + 1, numElements, true, "Reading elements");
} }
...@@ -467,7 +467,7 @@ int GModel::_readMSH2(const std::string &name) ...@@ -467,7 +467,7 @@ int GModel::_readMSH2(const std::string &name)
elemphy[num] = physical; elemphy[num] = physical;
if(numPartitions > 1) if(numPartitions > 1)
for(int j = 0; j < numPartitions - 1; j++) for(int j = 0; j < numPartitions - 1; j++)
//_ghostCells.insert(std::pair<MElement*, short>(e, -data[5 + j])); _ghostCells.insert(std::pair<MElement*, short>(e, -data[5 + j]));
if(numElements > 100000) if(numElements > 100000)
Msg::ProgressMeter(numElementsPartial + i + 1, numElements, true, Msg::ProgressMeter(numElementsPartial + i + 1, numElements, true,
"Reading elements"); "Reading elements");
...@@ -592,14 +592,14 @@ static void writeElementMSH(FILE *fp, GModel *model, T *ele, bool saveAll, ...@@ -592,14 +592,14 @@ static void writeElementMSH(FILE *fp, GModel *model, T *ele, bool saveAll,
int dom1Num = 0, int dom2Num = 0) int dom1Num = 0, int dom2Num = 0)
{ {
std::vector<short> ghosts; std::vector<short> ghosts;
/*if(model->getGhostCells().size()){ if(model->getGhostCells().size()){
std::pair<std::multimap<MElement*, short>::iterator, std::pair<std::multimap<MElement*, short>::iterator,
std::multimap<MElement*, short>::iterator> itp = std::multimap<MElement*, short>::iterator> itp =
model->getGhostCells().equal_range(ele); model->getGhostCells().equal_range(ele);
for(std::multimap<MElement*, short>::iterator it = itp.first; for(std::multimap<MElement*, short>::iterator it = itp.first;
it != itp.second; it++) it != itp.second; it++)
ghosts.push_back(it->second); ghosts.push_back(it->second);
}*/ }
if(saveAll) if(saveAll)
ele->writeMSH2(fp, version, binary, ++num, elementary, 0, ele->writeMSH2(fp, version, binary, ++num, elementary, 0,
......
...@@ -555,7 +555,7 @@ static int getNumElementsMSH(GEntity *ge, bool saveAll, int saveSinglePartition) ...@@ -555,7 +555,7 @@ static int getNumElementsMSH(GEntity *ge, bool saveAll, int saveSinglePartition)
static void writeElementMSH(FILE *fp, GModel *model, MElement *ele, bool binary, static void writeElementMSH(FILE *fp, GModel *model, MElement *ele, bool binary,
int elementary) int elementary)
{ {
/*if(model->getGhostCells().size()){ if(model->getGhostCells().size()){
std::vector<short> ghosts; std::vector<short> ghosts;
std::pair<std::multimap<MElement*, short>::iterator, std::pair<std::multimap<MElement*, short>::iterator,
std::multimap<MElement*, short>::iterator> itp = std::multimap<MElement*, short>::iterator> itp =
...@@ -565,7 +565,7 @@ static void writeElementMSH(FILE *fp, GModel *model, MElement *ele, bool binary, ...@@ -565,7 +565,7 @@ static void writeElementMSH(FILE *fp, GModel *model, MElement *ele, bool binary,
ghosts.push_back(it->second); ghosts.push_back(it->second);
ele->writeMSH(fp, binary, elementary, &ghosts); ele->writeMSH(fp, binary, elementary, &ghosts);
} }
else*/ else
ele->writeMSH(fp, binary, elementary); ele->writeMSH(fp, binary, elementary);
} }
......
...@@ -42,11 +42,13 @@ public: ...@@ -42,11 +42,13 @@ public:
{ {
GEdge::addLine(l); GEdge::addLine(l);
_ghostCells.insert(std::pair<MElement*, unsigned int>(l,onWhichPartition)); _ghostCells.insert(std::pair<MElement*, unsigned int>(l,onWhichPartition));
model()->addGhostCells(l,onWhichPartition);
} }
void addElement(int type, MElement *e, unsigned int onWhichPartition) void addElement(int type, MElement *e, unsigned int onWhichPartition)
{ {
GEdge::addElement(type, e); GEdge::addElement(type, e);
_ghostCells.insert(std::pair<MElement*, unsigned int>(e,onWhichPartition)); _ghostCells.insert(std::pair<MElement*, unsigned int>(e,onWhichPartition));
model()->addGhostCells(e,onWhichPartition);
} }
}; };
......
...@@ -47,21 +47,25 @@ public: ...@@ -47,21 +47,25 @@ public:
{ {
GFace::addTriangle(t); GFace::addTriangle(t);
_ghostCells.insert(std::pair<MElement*, unsigned int>(t,onWhichPartition)); _ghostCells.insert(std::pair<MElement*, unsigned int>(t,onWhichPartition));
model()->addGhostCells(t,onWhichPartition);
} }
void addQuadrangle(MQuadrangle *q, unsigned int onWhichPartition) void addQuadrangle(MQuadrangle *q, unsigned int onWhichPartition)
{ {
GFace::addQuadrangle(q); GFace::addQuadrangle(q);
_ghostCells.insert(std::pair<MElement*, unsigned int>(q,onWhichPartition)); _ghostCells.insert(std::pair<MElement*, unsigned int>(q,onWhichPartition));
model()->addGhostCells(q,onWhichPartition);
} }
void addPolygon(MPolygon *p, unsigned int onWhichPartition) void addPolygon(MPolygon *p, unsigned int onWhichPartition)
{ {
GFace::addPolygon(p); GFace::addPolygon(p);
_ghostCells.insert(std::pair<MElement*, unsigned int>(p,onWhichPartition)); _ghostCells.insert(std::pair<MElement*, unsigned int>(p,onWhichPartition));
model()->addGhostCells(p,onWhichPartition);
} }
void addElement(int type, MElement *e, unsigned int onWhichPartition) void addElement(int type, MElement *e, unsigned int onWhichPartition)
{ {
GFace::addElement(type, e); GFace::addElement(type, e);
_ghostCells.insert(std::pair<MElement*, unsigned int>(e,onWhichPartition)); _ghostCells.insert(std::pair<MElement*, unsigned int>(e,onWhichPartition));
model()->addGhostCells(e,onWhichPartition);
} }
}; };
......
...@@ -53,36 +53,43 @@ public: ...@@ -53,36 +53,43 @@ public:
{ {
GRegion::addTetrahedron(t); GRegion::addTetrahedron(t);
_ghostCells.insert(std::pair<MElement*, unsigned int>(t,onWhichPartition)); _ghostCells.insert(std::pair<MElement*, unsigned int>(t,onWhichPartition));
model()->addGhostCells(t,onWhichPartition);
} }
void addHexahedron(MHexahedron *h, unsigned int onWhichPartition) void addHexahedron(MHexahedron *h, unsigned int onWhichPartition)
{ {
GRegion::addHexahedron(h); GRegion::addHexahedron(h);
_ghostCells.insert(std::pair<MElement*, unsigned int>(h,onWhichPartition)); _ghostCells.insert(std::pair<MElement*, unsigned int>(h,onWhichPartition));
model()->addGhostCells(h,onWhichPartition);
} }
void addPrism(MPrism *p, unsigned int onWhichPartition) void addPrism(MPrism *p, unsigned int onWhichPartition)
{ {
GRegion::addPrism(p); GRegion::addPrism(p);
_ghostCells.insert(std::pair<MElement*, unsigned int>(p,onWhichPartition)); _ghostCells.insert(std::pair<MElement*, unsigned int>(p,onWhichPartition));
model()->addGhostCells(p,onWhichPartition);
} }
void addPyramid(MPyramid *p, unsigned int onWhichPartition) void addPyramid(MPyramid *p, unsigned int onWhichPartition)
{ {
GRegion::addPyramid(p); GRegion::addPyramid(p);
_ghostCells.insert(std::pair<MElement*, unsigned int>(p,onWhichPartition)); _ghostCells.insert(std::pair<MElement*, unsigned int>(p,onWhichPartition));
model()->addGhostCells(p,onWhichPartition);
} }
void addPolyhedron(MPolyhedron *p, unsigned int onWhichPartition) void addPolyhedron(MPolyhedron *p, unsigned int onWhichPartition)
{ {
GRegion::addPolyhedron(p); GRegion::addPolyhedron(p);
_ghostCells.insert(std::pair<MElement*, unsigned int>(p,onWhichPartition)); _ghostCells.insert(std::pair<MElement*, unsigned int>(p,onWhichPartition));
model()->addGhostCells(p,onWhichPartition);
} }
void addTrihedron(MTrihedron *t, unsigned int onWhichPartition) void addTrihedron(MTrihedron *t, unsigned int onWhichPartition)
{ {
GRegion::addTrihedron(t); GRegion::addTrihedron(t);
_ghostCells.insert(std::pair<MElement*, unsigned int>(t,onWhichPartition)); _ghostCells.insert(std::pair<MElement*, unsigned int>(t,onWhichPartition));
model()->addGhostCells(t,onWhichPartition);
} }
void addElement(int type, MElement *e, unsigned int onWhichPartition) void addElement(int type, MElement *e, unsigned int onWhichPartition)
{ {
GRegion::addElement(type, e); GRegion::addElement(type, e);
_ghostCells.insert(std::pair<MElement*, unsigned int>(e,onWhichPartition)); _ghostCells.insert(std::pair<MElement*, unsigned int>(e,onWhichPartition));
model()->addGhostCells(e,onWhichPartition);
} }
}; };
......
...@@ -2627,6 +2627,10 @@ int UnpartitionMesh(GModel *const model) ...@@ -2627,6 +2627,10 @@ int UnpartitionMesh(GModel *const model)
model->remove(pedge); model->remove(pedge);
delete pedge; delete pedge;
} }
else if(edge->geomType() == GEntity::GhostCurve){
model->remove(edge);
delete edge;
}
} }
// Loop over faces // Loop over faces
...@@ -2655,6 +2659,10 @@ int UnpartitionMesh(GModel *const model) ...@@ -2655,6 +2659,10 @@ int UnpartitionMesh(GModel *const model)
model->remove(pface); model->remove(pface);
delete pface; delete pface;
} }
else if(face->geomType() == GEntity::GhostSurface){
model->remove(face);
delete face;
}
} }
// Loop over regions // Loop over regions
...@@ -2698,6 +2706,10 @@ int UnpartitionMesh(GModel *const model) ...@@ -2698,6 +2706,10 @@ int UnpartitionMesh(GModel *const model)
model->remove(pregion); model->remove(pregion);
delete pregion; delete pregion;
} }
else if(region->geomType() == GEntity::GhostVolume){
model->remove(region);
delete region;
}
} }
model->setNumPartitions(0); model->setNumPartitions(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment