Commit 9e399651 authored by Christophe Geuzaine's avatar Christophe Geuzaine

make MSH3 behave as before with partitioned meshes if no physicals are created…

make MSH3 behave as before with partitioned meshes if no physicals are created for partitioned entities

PS: MSH3 is undocumented and will never be. MSH4 is the future :-)
parent e2924059
Pipeline #2080 passed with stage
in 64 minutes and 46 seconds
......@@ -472,7 +472,10 @@ int GModel::_readMSH3(const std::string &name)
static void writeMSHPhysicals(FILE *fp, GEntity *ge)
{
std::vector<int> phys = ge->getPhysicalEntities();
std::vector<int> phys = ge->physicals;
// for compatibility with new partitioner
if(phys.empty() && ge->getParentEntity())
phys = ge->getParentEntity()->physicals;
fprintf(fp, "%d ", (int)phys.size());
for(std::vector<int>::iterator itp = phys.begin(); itp != phys.end(); itp++)
fprintf(fp, "%d ", *itp);
......@@ -541,15 +544,17 @@ void writeMSHEntities(FILE *fp, GModel *gm) // also used in MSH2
static int getNumElementsMSH(GEntity *ge, bool saveAll, int saveSinglePartition)
{
if(!saveAll && ge->physicals.empty()) return 0;
int n = 0;
if(saveSinglePartition <= 0)
n = ge->getNumMeshElements();
else
for(unsigned int i = 0; i < ge->getNumMeshElements(); i++)
if(ge->getMeshElement(i)->getPartition() == saveSinglePartition)
n++;
if(saveAll || ge->physicals.size() ||
// for compatibility with new partitioner
(ge->getParentEntity() && ge->getParentEntity()->physicals.size())){
if(saveSinglePartition <= 0)
n = ge->getNumMeshElements();
else
for(unsigned int i = 0; i < ge->getNumMeshElements(); i++)
if(ge->getMeshElement(i)->getPartition() == saveSinglePartition)
n++;
}
return n;
}
......@@ -574,12 +579,14 @@ template<class T>
static void writeElementsMSH(FILE *fp, GModel *model, GEntity *ge, std::vector<T*> &ele,
bool saveAll, int saveSinglePartition, bool binary)
{
if(!saveAll && ge->physicals.empty()) return;
for(unsigned int i = 0; i < ele.size(); i++){
if(saveSinglePartition && ele[i]->getPartition() != saveSinglePartition)
continue;
writeElementMSH(fp, model, ele[i], binary, ge->tag());
if(saveAll || ge->physicals.size() ||
// for compatibility with new partitioner
(ge->getParentEntity() && ge->getParentEntity()->physicals.size())){
for(unsigned int i = 0; i < ele.size(); i++){
if(saveSinglePartition && ele[i]->getPartition() != saveSinglePartition)
continue;
writeElementMSH(fp, model, ele[i], binary, ge->tag());
}
}
}
......
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