From b249cc106001dc486914ebbae30455ccce996c4a Mon Sep 17 00:00:00 2001
From: Tuomas Karna <tuomas.karna@uclouvain.be>
Date: Tue, 31 Jan 2012 10:18:33 +0000
Subject: [PATCH] added a flag to GModel::createPartitionBoundaries to create
 both 2D and 3D boundaries

---
 Geo/GModel.cpp         |  4 ++--
 Geo/GModel.h           |  2 +-
 Mesh/meshPartition.cpp | 14 +++++++-------
 Mesh/meshPartition.h   |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp
index af2342ce6c..71928b1dbf 100644
--- a/Geo/GModel.cpp
+++ b/Geo/GModel.cpp
@@ -2732,10 +2732,10 @@ void GModel::classifyFaces(std::set<GFace*> &_faces)
 #endif
 }
 
-void GModel::createPartitionBoundaries(int createGhostCells)
+void GModel::createPartitionBoundaries(int createGhostCells, int createAllDims)
 {
 #if (defined(HAVE_CHACO) || defined(HAVE_METIS)) && defined(HAVE_MESH)
-  CreatePartitionBoundaries(this, createGhostCells);
+  CreatePartitionBoundaries(this, createGhostCells, createAllDims);
 #endif
 }
 
diff --git a/Geo/GModel.h b/Geo/GModel.h
index 820a5b9e90..4ae2f0cb58 100644
--- a/Geo/GModel.h
+++ b/Geo/GModel.h
@@ -403,7 +403,7 @@ class GModel
   int refineMesh(int linear);
 
   // create partition boundaries
-  void createPartitionBoundaries(int createGhostCells);
+  void createPartitionBoundaries(int createGhostCells, int createAllDims = 0);
 
   // fill the vertex arrays, given the current option and data
   void fillVertexArrays();
diff --git a/Mesh/meshPartition.cpp b/Mesh/meshPartition.cpp
index b25e30477c..199468841c 100644
--- a/Mesh/meshPartition.cpp
+++ b/Mesh/meshPartition.cpp
@@ -1188,7 +1188,7 @@ static void addGhostCells(GEntity *ge,
   }
 }
 
-int CreatePartitionBoundaries(GModel *model, bool createGhostCells)
+int CreatePartitionBoundaries(GModel *model, bool createGhostCells, bool createAllDims)
 {
   unsigned numElem[5];
   const int meshDim = model->getNumMeshElements(numElem);
@@ -1225,14 +1225,14 @@ int CreatePartitionBoundaries(GModel *model, bool createGhostCells)
   
   // create partition edges
   if (meshDim > 1){
-    if (meshDim == 2){
+    if (meshDim == 2 || createAllDims){
       for(GModel::fiter it = model->firstFace(); it != model->lastFace(); ++it){
         fillit_(edgeToElement, (*it)->triangles.begin(), (*it)->triangles.end());
         fillit_(edgeToElement, (*it)->quadrangles.begin(), (*it)->quadrangles.end());
         fillit_(edgeToElement, (*it)->polygons.begin(), (*it)->polygons.end());
       }
     }
-    else if (meshDim == 3){
+    if (meshDim == 3){
       for(GModel::riter it = model->firstRegion(); it != model->lastRegion(); ++it){
         fillit_(edgeToElement, (*it)->tetrahedra.begin(), (*it)->tetrahedra.end());
         fillit_(edgeToElement, (*it)->hexahedra.begin(), (*it)->hexahedra.end());
@@ -1258,14 +1258,14 @@ int CreatePartitionBoundaries(GModel *model, bool createGhostCells)
 
   // create partition vertices
   if (meshDim > 1){
-    if (meshDim == 2){
+    if (meshDim == 2 || createAllDims){
       for(GModel::fiter it = model->firstFace(); it != model->lastFace(); ++it){
         fillit_(vertexToElement, (*it)->triangles.begin(), (*it)->triangles.end());
         fillit_(vertexToElement, (*it)->quadrangles.begin(), (*it)->quadrangles.end());
         fillit_(vertexToElement, (*it)->polygons.begin(), (*it)->polygons.end());
       }
     }
-    else if (meshDim == 3){
+    if (meshDim == 3){
       for(GModel::riter it = model->firstRegion(); it != model->lastRegion(); ++it){
         fillit_(vertexToElement, (*it)->tetrahedra.begin(), (*it)->tetrahedra.end());
         fillit_(vertexToElement, (*it)->hexahedra.begin(), (*it)->hexahedra.end());
@@ -1292,11 +1292,11 @@ int CreatePartitionBoundaries(GModel *model, bool createGhostCells)
   if(createGhostCells){
     std::multimap<MElement*, short> &ghosts(model->getGhostCells());
     ghosts.clear();
-    if(meshDim == 2)
+    if(meshDim == 2 || createAllDims)
       for(std::set<partitionEdge*, Less_partitionEdge>::iterator it = pedges.begin();
           it != pedges.end(); it++)
         addGhostCells(*it, vertexToElement, ghosts);
-    else if(meshDim == 3)
+    if(meshDim == 3)
       for(std::set<partitionFace*, Less_partitionFace>::iterator it = pfaces.begin();
           it != pfaces.end(); it++)
         addGhostCells(*it, vertexToElement, ghosts);
diff --git a/Mesh/meshPartition.h b/Mesh/meshPartition.h
index 85ceb85d9d..56954fa5f6 100644
--- a/Mesh/meshPartition.h
+++ b/Mesh/meshPartition.h
@@ -29,7 +29,7 @@ int RenumberMesh(GModel *const model, meshPartitionOptions &options);
 int PartitionMeshFace(std::list<GFace*> &cFaces, meshPartitionOptions &options);
 int PartitionMeshElements(std::vector<MElement*> &elements, 
                           meshPartitionOptions &options);
-int CreatePartitionBoundaries(GModel *model, bool createGhostCells);
+int CreatePartitionBoundaries(GModel *model, bool createGhostCells, bool createAllDims = false);
 
 void splitBoundaryEdges(GModel *model,
                         std::set<partitionEdge*, Less_partitionEdge> &newEdges);
-- 
GitLab