From 0ece73ddc61d407c921a23ce851a0ae40f33b8d1 Mon Sep 17 00:00:00 2001 From: Max Orok <morok@mevex.com> Date: Tue, 27 Aug 2019 12:34:53 -0400 Subject: [PATCH] Change comment style to match the existing tutorials --- demos/api/t11.py | 1 - demos/api/t15.py | 30 +++++++----------------------- demos/api/t7.py | 17 ++++++----------- demos/api/t8.py | 25 ++++++++++--------------- demos/api/t9.py | 2 +- 5 files changed, 24 insertions(+), 51 deletions(-) diff --git a/demos/api/t11.py b/demos/api/t11.py index 94e751c1a2..cfdf6ad584 100644 --- a/demos/api/t11.py +++ b/demos/api/t11.py @@ -61,7 +61,6 @@ model.mesh.generate(2) # Force a full-quad mesh with either option # gmsh.option.setNumber("Mesh.SubdivisionAlgorithm", 1) # gmsh.option.setNumber("Mesh.RecombinationAlgorithm", 2) # or 3 - # model.mesh.generate(2) gmsh.fltk.run() diff --git a/demos/api/t15.py b/demos/api/t15.py index 3b15c63064..a0e18172c4 100644 --- a/demos/api/t15.py +++ b/demos/api/t15.py @@ -1,48 +1,32 @@ # This file reimplements gmsh/tutorial/t15.geo in Python. - -# Note that t15.geo begins by calling "Include(t1.geo)" to paste the contents -# of t1.geo into t15.geo. Since the Python API has no equivalent command, we -# mark the lines adapted from t1.py. -# -# For educational purposes this code makes use of frequent geometry model -# synchronization calls. # -# If performance is a priority, you may want to group related embed calls to -# avoid calling the expensive synchronize operation too many times. +# Embedded points, lines and surfaces import gmsh model = gmsh.model factory = model.geo -# adapted t1.py section {{{ - gmsh.initialize() gmsh.option.setNumber("General.Terminal", 1) +# Copied from t1.py... lc = 1e-2 factory.addPoint(0, 0, 0, lc, 1) factory.addPoint(.1, 0, 0, lc, 2) factory.addPoint(.1, .3, 0, lc, 3) factory.addPoint(0, .3, 0, lc, 4) - factory.addLine(1, 2, 1) factory.addLine(3, 2, 2) factory.addLine(3, 4, 3) factory.addLine(4, 1, 4) - factory.addCurveLoop([4, 1, -2, 3], 1) factory.addPlaneSurface([1], 1) - model.addPhysicalGroup(0, [1, 2], 1) model.addPhysicalGroup(1, [1, 2], 2) model.addPhysicalGroup(2, [1], 6) - model.setPhysicalName(2, 6, "My surface") - -# }}} - -# -- begin t15.py proper -- +# ...end of copy # We change the mesh size to generate a coarser mesh lc = lc * 4 @@ -53,7 +37,6 @@ factory.addPoint(0.02, 0.02, 0., lc, 5) # We have to synchronize before embedding entites. # Otherwise, we get an error like "Point 5 does not exist" -# factory.synchronize() # embed the point (dim 0) in the surface (dim 2) @@ -81,7 +64,7 @@ l = factory.addLine(7, p+1) factory.synchronize() model.mesh.embed(1, [l], 3, 1) -# finally, we can only embed a surface in a volume +# finally, we can embed a surface in a volume factory.addPoint(0.02, 0.12, 0.05, lc, p+2) factory.addPoint(0.04, 0.12, 0.05, lc, p+3) factory.addPoint(0.04, 0.18, 0.05, lc, p+4) @@ -99,7 +82,8 @@ factory.synchronize() model.mesh.embed(2, [s], 3, 1) # create and show the mesh -# model.mesh.generate(3) -# gmsh.fltk.run() +model.mesh.generate(3) +gmsh.write("t15.msh") +gmsh.fltk.run() gmsh.finalize() diff --git a/demos/api/t7.py b/demos/api/t7.py index c453d0661b..1435a872d3 100644 --- a/demos/api/t7.py +++ b/demos/api/t7.py @@ -1,40 +1,34 @@ # This file reimplements gmsh/tutorial/t7.geo in Python. -# It extends t1.py to use a background mesh. +# +# Background mesh import gmsh model = gmsh.model factory = model.geo -# adapted t1.py section {{{ - gmsh.initialize() gmsh.option.setNumber("General.Terminal", 1) +# Copied from t1.py... lc = 1e-2 factory.addPoint(0, 0, 0, lc, 1) factory.addPoint(.1, 0, 0, lc, 2) factory.addPoint(.1, .3, 0, lc, 3) factory.addPoint(0, .3, 0, lc, 4) - factory.addLine(1, 2, 1) factory.addLine(3, 2, 2) factory.addLine(3, 4, 3) factory.addLine(4, 1, 4) - factory.addCurveLoop([4, 1, -2, 3], 1) factory.addPlaneSurface([1], 1) - model.addPhysicalGroup(0, [1, 2], 1) model.addPhysicalGroup(1, [1, 2], 2) model.addPhysicalGroup(2, [1], 6) - model.setPhysicalName(2, 6, "My surface") +# ...end of copy -model.geo.synchronize() -# }}} - -# -- begin t7.py -- +factory.synchronize() # add the background mesh file as a view gmsh.merge("bgmesh.pos") @@ -42,6 +36,7 @@ gmsh.merge("bgmesh.pos") # pass the just-added view number to specify the background mesh gmsh.model.mesh.field.setAsBackgroundMesh(0) gmsh.model.mesh.generate(2) +gmsh.write("t7.msh") # show the mesh file # gmsh.fltk.run() diff --git a/demos/api/t8.py b/demos/api/t8.py index 3edd9f7b03..f59d2261b7 100644 --- a/demos/api/t8.py +++ b/demos/api/t8.py @@ -1,40 +1,34 @@ # This file reimplements gmsh/tutorial/t8.geo in Python. -# It demonstrates post-processing, animations and using options. +# +# Post-processing, scripting, animations, options import gmsh model = gmsh.model factory = model.geo -# adapted t1.py section {{{ - gmsh.initialize() gmsh.option.setNumber("General.Terminal", 1) +# Copied from t1.py... lc = 1e-2 factory.addPoint(0, 0, 0, lc, 1) factory.addPoint(.1, 0, 0, lc, 2) factory.addPoint(.1, .3, 0, lc, 3) factory.addPoint(0, .3, 0, lc, 4) - factory.addLine(1, 2, 1) factory.addLine(3, 2, 2) factory.addLine(3, 4, 3) factory.addLine(4, 1, 4) - factory.addCurveLoop([4, 1, -2, 3], 1) factory.addPlaneSurface([1], 1) - model.addPhysicalGroup(0, [1, 2], 1) model.addPhysicalGroup(1, [1, 2], 2) model.addPhysicalGroup(2, [1], 6) - model.setPhysicalName(2, 6, "My surface") +# ...end of copy -model.geo.synchronize() -# }}} - -# -- begin t8.py -- +factory.synchronize() # add post-processing views to work on gmsh.merge("view1.pos") @@ -164,10 +158,11 @@ for num in range(1, 4): # write out the graphics scene to an image file # Gmsh will try to detect the file extension - if num == 3: - gmsh.write("t2-{:.2g}.gif".format(num2)) - gmsh.write("t2-{:.2g}.ppm".format(num2)) - gmsh.write("t2-{:.2g}.jpg".format(num2)) + + # if num == 3: + # gmsh.write("t2-{:.2g}.gif".format(num2)) + # gmsh.write("t2-{:.2g}.ppm".format(num2)) + # gmsh.write("t2-{:.2g}.jpg".format(num2)) if num == 3: pass diff --git a/demos/api/t9.py b/demos/api/t9.py index 958e6ad5d2..835c208e6f 100644 --- a/demos/api/t9.py +++ b/demos/api/t9.py @@ -32,7 +32,7 @@ plugin.run("CutPlane") # Third is Annotate plugin.setString("Annotate", "Text", "A nice title") -# By convention, window coordinates larger than 99999 represent the center` +# By convention, window coordinates larger than 99999 represent the center plugin.setNumber("Annotate", "X", 1.e5) plugin.setNumber("Annotate", "Y", 50) plugin.setString("Annotate", "Font", "Times-BoldItalic") -- GitLab