From 3b24fbfcebfe6c0195003e66b6bdbfd4c342e8ae Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@uliege.be>
Date: Wed, 25 Mar 2020 17:55:20 +0100
Subject: [PATCH] work on tutorials

---
 CHANGELOG.txt          |  4 ++--
 tutorial/c++/t8.cpp    |  3 ++-
 tutorial/python/t14.py | 40 ++++++++++++++++++++++------------------
 3 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 16587f6557..b2f1a72a22 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,4 +1,4 @@
-4.5.6 (Work-in-progress): small bug fixes.
+4.5.6 (Work-in-progress): API tutorials; small bug fixes.
 
 4.5.5 (March 21, 2020): tooltips in GUI to help discovery of scripting options;
 fixed MED IO of high-order elements; fixed OCC attribute search by bounding box;
@@ -6,7 +6,7 @@ fix parsing of mac-encoded scripts; new RecombineMesh command; added support for
 extrusion of mixed-dimension entities with OCC; small bug fixes.
 
 4.5.4 (February 29, 2020): periodic mesh optimization now ensures that the
-master mesh is not modified; code cleanup; API tutorials; small bug fixes.
+master mesh is not modified; code cleanup; small bug fixes.
 
 4.5.3 (February 22, 2020): improved positioning of corresponding nodes on
 periodic entities; improved LaTeX output; improved curve splitting in
diff --git a/tutorial/c++/t8.cpp b/tutorial/c++/t8.cpp
index 3e04c501ba..eabf507216 100644
--- a/tutorial/c++/t8.cpp
+++ b/tutorial/c++/t8.cpp
@@ -11,7 +11,7 @@ int main(int argc, char **argv)
   gmsh::initialize();
   gmsh::option::setNumber("General.Terminal", 1);
 
-  model::add("t7");
+  model::add("t8");
 
   // Copied from t1.cpp...
   double lc = 1e-2;
@@ -35,6 +35,7 @@ int main(int argc, char **argv)
   }
   catch(...) {
     gmsh::logger::write("Could not load post-processing views: bye!");
+    gmsh::finalize();
     return 0;
   }
 
diff --git a/tutorial/python/t14.py b/tutorial/python/t14.py
index 05852ccda1..9d3a67debb 100644
--- a/tutorial/python/t14.py
+++ b/tutorial/python/t14.py
@@ -1,13 +1,5 @@
 # This file reimplements gmsh/tutorial/t14.geo in Python.
 
-# /*********************************************************************
-#  *
-#  *  Gmsh tutorial 14
-#  *
-#  *  Homology and cohomology computation
-#  *
-#  *********************************************************************/
-
 # Homology computation in Gmsh finds representative chains of (relative)
 # (co)homology space bases using a mesh of a model.  The representative basis
 # chains are stored in the mesh as physical groups of Gmsh, one for each chain.
@@ -90,32 +82,44 @@ for tag in terminal_tags:
 
 # Whole domain surface
 boundary_physical_tag = 2002
-gmsh.model.addPhysicalGroup(dim=2, tags=boundary_tags, tag=boundary_physical_tag)
-gmsh.model.setPhysicalName(dim=2, tag=boundary_physical_tag, name="Boundary")
+gmsh.model.addPhysicalGroup(dim=2, tags=boundary_tags,
+                            tag=boundary_physical_tag)
+gmsh.model.setPhysicalName(dim=2, tag=boundary_physical_tag,
+                           name="Boundary")
 
 # Complement of the domain surface respect to the four terminals
 complement_physical_tag = 2003
-gmsh.model.addPhysicalGroup(dim=2, tags=complement_tags, tag=complement_physical_tag)
-gmsh.model.setPhysicalName(dim=2, tag=complement_physical_tag, name="Complement")
+gmsh.model.addPhysicalGroup(dim=2, tags=complement_tags,
+                            tag=complement_physical_tag)
+gmsh.model.setPhysicalName(dim=2, tag=complement_physical_tag,
+                           name="Complement")
 
 gmsh.model.geo.synchronize()
 
 # Find bases for relative homology spaces of the domain modulo the four
 # terminals.
-gmsh.model.mesh.computeHomology(domainTags=[domain_physical_tag], subdomainTags=[terminals_physical_tag], dims=[0,1,2,3])
+gmsh.model.mesh.computeHomology(domainTags=[domain_physical_tag],
+                                subdomainTags=[terminals_physical_tag],
+                                dims=[0,1,2,3])
 
 # Find homology space bases isomorphic to the previous bases: homology spaces
 # modulo the non-terminal domain surface, a.k.a the thin cuts.
-gmsh.model.mesh.computeHomology(domainTags=[domain_physical_tag], subdomainTags=[complement_physical_tag], dims=[0,1,2,3])
+gmsh.model.mesh.computeHomology(domainTags=[domain_physical_tag],
+                                subdomainTags=[complement_physical_tag],
+                                dims=[0,1,2,3])
 
 # Find cohomology space bases isomorphic to the previous bases: cohomology
 # spaces of the domain modulo the four terminals, a.k.a the thick cuts.
-gmsh.model.mesh.computeCohomology(domainTags=[domain_physical_tag], subdomainTags=[terminals_physical_tag], dims=[0,1,2,3])
+gmsh.model.mesh.computeCohomology(domainTags=[domain_physical_tag],
+                                  subdomainTags=[terminals_physical_tag],
+                                  dims=[0,1,2,3])
 
 # more examples
-#gmsh.model.mesh.computeHomology()
-#gmsh.model.mesh.computeHomology(domainTags=[domain_physical_tag])
-#gmsh.model.mesh.computeHomology(domainTags=[domain_physical_tag], subdomainTags=[boundary_physical_tag], dims=[0,1,2,3])
+# gmsh.model.mesh.computeHomology()
+# gmsh.model.mesh.computeHomology(domainTags=[domain_physical_tag])
+# gmsh.model.mesh.computeHomology(domainTags=[domain_physical_tag],
+#                                 subdomainTags=[boundary_physical_tag],
+#                                 dims=[0,1,2,3])
 
 # Generate the mesh and perform the requested homology computations
 gmsh.model.mesh.generate(3)
-- 
GitLab