Skip to content
Snippets Groups Projects
Commit 99305dd7 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

compute bnd is optional

parent 57be5799
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
StringXNumber SimplePartitionOptions_Number[] = { StringXNumber SimplePartitionOptions_Number[] = {
{GMSH_FULLRC, "NumSlices", NULL, 4.}, {GMSH_FULLRC, "NumSlices", NULL, 4.},
{GMSH_FULLRC, "Direction", NULL, 0.}, {GMSH_FULLRC, "Direction", NULL, 0.},
{GMSH_FULLRC, "CreateBoundaries", NULL, 1.},
}; };
extern "C" extern "C"
...@@ -29,7 +30,8 @@ std::string GMSH_SimplePartitionPlugin::getHelp() const ...@@ -29,7 +30,8 @@ std::string GMSH_SimplePartitionPlugin::getHelp() const
{ {
return "Plugin(SimplePartition) partitions the current mesh into " return "Plugin(SimplePartition) partitions the current mesh into "
"`NumSlices' slices, along the X-, Y- or Z-axis depending on " "`NumSlices' slices, along the X-, Y- or Z-axis depending on "
"the value of `Direction' (0,1,2)."; "the value of `Direction' (0,1,2). The plugin creates partition "
"boundaries if `CreateBoundaries' is set.";
} }
int GMSH_SimplePartitionPlugin::getNbOptions() const int GMSH_SimplePartitionPlugin::getNbOptions() const
...@@ -46,10 +48,12 @@ PView *GMSH_SimplePartitionPlugin::execute(PView *v) ...@@ -46,10 +48,12 @@ PView *GMSH_SimplePartitionPlugin::execute(PView *v)
{ {
int numSlices = (int)SimplePartitionOptions_Number[0].def; int numSlices = (int)SimplePartitionOptions_Number[0].def;
int direction = (int)SimplePartitionOptions_Number[1].def; int direction = (int)SimplePartitionOptions_Number[1].def;
int createBoundaries = (int)SimplePartitionOptions_Number[2].def;
// partition the highest dimension elements in the current model (lower // partition the highest dimension elements in the current model (lower
// dimension elements en boundaries cannot be tagged a priori: there are // dimension elements on boundaries cannot be tagged a priori: there are
// special geometrical cases) // special geometrical cases where this will fail)
Msg::Info("Partitioning highest dimension elements");
GModel *m = GModel::current(); GModel *m = GModel::current();
SBoundingBox3d bbox = m->bounds(); SBoundingBox3d bbox = m->bounds();
double pmin = bbox.min()[direction], pmax = bbox.max()[direction]; double pmin = bbox.min()[direction], pmax = bbox.max()[direction];
...@@ -89,6 +93,7 @@ PView *GMSH_SimplePartitionPlugin::execute(PView *v) ...@@ -89,6 +93,7 @@ PView *GMSH_SimplePartitionPlugin::execute(PView *v)
m->recomputeMeshPartitions(); m->recomputeMeshPartitions();
// partition lower dimension elements // partition lower dimension elements
Msg::Info("Partitioning lower dimension elements");
for(unsigned int i = 0; i < entities.size(); i++){ for(unsigned int i = 0; i < entities.size(); i++){
GEntity *ge = entities[i]; GEntity *ge = entities[i];
if(ge->dim() == dim) continue; if(ge->dim() == dim) continue;
...@@ -115,54 +120,56 @@ PView *GMSH_SimplePartitionPlugin::execute(PView *v) ...@@ -115,54 +120,56 @@ PView *GMSH_SimplePartitionPlugin::execute(PView *v)
} }
} }
// create partition boundaries if(createBoundaries){
#if defined(HAVE_MESH) #if defined(HAVE_MESH)
CreatePartitionBoundaries(m, false, false); Msg::Info("Creating partition boundaries");
CreatePartitionBoundaries(m, false, false);
#else
Msg::Error("Creating partition boundaries requires the mesh module");
#endif #endif
// renumber partition boundaries using the natural slicing order
// renumber partition boundaries using the natural slicing order Msg::Info("Renumbering partition boundaries");
std::vector<std::pair<double, GFace*> > parFaces; std::vector<std::pair<double, GFace*> > parFaces;
std::vector<std::pair<double, GEdge*> > parEdges; std::vector<std::pair<double, GEdge*> > parEdges;
m->getEntities(entities); m->getEntities(entities);
for(unsigned int i = 0; i < entities.size(); i++){ for(unsigned int i = 0; i < entities.size(); i++){
GEntity *ge = entities[i]; GEntity *ge = entities[i];
if(ge->geomType() == GEntity::PartitionSurface || if(ge->geomType() == GEntity::PartitionSurface ||
ge->geomType() == GEntity::PartitionCurve){ ge->geomType() == GEntity::PartitionCurve){
double val = pmax; double val = pmax;
for(int j = 0; j < ge->getNumMeshElements(); j++){ for(int j = 0; j < ge->getNumMeshElements(); j++){
MElement *e = ge->getMeshElement(j); MElement *e = ge->getMeshElement(j);
for(int k = 0; k < e->getNumVertices(); k++){ for(int k = 0; k < e->getNumVertices(); k++){
MVertex *v = e->getVertex(k); MVertex *v = e->getVertex(k);
val = std::min(val, v->point()[direction]); val = std::min(val, v->point()[direction]);
}
}
if(ge->dim() == 2){
GFace *gf = (GFace*)ge;
parFaces.push_back(std::pair<double, GFace*>(val, gf));
m->remove(gf);
}
else{
GEdge *gc = (GEdge*)ge;
parEdges.push_back(std::pair<double, GEdge*>(val, gc));
m->remove(gc);
} }
}
if(ge->dim() == 2){
GFace *gf = (GFace*)ge;
parFaces.push_back(std::pair<double, GFace*>(val, gf));
m->remove(gf);
}
else{
GEdge *gc = (GEdge*)ge;
parEdges.push_back(std::pair<double, GEdge*>(val, gc));
m->remove(gc);
} }
} }
} std::sort(parFaces.begin(), parFaces.end());
for(unsigned int i = 0; i < parFaces.size(); i++){
std::sort(parFaces.begin(), parFaces.end()); GFace *gf = parFaces[i].second;
for(unsigned int i = 0; i < parFaces.size(); i++){ gf->setTag(-i-1);
GFace *gf = parFaces[i].second; gf->setMeshMaster(-i-1);
gf->setTag(-i-1); m->add(gf);
gf->setMeshMaster(-i-1); }
m->add(gf); std::sort(parEdges.begin(), parEdges.end());
} for(unsigned int i = 0; i < parEdges.size(); i++){
GEdge *ge = parEdges[i].second;
std::sort(parEdges.begin(), parEdges.end()); ge->setTag(-i-1);
for(unsigned int i = 0; i < parEdges.size(); i++){ ge->setMeshMaster(-i-1);
GEdge *ge = parEdges[i].second; m->add(ge);
ge->setTag(-i-1); }
ge->setMeshMaster(-i-1);
m->add(ge);
} }
return v; return v;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment