Commit ee83ae71 authored by Anthony Royer's avatar Anthony Royer

- Delete Ghostentities during unpartitioning - ghostcells for msh2 and msh3

parent 717aa5f3
Pipeline #1075 passed with stage
in 15 minutes and 25 seconds
......@@ -263,7 +263,7 @@ void CreateOutputFile(const std::string &fileName, int format,
break;
case FORMAT_MSH:
if(GModel::current()->getMeshPartitions().size() &&
if(GModel::current()->getNumPartitions() &&
CTX::instance()->mesh.partitionSplitMeshFiles){
std::vector<std::string> splitName = SplitFileName(name);
splitName[0] += splitName[1];
......@@ -278,7 +278,7 @@ void CreateOutputFile(const std::string &fileName, int format,
CTX::instance()->mesh.saveAll, CTX::instance()->mesh.saveParametric,
CTX::instance()->mesh.scalingFactor);
}
if(GModel::current()->getMeshPartitions().size() &&
if(GModel::current()->getNumPartitions() &&
CTX::instance()->mesh.partitionSaveTopologyFile){
std::vector<std::string> splitName = SplitFileName(name);
splitName[0] += splitName[1] + "_topology.pro";
......
......@@ -85,6 +85,11 @@ class GModel {
std::vector<MElement*> _elementVectorCache;
std::map<int, MElement*> _elementMapCache;
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
MElementOctree *_octree;
......@@ -461,6 +466,10 @@ class GModel {
int convertOldPartitioningToNewOne();
// write the partitioned topology file
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
void checkMeshCoherence(double tolerance);
......
......@@ -391,7 +391,7 @@ int GModel::_readMSH2(const std::string &name)
elemreg[num] = elementary;
elemphy[num] = physical;
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)
Msg::ProgressMeter(i + 1, numElements, true, "Reading elements");
}
......@@ -467,7 +467,7 @@ int GModel::_readMSH2(const std::string &name)
elemphy[num] = physical;
if(numPartitions > 1)
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)
Msg::ProgressMeter(numElementsPartial + i + 1, numElements, true,
"Reading elements");
......@@ -592,14 +592,14 @@ static void writeElementMSH(FILE *fp, GModel *model, T *ele, bool saveAll,
int dom1Num = 0, int dom2Num = 0)
{
std::vector<short> ghosts;
/*if(model->getGhostCells().size()){
if(model->getGhostCells().size()){
std::pair<std::multimap<MElement*, short>::iterator,
std::multimap<MElement*, short>::iterator> itp =
model->getGhostCells().equal_range(ele);
for(std::multimap<MElement*, short>::iterator it = itp.first;
it != itp.second; it++)
ghosts.push_back(it->second);
}*/
}
if(saveAll)
ele->writeMSH2(fp, version, binary, ++num, elementary, 0,
......
......@@ -555,7 +555,7 @@ static int getNumElementsMSH(GEntity *ge, bool saveAll, int saveSinglePartition)
static void writeElementMSH(FILE *fp, GModel *model, MElement *ele, bool binary,
int elementary)
{
/*if(model->getGhostCells().size()){
if(model->getGhostCells().size()){
std::vector<short> ghosts;
std::pair<std::multimap<MElement*, short>::iterator,
std::multimap<MElement*, short>::iterator> itp =
......@@ -565,7 +565,7 @@ static void writeElementMSH(FILE *fp, GModel *model, MElement *ele, bool binary,
ghosts.push_back(it->second);
ele->writeMSH(fp, binary, elementary, &ghosts);
}
else*/
else
ele->writeMSH(fp, binary, elementary);
}
......
......@@ -42,11 +42,13 @@ public:
{
GEdge::addLine(l);
_ghostCells.insert(std::pair<MElement*, unsigned int>(l,onWhichPartition));
model()->addGhostCells(l,onWhichPartition);
}
void addElement(int type, MElement *e, unsigned int onWhichPartition)
{
GEdge::addElement(type, e);
_ghostCells.insert(std::pair<MElement*, unsigned int>(e,onWhichPartition));
model()->addGhostCells(e,onWhichPartition);
}
};
......
......@@ -47,21 +47,25 @@ public:
{
GFace::addTriangle(t);
_ghostCells.insert(std::pair<MElement*, unsigned int>(t,onWhichPartition));
model()->addGhostCells(t,onWhichPartition);
}
void addQuadrangle(MQuadrangle *q, unsigned int onWhichPartition)
{
GFace::addQuadrangle(q);
_ghostCells.insert(std::pair<MElement*, unsigned int>(q,onWhichPartition));
model()->addGhostCells(q,onWhichPartition);
}
void addPolygon(MPolygon *p, unsigned int onWhichPartition)
{
GFace::addPolygon(p);
_ghostCells.insert(std::pair<MElement*, unsigned int>(p,onWhichPartition));
model()->addGhostCells(p,onWhichPartition);
}
void addElement(int type, MElement *e, unsigned int onWhichPartition)
{
GFace::addElement(type, e);
_ghostCells.insert(std::pair<MElement*, unsigned int>(e,onWhichPartition));
model()->addGhostCells(e,onWhichPartition);
}
};
......
......@@ -53,36 +53,43 @@ public:
{
GRegion::addTetrahedron(t);
_ghostCells.insert(std::pair<MElement*, unsigned int>(t,onWhichPartition));
model()->addGhostCells(t,onWhichPartition);
}
void addHexahedron(MHexahedron *h, unsigned int onWhichPartition)
{
GRegion::addHexahedron(h);
_ghostCells.insert(std::pair<MElement*, unsigned int>(h,onWhichPartition));
model()->addGhostCells(h,onWhichPartition);
}
void addPrism(MPrism *p, unsigned int onWhichPartition)
{
GRegion::addPrism(p);
_ghostCells.insert(std::pair<MElement*, unsigned int>(p,onWhichPartition));
model()->addGhostCells(p,onWhichPartition);
}
void addPyramid(MPyramid *p, unsigned int onWhichPartition)
{
GRegion::addPyramid(p);
_ghostCells.insert(std::pair<MElement*, unsigned int>(p,onWhichPartition));
model()->addGhostCells(p,onWhichPartition);
}
void addPolyhedron(MPolyhedron *p, unsigned int onWhichPartition)
{
GRegion::addPolyhedron(p);
_ghostCells.insert(std::pair<MElement*, unsigned int>(p,onWhichPartition));
model()->addGhostCells(p,onWhichPartition);
}
void addTrihedron(MTrihedron *t, unsigned int onWhichPartition)
{
GRegion::addTrihedron(t);
_ghostCells.insert(std::pair<MElement*, unsigned int>(t,onWhichPartition));
model()->addGhostCells(t,onWhichPartition);
}
void addElement(int type, MElement *e, unsigned int onWhichPartition)
{
GRegion::addElement(type, e);
_ghostCells.insert(std::pair<MElement*, unsigned int>(e,onWhichPartition));
model()->addGhostCells(e,onWhichPartition);
}
};
......
......@@ -2627,6 +2627,10 @@ int UnpartitionMesh(GModel *const model)
model->remove(pedge);
delete pedge;
}
else if(edge->geomType() == GEntity::GhostCurve){
model->remove(edge);
delete edge;
}
}
// Loop over faces
......@@ -2655,6 +2659,10 @@ int UnpartitionMesh(GModel *const model)
model->remove(pface);
delete pface;
}
else if(face->geomType() == GEntity::GhostSurface){
model->remove(face);
delete face;
}
}
// Loop over regions
......@@ -2698,6 +2706,10 @@ int UnpartitionMesh(GModel *const model)
model->remove(pregion);
delete pregion;
}
else if(region->geomType() == GEntity::GhostVolume){
model->remove(region);
delete region;
}
}
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