From e884dfcd1f7cde5f6a5d7d8bcb082172e8c8518b Mon Sep 17 00:00:00 2001
From: Matti Pellika <matti.pellikka@tut.fi>
Date: Thu, 4 Jun 2009 07:25:23 +0000
Subject: [PATCH] Changed GMSH_LIBS order in configure.in in order to make
 linker work with homology computation plugin under linux.

Added more message console info about homology computation.
---
 Geo/CellComplex.cpp    | 14 +++++++++-----
 Geo/CellComplex.h      |  4 ++--
 Geo/Homology.cpp       | 23 ++++++++++++++++++++---
 benchmarks/3d/hole.geo |  1 +
 configure              |  4 ++--
 configure.in           |  4 ++--
 6 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/Geo/CellComplex.cpp b/Geo/CellComplex.cpp
index 64d87e5fe1..64224caf67 100644
--- a/Geo/CellComplex.cpp
+++ b/Geo/CellComplex.cpp
@@ -355,14 +355,14 @@ int CellComplex::reduction(int dim){
 }
 
  
-void CellComplex::reduceComplex(bool omitHighdim){
+int CellComplex::reduceComplex(bool omitHighdim){
   printf("Cell complex before reduction: %d volumes, %d faces, %d edges and %d vertices.\n",
          getSize(3), getSize(2), getSize(1), getSize(0));
 
   int count = 0;
   for(int i = 3; i > 0; i--) count = count + reduction(i);
   
-  
+  int omitted = 0;
   if(count == 0 && omitHighdim){
     
     removeSubdomain();
@@ -376,7 +376,7 @@ void CellComplex::reduceComplex(bool omitHighdim){
       reduction(3);
       reduction(2);
       reduction(1);
-             
+      omitted++;
      }
     
     
@@ -393,6 +393,8 @@ void CellComplex::reduceComplex(bool omitHighdim){
   
   printf("Cell complex after reduction: %d volumes, %d faces, %d edges and %d vertices.\n",
          getSize(3), getSize(2), getSize(1), getSize(0));
+  
+  return omitted;
 }
 
 
@@ -412,7 +414,7 @@ void CellComplex::removeSubdomain(){
 }
 
 
-void CellComplex::coreduceComplex(bool omitLowdim){
+int CellComplex::coreduceComplex(bool omitLowdim){
 
   printf("Cell complex before coreduction: %d volumes, %d faces, %d edges and %d vertices.\n",
          getSize(3), getSize(2), getSize(1), getSize(0));
@@ -430,6 +432,7 @@ void CellComplex::coreduceComplex(bool omitLowdim){
     }
   } 
   
+  int omitted = 0;
   if(count == 0 && omitLowdim){
     std::set<Cell*, Less_Cell> generatorCells;
     
@@ -439,6 +442,7 @@ void CellComplex::coreduceComplex(bool omitLowdim){
       generatorCells.insert(cell);
       removeCell(cell);
       coreduction(cell);
+      omitted++;
     }
     
     for(citer cit = generatorCells.begin(); cit != generatorCells.end(); cit++){
@@ -454,7 +458,7 @@ void CellComplex::coreduceComplex(bool omitLowdim){
   printf("Cell complex after coreduction: %d volumes, %d faces, %d edges and %d vertices.\n",
          getSize(3), getSize(2), getSize(1), getSize(0));
   
-  return;
+  return omitted;
 }
 
 void CellComplex::computeBettiNumbers(){
diff --git a/Geo/CellComplex.h b/Geo/CellComplex.h
index 1252592f31..7c217e15ff 100644
--- a/Geo/CellComplex.h
+++ b/Geo/CellComplex.h
@@ -618,8 +618,8 @@ class CellComplex
    
    
    // useful functions for (co)reduction of cell complex
-   void reduceComplex(bool omitHighdim = false);
-   void coreduceComplex(bool omitlowDim = false);
+   int reduceComplex(bool omitHighdim = false);
+   int coreduceComplex(bool omitlowDim = false);
    
    // queued coreduction presented in Mrozek's paper
    int coreduction(Cell* generator);
diff --git a/Geo/Homology.cpp b/Geo/Homology.cpp
index 6b1f79aa2e..d39404115b 100644
--- a/Geo/Homology.cpp
+++ b/Geo/Homology.cpp
@@ -71,7 +71,7 @@ Homology::Homology(GModel* model, std::vector<int> physicalDomain, std::vector<i
 void Homology::findGenerators(std::string fileName){
   
   Msg::Info("Reducing Cell Complex...");
-  _cellComplex->reduceComplex(true);
+  int omitted = _cellComplex->reduceComplex(true);
   _cellComplex->combine(3);
   _cellComplex->combine(2);
   _cellComplex->combine(1);
@@ -100,6 +100,15 @@ void Homology::findGenerators(std::string fileName){
       delete chain;
     }
   }
+  
+  Msg::Info("Ranks of homology groups for primal cell complex:");
+  Msg::Info("H0 = %d", chains->getBasisSize(0));
+  Msg::Info("H1 = %d", chains->getBasisSize(1));
+  Msg::Info("H2 = %d", chains->getBasisSize(2));
+  Msg::Info("H3 = %d", chains->getBasisSize(3));
+  if(omitted != 0) Msg::Info("%d 0D generators are not shown completely.", omitted);
+  
+  
   Msg::Info("Wrote results to %s.", fileName.c_str());
   
   delete chains;
@@ -110,7 +119,7 @@ void Homology::findGenerators(std::string fileName){
 void Homology::findThickCuts(std::string fileName){
   
   Msg::Info("Reducing Cell Complex...");
-  _cellComplex->coreduceComplex(true);
+  int omitted = _cellComplex->coreduceComplex(true);
   _cellComplex->cocombine(0);
   _cellComplex->cocombine(1);
   _cellComplex->cocombine(2);
@@ -134,7 +143,7 @@ void Homology::findThickCuts(std::string fileName){
       convert(i, generator);
       convert(3-j, dimension);
       
-      std::string name = dimension + "D Dual cut " + generator;
+      std::string name = dimension + "D Thick cut " + generator;
       Chain* chain = new Chain(_cellComplex->getCells(j), chains->getCoeffVector(j,i), _cellComplex, name);
       chain->writeChainMSH(fileName);
       delete chain;
@@ -142,6 +151,14 @@ void Homology::findThickCuts(std::string fileName){
     }
   }
   
+  Msg::Info("Ranks of homology groups for dual cell complex:");
+  Msg::Info("H0 = %d", chains->getBasisSize(3));
+  Msg::Info("H1 = %d", chains->getBasisSize(2));
+  Msg::Info("H2 = %d", chains->getBasisSize(1));
+  Msg::Info("H3 = %d", chains->getBasisSize(0));
+  if(omitted != 0) Msg::Info("%d 3D thick cuts are not shown completely.", omitted);
+  
+  
   Msg::Info("Wrote results to %s.", fileName.c_str());
   
   delete chains;
diff --git a/benchmarks/3d/hole.geo b/benchmarks/3d/hole.geo
index c45163022f..72870d2c5f 100644
--- a/benchmarks/3d/hole.geo
+++ b/benchmarks/3d/hole.geo
@@ -588,3 +588,4 @@ Volume(100019) = {100018};
 // air bottom
 Surface Loop(100020) = {1138,100009,1104,1110,1116,1096,1092,1134,1136,1087,1140,1208,1374,1368,1378,1376,1370,1372,1362,1366};
 Volume(100021) = {100020};
+Physical Volume(100022) = {100005, 1390, 1388, 1386, 100001, 100003};
diff --git a/configure b/configure
index 974e069c33..0a3ee5d061 100755
--- a/configure
+++ b/configure
@@ -3711,7 +3711,7 @@ esac
 if test "x$enable_gui" != "xno"; then
 
   GMSH_DIRS="Common Geo Mesh Post Plugin Numeric Parser Graphics Fltk"
-  GMSH_LIBS="-Llib -lGmshFltk -lGmshCommon -lGmshMesh -lGmshGeo -lGmshPost -lGmshPlugin"
+  GMSH_LIBS="-Llib -lGmshFltk -lGmshCommon -lGmshMesh -lGmshPost -lGmshPlugin -lGmshGeo"
   GMSH_LIBS="${GMSH_LIBS} -lGmshCommon -lGmshGraphics -lGmshParser -lGmshNumeric"
   cat >>confdefs.h <<\_ACEOF
 #define HAVE_FLTK 1
@@ -4222,7 +4222,7 @@ else
 
   if test "x$enable_post" != "xno"; then
     GMSH_DIRS="${GMSH_DIRS} Post Plugin"
-    GMSH_LIBS="${GMSH_LIBS} -lGmshPost -lGmshPlugin"
+    GMSH_LIBS="${GMSH_LIBS} -lGmshPost -lGmshPlugin -lGmshGeo"
   else
     cat >>confdefs.h <<\_ACEOF
 #define HAVE_NO_POST 1
diff --git a/configure.in b/configure.in
index 5a4c54d3ff..7732fd1fdc 100644
--- a/configure.in
+++ b/configure.in
@@ -233,7 +233,7 @@ dnl Choose to build the GUI or the batch version
 if test "x$enable_gui" != "xno"; then
 
   GMSH_DIRS="Common Geo Mesh Post Plugin Numeric Parser Graphics Fltk"
-  GMSH_LIBS="-Llib -lGmshFltk -lGmshCommon -lGmshMesh -lGmshGeo -lGmshPost -lGmshPlugin"
+  GMSH_LIBS="-Llib -lGmshFltk -lGmshCommon -lGmshMesh -lGmshPost -lGmshPlugin -lGmshGeo"
   GMSH_LIBS="${GMSH_LIBS} -lGmshCommon -lGmshGraphics -lGmshParser -lGmshNumeric"
   AC_DEFINE(HAVE_FLTK)
   BO="${BO} Fltk"
@@ -379,7 +379,7 @@ else
 
   if test "x$enable_post" != "xno"; then
     GMSH_DIRS="${GMSH_DIRS} Post Plugin"
-    GMSH_LIBS="${GMSH_LIBS} -lGmshPost -lGmshPlugin"
+    GMSH_LIBS="${GMSH_LIBS} -lGmshPost -lGmshPlugin -lGmshGeo"
   else
     AC_DEFINE(HAVE_NO_POST)
     BO="${BO} NoPost"
-- 
GitLab