Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Romin Tomasetti
gmsh
Commits
0ece73dd
Commit
0ece73dd
authored
5 years ago
by
Max Orok
Browse files
Options
Downloads
Patches
Plain Diff
Change comment style to match the existing tutorials
parent
5f2b1d9b
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
demos/api/t11.py
+0
-1
0 additions, 1 deletion
demos/api/t11.py
demos/api/t15.py
+7
-23
7 additions, 23 deletions
demos/api/t15.py
demos/api/t7.py
+6
-11
6 additions, 11 deletions
demos/api/t7.py
demos/api/t8.py
+10
-15
10 additions, 15 deletions
demos/api/t8.py
demos/api/t9.py
+1
-1
1 addition, 1 deletion
demos/api/t9.py
with
24 additions
and
51 deletions
demos/api/t11.py
+
0
−
1
View file @
0ece73dd
...
@@ -61,7 +61,6 @@ model.mesh.generate(2)
...
@@ -61,7 +61,6 @@ model.mesh.generate(2)
# Force a full-quad mesh with either option
# Force a full-quad mesh with either option
# gmsh.option.setNumber("Mesh.SubdivisionAlgorithm", 1)
# gmsh.option.setNumber("Mesh.SubdivisionAlgorithm", 1)
# gmsh.option.setNumber("Mesh.RecombinationAlgorithm", 2) # or 3
# gmsh.option.setNumber("Mesh.RecombinationAlgorithm", 2) # or 3
# model.mesh.generate(2)
# model.mesh.generate(2)
gmsh
.
fltk
.
run
()
gmsh
.
fltk
.
run
()
...
...
This diff is collapsed.
Click to expand it.
demos/api/t15.py
+
7
−
23
View file @
0ece73dd
# This file reimplements gmsh/tutorial/t15.geo in Python.
# 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
# Embedded points, lines and surfaces
# avoid calling the expensive synchronize operation too many times.
import
gmsh
import
gmsh
model
=
gmsh
.
model
model
=
gmsh
.
model
factory
=
model
.
geo
factory
=
model
.
geo
# adapted t1.py section {{{
gmsh
.
initialize
()
gmsh
.
initialize
()
gmsh
.
option
.
setNumber
(
"
General.Terminal
"
,
1
)
gmsh
.
option
.
setNumber
(
"
General.Terminal
"
,
1
)
# Copied from t1.py...
lc
=
1e-2
lc
=
1e-2
factory
.
addPoint
(
0
,
0
,
0
,
lc
,
1
)
factory
.
addPoint
(
0
,
0
,
0
,
lc
,
1
)
factory
.
addPoint
(.
1
,
0
,
0
,
lc
,
2
)
factory
.
addPoint
(.
1
,
0
,
0
,
lc
,
2
)
factory
.
addPoint
(.
1
,
.
3
,
0
,
lc
,
3
)
factory
.
addPoint
(.
1
,
.
3
,
0
,
lc
,
3
)
factory
.
addPoint
(
0
,
.
3
,
0
,
lc
,
4
)
factory
.
addPoint
(
0
,
.
3
,
0
,
lc
,
4
)
factory
.
addLine
(
1
,
2
,
1
)
factory
.
addLine
(
1
,
2
,
1
)
factory
.
addLine
(
3
,
2
,
2
)
factory
.
addLine
(
3
,
2
,
2
)
factory
.
addLine
(
3
,
4
,
3
)
factory
.
addLine
(
3
,
4
,
3
)
factory
.
addLine
(
4
,
1
,
4
)
factory
.
addLine
(
4
,
1
,
4
)
factory
.
addCurveLoop
([
4
,
1
,
-
2
,
3
],
1
)
factory
.
addCurveLoop
([
4
,
1
,
-
2
,
3
],
1
)
factory
.
addPlaneSurface
([
1
],
1
)
factory
.
addPlaneSurface
([
1
],
1
)
model
.
addPhysicalGroup
(
0
,
[
1
,
2
],
1
)
model
.
addPhysicalGroup
(
0
,
[
1
,
2
],
1
)
model
.
addPhysicalGroup
(
1
,
[
1
,
2
],
2
)
model
.
addPhysicalGroup
(
1
,
[
1
,
2
],
2
)
model
.
addPhysicalGroup
(
2
,
[
1
],
6
)
model
.
addPhysicalGroup
(
2
,
[
1
],
6
)
model
.
setPhysicalName
(
2
,
6
,
"
My surface
"
)
model
.
setPhysicalName
(
2
,
6
,
"
My surface
"
)
# ...end of copy
# }}}
# -- begin t15.py proper --
# We change the mesh size to generate a coarser mesh
# We change the mesh size to generate a coarser mesh
lc
=
lc
*
4
lc
=
lc
*
4
...
@@ -53,7 +37,6 @@ factory.addPoint(0.02, 0.02, 0., lc, 5)
...
@@ -53,7 +37,6 @@ factory.addPoint(0.02, 0.02, 0., lc, 5)
# We have to synchronize before embedding entites.
# We have to synchronize before embedding entites.
# Otherwise, we get an error like "Point 5 does not exist"
# Otherwise, we get an error like "Point 5 does not exist"
#
factory
.
synchronize
()
factory
.
synchronize
()
# embed the point (dim 0) in the surface (dim 2)
# embed the point (dim 0) in the surface (dim 2)
...
@@ -81,7 +64,7 @@ l = factory.addLine(7, p+1)
...
@@ -81,7 +64,7 @@ l = factory.addLine(7, p+1)
factory
.
synchronize
()
factory
.
synchronize
()
model
.
mesh
.
embed
(
1
,
[
l
],
3
,
1
)
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.02
,
0.12
,
0.05
,
lc
,
p
+
2
)
factory
.
addPoint
(
0.04
,
0.12
,
0.05
,
lc
,
p
+
3
)
factory
.
addPoint
(
0.04
,
0.12
,
0.05
,
lc
,
p
+
3
)
factory
.
addPoint
(
0.04
,
0.18
,
0.05
,
lc
,
p
+
4
)
factory
.
addPoint
(
0.04
,
0.18
,
0.05
,
lc
,
p
+
4
)
...
@@ -99,7 +82,8 @@ factory.synchronize()
...
@@ -99,7 +82,8 @@ factory.synchronize()
model
.
mesh
.
embed
(
2
,
[
s
],
3
,
1
)
model
.
mesh
.
embed
(
2
,
[
s
],
3
,
1
)
# create and show the mesh
# create and show the mesh
# model.mesh.generate(3)
model
.
mesh
.
generate
(
3
)
# gmsh.fltk.run()
gmsh
.
write
(
"
t15.msh
"
)
gmsh
.
fltk
.
run
()
gmsh
.
finalize
()
gmsh
.
finalize
()
This diff is collapsed.
Click to expand it.
demos/api/t7.py
+
6
−
11
View file @
0ece73dd
# This file reimplements gmsh/tutorial/t7.geo in Python.
# This file reimplements gmsh/tutorial/t7.geo in Python.
# It extends t1.py to use a background mesh.
#
# Background mesh
import
gmsh
import
gmsh
model
=
gmsh
.
model
model
=
gmsh
.
model
factory
=
model
.
geo
factory
=
model
.
geo
# adapted t1.py section {{{
gmsh
.
initialize
()
gmsh
.
initialize
()
gmsh
.
option
.
setNumber
(
"
General.Terminal
"
,
1
)
gmsh
.
option
.
setNumber
(
"
General.Terminal
"
,
1
)
# Copied from t1.py...
lc
=
1e-2
lc
=
1e-2
factory
.
addPoint
(
0
,
0
,
0
,
lc
,
1
)
factory
.
addPoint
(
0
,
0
,
0
,
lc
,
1
)
factory
.
addPoint
(.
1
,
0
,
0
,
lc
,
2
)
factory
.
addPoint
(.
1
,
0
,
0
,
lc
,
2
)
factory
.
addPoint
(.
1
,
.
3
,
0
,
lc
,
3
)
factory
.
addPoint
(.
1
,
.
3
,
0
,
lc
,
3
)
factory
.
addPoint
(
0
,
.
3
,
0
,
lc
,
4
)
factory
.
addPoint
(
0
,
.
3
,
0
,
lc
,
4
)
factory
.
addLine
(
1
,
2
,
1
)
factory
.
addLine
(
1
,
2
,
1
)
factory
.
addLine
(
3
,
2
,
2
)
factory
.
addLine
(
3
,
2
,
2
)
factory
.
addLine
(
3
,
4
,
3
)
factory
.
addLine
(
3
,
4
,
3
)
factory
.
addLine
(
4
,
1
,
4
)
factory
.
addLine
(
4
,
1
,
4
)
factory
.
addCurveLoop
([
4
,
1
,
-
2
,
3
],
1
)
factory
.
addCurveLoop
([
4
,
1
,
-
2
,
3
],
1
)
factory
.
addPlaneSurface
([
1
],
1
)
factory
.
addPlaneSurface
([
1
],
1
)
model
.
addPhysicalGroup
(
0
,
[
1
,
2
],
1
)
model
.
addPhysicalGroup
(
0
,
[
1
,
2
],
1
)
model
.
addPhysicalGroup
(
1
,
[
1
,
2
],
2
)
model
.
addPhysicalGroup
(
1
,
[
1
,
2
],
2
)
model
.
addPhysicalGroup
(
2
,
[
1
],
6
)
model
.
addPhysicalGroup
(
2
,
[
1
],
6
)
model
.
setPhysicalName
(
2
,
6
,
"
My surface
"
)
model
.
setPhysicalName
(
2
,
6
,
"
My surface
"
)
# ...end of copy
model
.
geo
.
synchronize
()
factory
.
synchronize
()
# }}}
# -- begin t7.py --
# add the background mesh file as a view
# add the background mesh file as a view
gmsh
.
merge
(
"
bgmesh.pos
"
)
gmsh
.
merge
(
"
bgmesh.pos
"
)
...
@@ -42,6 +36,7 @@ gmsh.merge("bgmesh.pos")
...
@@ -42,6 +36,7 @@ gmsh.merge("bgmesh.pos")
# pass the just-added view number to specify the background mesh
# pass the just-added view number to specify the background mesh
gmsh
.
model
.
mesh
.
field
.
setAsBackgroundMesh
(
0
)
gmsh
.
model
.
mesh
.
field
.
setAsBackgroundMesh
(
0
)
gmsh
.
model
.
mesh
.
generate
(
2
)
gmsh
.
model
.
mesh
.
generate
(
2
)
gmsh
.
write
(
"
t7.msh
"
)
# show the mesh file
# show the mesh file
# gmsh.fltk.run()
# gmsh.fltk.run()
...
...
This diff is collapsed.
Click to expand it.
demos/api/t8.py
+
10
−
15
View file @
0ece73dd
# This file reimplements gmsh/tutorial/t8.geo in Python.
# This file reimplements gmsh/tutorial/t8.geo in Python.
# It demonstrates post-processing, animations and using options.
#
# Post-processing, scripting, animations, options
import
gmsh
import
gmsh
model
=
gmsh
.
model
model
=
gmsh
.
model
factory
=
model
.
geo
factory
=
model
.
geo
# adapted t1.py section {{{
gmsh
.
initialize
()
gmsh
.
initialize
()
gmsh
.
option
.
setNumber
(
"
General.Terminal
"
,
1
)
gmsh
.
option
.
setNumber
(
"
General.Terminal
"
,
1
)
# Copied from t1.py...
lc
=
1e-2
lc
=
1e-2
factory
.
addPoint
(
0
,
0
,
0
,
lc
,
1
)
factory
.
addPoint
(
0
,
0
,
0
,
lc
,
1
)
factory
.
addPoint
(.
1
,
0
,
0
,
lc
,
2
)
factory
.
addPoint
(.
1
,
0
,
0
,
lc
,
2
)
factory
.
addPoint
(.
1
,
.
3
,
0
,
lc
,
3
)
factory
.
addPoint
(.
1
,
.
3
,
0
,
lc
,
3
)
factory
.
addPoint
(
0
,
.
3
,
0
,
lc
,
4
)
factory
.
addPoint
(
0
,
.
3
,
0
,
lc
,
4
)
factory
.
addLine
(
1
,
2
,
1
)
factory
.
addLine
(
1
,
2
,
1
)
factory
.
addLine
(
3
,
2
,
2
)
factory
.
addLine
(
3
,
2
,
2
)
factory
.
addLine
(
3
,
4
,
3
)
factory
.
addLine
(
3
,
4
,
3
)
factory
.
addLine
(
4
,
1
,
4
)
factory
.
addLine
(
4
,
1
,
4
)
factory
.
addCurveLoop
([
4
,
1
,
-
2
,
3
],
1
)
factory
.
addCurveLoop
([
4
,
1
,
-
2
,
3
],
1
)
factory
.
addPlaneSurface
([
1
],
1
)
factory
.
addPlaneSurface
([
1
],
1
)
model
.
addPhysicalGroup
(
0
,
[
1
,
2
],
1
)
model
.
addPhysicalGroup
(
0
,
[
1
,
2
],
1
)
model
.
addPhysicalGroup
(
1
,
[
1
,
2
],
2
)
model
.
addPhysicalGroup
(
1
,
[
1
,
2
],
2
)
model
.
addPhysicalGroup
(
2
,
[
1
],
6
)
model
.
addPhysicalGroup
(
2
,
[
1
],
6
)
model
.
setPhysicalName
(
2
,
6
,
"
My surface
"
)
model
.
setPhysicalName
(
2
,
6
,
"
My surface
"
)
# ...end of copy
model
.
geo
.
synchronize
()
factory
.
synchronize
()
# }}}
# -- begin t8.py --
# add post-processing views to work on
# add post-processing views to work on
gmsh
.
merge
(
"
view1.pos
"
)
gmsh
.
merge
(
"
view1.pos
"
)
...
@@ -164,10 +158,11 @@ for num in range(1, 4):
...
@@ -164,10 +158,11 @@ for num in range(1, 4):
# write out the graphics scene to an image file
# write out the graphics scene to an image file
# Gmsh will try to detect the file extension
# Gmsh will try to detect the file extension
if
num
==
3
:
gmsh
.
write
(
"
t2-{:.2g}.gif
"
.
format
(
num2
))
# if num == 3:
gmsh
.
write
(
"
t2-{:.2g}.ppm
"
.
format
(
num2
))
# gmsh.write("t2-{:.2g}.gif".format(num2))
gmsh
.
write
(
"
t2-{:.2g}.jpg
"
.
format
(
num2
))
# gmsh.write("t2-{:.2g}.ppm".format(num2))
# gmsh.write("t2-{:.2g}.jpg".format(num2))
if
num
==
3
:
if
num
==
3
:
pass
pass
...
...
This diff is collapsed.
Click to expand it.
demos/api/t9.py
+
1
−
1
View file @
0ece73dd
...
@@ -32,7 +32,7 @@ plugin.run("CutPlane")
...
@@ -32,7 +32,7 @@ plugin.run("CutPlane")
# Third is Annotate
# Third is Annotate
plugin
.
setString
(
"
Annotate
"
,
"
Text
"
,
"
A nice title
"
)
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
"
,
"
X
"
,
1.e5
)
plugin
.
setNumber
(
"
Annotate
"
,
"
Y
"
,
50
)
plugin
.
setNumber
(
"
Annotate
"
,
"
Y
"
,
50
)
plugin
.
setString
(
"
Annotate
"
,
"
Font
"
,
"
Times-BoldItalic
"
)
plugin
.
setString
(
"
Annotate
"
,
"
Font
"
,
"
Times-BoldItalic
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment