Commit 45dcca15 authored by Christophe Geuzaine's avatar Christophe Geuzaine

Merge branch 'periodicPartitions' into 'master'

Move the periodic info (correspondingVertices and meshMaster) into the partition entities

See merge request !70
parents 71f1c9d4 3cab7286
Pipeline #1082 passed with stage
in 34 minutes and 31 seconds
......@@ -2457,6 +2457,63 @@ static void BuildTopology(GModel *model)
}
}
void movePeriodicNodesFromParentToPartitionEntities(GModel * const model)
{
std::vector<GEntity*> entities;
model->getEntities(entities);
std::set<GEntity*> emptiedEntities;
for(unsigned int i = 0; i < entities.size(); i++){
if(entities[i]->correspondingVertices.size() != 0){
emptiedEntities.insert(entities[i]);
for(std::map<MVertex*,MVertex*>::iterator it = entities[i]->correspondingVertices.begin(); it != entities[i]->correspondingVertices.end(); ++it){
it->first->onWhat()->correspondingVertices.insert(std::pair<MVertex*,MVertex*>(it->first,it->second));
it->first->onWhat()->setMeshMaster(it->second->onWhat());
}
}
}
for(std::set<GEntity*>::iterator it = emptiedEntities.begin(); it != emptiedEntities.end(); ++it){
(*it)->correspondingVertices.clear();
(*it)->setMeshMaster(*it);
}
}
void movePeriodicNodesFromPartitionToParentEntities(GModel * const model)
{
std::vector<GEntity*> entities;
model->getEntities(entities);
std::set<GEntity*> emptiedEntities;
for(unsigned int i = 0; i < entities.size(); i++){
if(entities[i]->correspondingVertices.size() != 0){
emptiedEntities.insert(entities[i]);
for(std::map<MVertex*,MVertex*>::iterator it = entities[i]->correspondingVertices.begin(); it != entities[i]->correspondingVertices.end(); ++it){
if(entities[i]->geomType() == GEntity::PartitionVertex){
partitionVertex* pv = static_cast<partitionVertex*>(entities[i]);
pv->getParentEntity()->correspondingVertices.insert(std::pair<MVertex*,MVertex*>(it->first,it->second));
static_cast<GEntity*>(pv->getParentEntity())->setMeshMaster(static_cast<partitionVertex*>(it->second->onWhat())->getParentEntity());
}
else if(entities[i]->geomType() == GEntity::PartitionCurve){
partitionEdge* pe = static_cast<partitionEdge*>(entities[i]);
pe->getParentEntity()->correspondingVertices.insert(std::pair<MVertex*,MVertex*>(it->first,it->second));
static_cast<GEntity*>(pe->getParentEntity())->setMeshMaster(static_cast<partitionEdge*>(it->second->onWhat())->getParentEntity());
}
else if(entities[i]->geomType() == GEntity::PartitionSurface){
partitionFace* pf = static_cast<partitionFace*>(entities[i]);
pf->getParentEntity()->correspondingVertices.insert(std::pair<MVertex*,MVertex*>(it->first,it->second));
static_cast<GEntity*>(pf->getParentEntity())->setMeshMaster(static_cast<partitionFace*>(it->second->onWhat())->getParentEntity());
}
else if(entities[i]->geomType() == GEntity::PartitionVolume){
partitionRegion* pr = static_cast<partitionRegion*>(entities[i]);
pr->getParentEntity()->correspondingVertices.insert(std::pair<MVertex*,MVertex*>(it->first,it->second));
static_cast<GEntity*>(pr->getParentEntity())->setMeshMaster(static_cast<partitionRegion*>(it->second->onWhat())->getParentEntity());
}
}
}
}
}
// Partition a mesh into n parts. Returns: 0 = success, 1 = error
int PartitionMesh(GModel *const model)
{
......@@ -2508,6 +2565,8 @@ int PartitionMesh(GModel *const model)
AssignMeshVertices(model);
movePeriodicNodesFromParentToPartitionEntities(model);
graph.clearDualGraph();
createDualGraph(graph, true);
graph.assignGhostCells();
......@@ -2599,6 +2658,8 @@ int UnpartitionMesh(GModel *const model)
std::set<GVertex*, GEntityLessThan> vertices = model->getVertices();
std::set<MVertex*> verts;
movePeriodicNodesFromPartitionToParentEntities(model);
// Loop over vertices
for(GModel::viter it = vertices.begin(); it != vertices.end(); ++it){
......@@ -2795,6 +2856,8 @@ int ConvertOldPartitioningToNewOne(GModel *const model)
AssignMeshVertices(model);
movePeriodicNodesFromParentToPartitionEntities(model);
graph.clearDualGraph();
createDualGraph(graph, false);
graph.assignGhostCells();
......
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