Commit 157f78df authored by Anthony Royer's avatar Anthony Royer

Merge branch 'master' into simplePartition

parents 18f67fee ceb1fb9d
Pipeline #1087 passed with stage
in 23 minutes and 51 seconds
......@@ -84,6 +84,7 @@ std::vector<std::pair<std::string, std::string> > GetUsage()
"Weight of a triangle/quad/etc. during partitioning"));
s.push_back(mp("-part_split", "Save mesh partitions in separate files"));
s.push_back(mp("-part_[no_]topo", "Create the partition topology"));
s.push_back(mp("-part_[no_]ghosts", "Create ghost cells"));
s.push_back(mp("-part_topo_pro", "Save the partition topology .pro file"));
s.push_back(mp("-save_all", "Save all elements (discard physical group definitions)"));
s.push_back(mp("-save_parametric", "Save vertices with their parametric coordinates"));
......@@ -468,6 +469,14 @@ void GetOptions(int argc, char *argv[], bool readConfigFiles)
opt_mesh_partition_create_topology(0, GMSH_SET, 0.);
i++;
}
else if(!strcmp(argv[i] + 1, "part_ghosts")){
opt_mesh_partition_create_ghost_cells(0, GMSH_SET, 1.);
i++;
}
else if(!strcmp(argv[i] + 1, "part_no_ghosts")){
opt_mesh_partition_create_ghost_cells(0, GMSH_SET, 0.);
i++;
}
else if(!strcmp(argv[i] + 1, "new")) {
CTX::instance()->files.push_back("-new");
i++;
......
......@@ -1109,7 +1109,7 @@ StringXNumber MeshOptions_Number[] = {
{ F|O, "PartitionTopology" , opt_mesh_partition_create_topology , 1 ,
"Create boundary entities between partitions" },
{ F|O, "PartitionGhostCells" , opt_mesh_partition_create_ghost_cells , 0 ,
"Create boundary entities between partitions" },
"Create partition ghost cells" },
{ F|O, "PartitionSplitMeshFiles" , opt_mesh_partition_split_mesh_files , 0 ,
"Write one file for each mesh partition" },
{ F|O, "PartitionTopologyFile" , opt_mesh_partition_save_topology_file , 0 ,
......
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,12 @@ 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; }
// To make the hidden function visible in ghostEdge
using GEdge::addLine;
using GEdge::addElement;
......
......@@ -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,23 +33,20 @@ 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; }
// To make the hidden function visible in ghostFace
using GFace::addTriangle;
using GFace::addQuadrangle;
using GFace::addElement;
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,16 +37,13 @@ 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; }
// To make the hidden function visible in ghostRegion
......
......@@ -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,12 +2582,14 @@ int PartitionMesh(GModel *const model)
}
AssignMeshVertices(model);
movePeriodicNodesFromParentToPartitionEntities(model);
graph.clearDualGraph();
createDualGraph(graph, true);
graph.assignGhostCells();
if(CTX::instance()->mesh.partitionCreateGhostCells){
graph.clearDualGraph();
createDualGraph(graph, true);
graph.assignGhostCells();
}
return 0;
}
......@@ -2658,7 +2678,7 @@ int UnpartitionMesh(GModel *const model)
std::set<GVertex*, GEntityLessThan> vertices = model->getVertices();
std::set<MVertex*> verts;
movePeriodicNodesFromPartitionToParentEntities(model);
// Loop over vertices
......@@ -2870,13 +2890,15 @@ int PartitionUsingThisSplit(GModel *const model, unsigned int npart, hashmap<MEl
}
AssignMeshVertices(model);
movePeriodicNodesFromParentToPartitionEntities(model);
graph.clearDualGraph();
createDualGraph(graph, false);
graph.assignGhostCells();
if(CTX::instance()->mesh.partitionCreateGhostCells){
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