Commit 81ab62dc authored by Christophe Geuzaine's avatar Christophe Geuzaine

pp

parent 45dcca15
Pipeline #1083 passed with stage
in 35 minutes and 5 seconds
This diff is collapsed.
......@@ -2,6 +2,8 @@
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@onelab.info>.
//
// Contributed by Anthony Royer
#ifndef _GHOST_EDGE_H_
#define _GHOST_EDGE_H_
......@@ -11,15 +13,15 @@
#include "MLine.h"
class ghostEdge : public discreteEdge {
private:
private:
unsigned int _partitions;
std::map<MElement*, unsigned int> _ghostCells;
bool _saveMesh;
bool _haveMesh;
public:
public:
ghostEdge(GModel *model, const int num, const unsigned int partitions)
: discreteEdge(model, num, NULL, NULL), _partitions(partitions), _ghostCells(), _saveMesh(false),
_haveMesh(false) {}
: discreteEdge(model, num, NULL, NULL), _partitions(partitions),
_ghostCells(), _saveMesh(false), _haveMesh(false) {}
virtual ~ghostEdge()
{
if(!_haveMesh){
......@@ -30,14 +32,11 @@ public:
virtual GeomType geomType() const { return GhostCurve; }
virtual void setPartition(const unsigned int partitions) { _partitions = partitions; }
virtual unsigned int getPartition() const { return _partitions; }
bool saveMesh() const { return _saveMesh; }
void saveMesh(bool saveMesh) { _saveMesh = saveMesh; }
bool haveMesh() const { return _haveMesh; }
void haveMesh(bool haveMesh) { _haveMesh = haveMesh; }
virtual std::map<MElement*, unsigned int> &getGhostCells() { return _ghostCells; }
void addLine(MLine *l, unsigned int onWhichPartition)
{
GEdge::addLine(l);
......
......@@ -2,6 +2,8 @@
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@onelab.info>.
//
// Contributed by Anthony Royer
#ifndef _GHOST_FACE_H_
#define _GHOST_FACE_H_
......@@ -13,15 +15,15 @@
#include "MElementCut.h"
class ghostFace : public discreteFace {
private:
private:
unsigned int _partitions;
std::map<MElement*, unsigned int> _ghostCells;
bool _saveMesh;
bool _haveMesh;
public:
public:
ghostFace(GModel *model, const int num, const unsigned int partitions)
: discreteFace(model, num), _partitions(partitions), _ghostCells(), _saveMesh(false),
_haveMesh(false) {}
: discreteFace(model, num), _partitions(partitions), _ghostCells(),
_saveMesh(false), _haveMesh(false) {}
virtual ~ghostFace()
{
if(!_haveMesh){
......@@ -31,18 +33,14 @@ public:
mesh_vertices.clear();
}
}
virtual GeomType geomType() const { return GhostSurface; }
virtual void setPartition(const unsigned int partitions) { _partitions = partitions; }
virtual unsigned int getPartition() const { return _partitions; }
bool saveMesh() const { return _saveMesh; }
void saveMesh(bool saveMesh) { _saveMesh = saveMesh; }
bool haveMesh() const { return _haveMesh; }
void haveMesh(bool haveMesh) { _haveMesh = haveMesh; }
virtual std::map<MElement*, unsigned int> &getGhostCells() { return _ghostCells; }
void addTriangle(MTriangle *t, unsigned int onWhichPartition)
{
GFace::addTriangle(t);
......
......@@ -16,15 +16,15 @@
#include "MElementCut.h"
class ghostRegion : public discreteRegion {
private:
private:
unsigned int _partitions;
std::map<MElement*, unsigned int> _ghostCells;
bool _saveMesh;
bool _haveMesh;
public:
public:
ghostRegion(GModel *model, const int num, const unsigned int partitions)
: discreteRegion(model, num), _partitions(partitions), _ghostCells(), _saveMesh(false),
_haveMesh(false) {}
: discreteRegion(model, num), _partitions(partitions), _ghostCells(),
_saveMesh(false), _haveMesh(false) {}
virtual ~ghostRegion()
{
if(!_haveMesh){
......@@ -37,18 +37,14 @@ public:
mesh_vertices.clear();
}
}
virtual GeomType geomType() const { return GhostVolume; }
virtual void setPartition(const unsigned int partitions) { _partitions = partitions; }
virtual unsigned int getPartition() const { return _partitions; }
bool saveMesh() const { return _saveMesh; }
void saveMesh(bool saveMesh) { _saveMesh = saveMesh; }
bool haveMesh() const { return _haveMesh; }
void haveMesh(bool haveMesh) { _haveMesh = haveMesh; }
virtual std::map<MElement*, unsigned int> &getGhostCells() { return _ghostCells; }
void addTetrahedron(MTetrahedron *t, unsigned int onWhichPartition)
{
GRegion::addTetrahedron(t);
......
......@@ -235,7 +235,7 @@ class Graph
_adjncy = 0;
}
}
std::vector< std::set<MElement*> > getBoundaryElements()
{
std::vector< std::set<MElement*> > elements(_nparts, std::set<MElement*>());
......@@ -251,7 +251,7 @@ class Graph
return elements;
}
void assignGhostCells()
{
std::vector<GEntity*> ghostEntities(_nparts, NULL);
......@@ -273,7 +273,7 @@ class Graph
break;
}
}
for(unsigned int i = 0; i < _ne; i++){
std::set<short> ghostCellsPartition;
for(unsigned int j = _xadj[i]; j < _xadj[i+1]; j++){
......@@ -534,7 +534,8 @@ static void createDualGraph(Graph &graph, bool connectedAll)
unsigned int nbrsNeighbors = 0;
for(unsigned int j = 0; j < l; j++){
if(marker[nbrs[j]] >=
(connectedAll ? 1 : graph.element(i)->numCommonNodesInDualGraph(graph.element(nbrs[j]))))
(connectedAll ? 1 :
graph.element(i)->numCommonNodesInDualGraph(graph.element(nbrs[j]))))
nbrsNeighbors++;
marker[nbrs[j]] = 0;
nbrs[j] = 0;
......@@ -561,7 +562,8 @@ static void createDualGraph(Graph &graph, bool connectedAll)
for(unsigned int j = 0; j < l; j++){
if(marker[nbrs[j]] >=
(connectedAll ? 1 : graph.element(i)->numCommonNodesInDualGraph(graph.element(nbrs[j])))){
(connectedAll ? 1 :
graph.element(i)->numCommonNodesInDualGraph(graph.element(nbrs[j])))){
graph.adjncy(graph.xadj(i), nbrs[j]);
graph.xadj(i, graph.xadj(i)+1);
}
......@@ -1704,10 +1706,12 @@ static void CreatePartitionBoundaries(GModel *const model,
Msg::Info(" - Creating partition faces");
for(unsigned int i = 0; i < boundaryElements.size(); i++){
for(std::set<MElement*>::iterator it = boundaryElements[i].begin(); it != boundaryElements[i].end(); ++it){
for(std::set<MElement*>::iterator it = boundaryElements[i].begin();
it != boundaryElements[i].end(); ++it){
for(int j = 0; j < (*it)->getNumFaces(); j++){
faceToElement[(*it)->getFace(j)].push_back
(std::pair<MElement*, std::vector<unsigned int> >(*it, std::vector<unsigned int>(1,i)));
(std::pair<MElement*, std::vector<unsigned int> >
(*it, std::vector<unsigned int>(1,i)));
}
}
}
......@@ -2462,18 +2466,22 @@ 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));
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){
for(std::set<GEntity*>::iterator it = emptiedEntities.begin();
it != emptiedEntities.end(); ++it){
(*it)->correspondingVertices.clear();
(*it)->setMeshMaster(*it);
}
......@@ -2484,30 +2492,40 @@ 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){
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());
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());
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());
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());
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());
}
}
}
......@@ -2547,7 +2565,7 @@ int PartitionMesh(GModel *const model)
std::vector< std::set<MElement*> > boundaryElements = graph.getBoundaryElements();
model->setNumPartitions(graph.nparts());
CreateNewEntities(model, elmToPartition);
elmToPartition.clear();
......@@ -2564,7 +2582,7 @@ int PartitionMesh(GModel *const model)
}
AssignMeshVertices(model);
movePeriodicNodesFromParentToPartitionEntities(model);
graph.clearDualGraph();
......@@ -2658,7 +2676,7 @@ int UnpartitionMesh(GModel *const model)
std::set<GVertex*, GEntityLessThan> vertices = model->getVertices();
std::set<MVertex*> verts;
movePeriodicNodesFromPartitionToParentEntities(model);
// Loop over vertices
......@@ -2855,13 +2873,13 @@ int ConvertOldPartitioningToNewOne(GModel *const model)
}
AssignMeshVertices(model);
movePeriodicNodesFromParentToPartitionEntities(model);
graph.clearDualGraph();
createDualGraph(graph, false);
graph.assignGhostCells();
return 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