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
Model registry
Operate
Environments
Monitor
Incidents
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
Larry Price
gmsh
Commits
64b70a24
Commit
64b70a24
authored
11 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
python client should use its name when querying for Action
parent
77623588
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
contrib/onelab/python/onelab.py
+1
-1
1 addition, 1 deletion
contrib/onelab/python/onelab.py
utils/solvers/python/pend.py
+15
-7
15 additions, 7 deletions
utils/solvers/python/pend.py
with
16 additions
and
8 deletions
contrib/onelab/python/onelab.py
+
1
−
1
View file @
64b70a24
...
...
@@ -346,7 +346,7 @@ class client :
self
.
addr
=
sys
.
argv
[
i
+
2
]
self
.
_createSocket
()
self
.
_send
(
self
.
_GMSH_START
,
str
(
os
.
getpid
()))
self
.
action
=
self
.
getString
(
'
python
/Action
'
)
self
.
action
=
self
.
getString
(
self
.
name
+
'
/Action
'
)
self
.
setNumber
(
'
IsPyMetamodel
'
,
value
=
1
,
visible
=
0
)
if
self
.
action
==
"
initialize
"
:
exit
(
0
)
...
...
This diff is collapsed.
Click to expand it.
utils/solvers/python/pend.py
+
15
−
7
View file @
64b70a24
#!/usr/bin/env python
#coding=utf-8
# 1) launch "gmsh pend.py"
# 2) there is no 2... :-)
import
onelab
import
math
,
os
...
...
@@ -32,7 +35,7 @@ g = 9.8 # acceleration of gravity
m
=
0.3
# mass of pendulum balls
l
=
OL
.
defineNumber
(
'
Geom/Length
'
,
value
=
1.0
,
label
=
'
Arm length [m]
'
)
time
=
OL
.
defineNumber
(
'
Dyna/time
'
,
label
=
'
time [s]
'
)
time
=
OL
.
defineNumber
(
'
Dyna/time
'
,
value
=
0.0
,
label
=
'
time [s]
'
)
dt
=
OL
.
defineNumber
(
'
Dyna/dt
'
,
value
=
0.001
,
label
=
'
time step [s]
'
)
tmax
=
OL
.
defineNumber
(
'
Dyna/tmax
'
,
value
=
20
,
label
=
'
max time [s]
'
)
refresh
=
OL
.
defineNumber
(
'
Dyna/refresh
'
,
value
=
0.05
,
label
=
'
refresh interval [s]
'
)
...
...
@@ -53,9 +56,9 @@ theta = theta0 / 180.*math.pi;
phi
=
phi0
/
180.
*
math
.
pi
;
theta_dot
=
0.0
phi_dot
=
0.0
time
=
0.0
refr
=
0.0
iter
=
0
time
=
0.0
while
(
time
<
tmax
):
delta
=
phi
-
theta
...
...
@@ -91,25 +94,30 @@ while (time < tmax):
if
refr
>=
refresh
:
refr
=
0
OL
.
setNumber
(
'
python
/Progress
'
,
value
=
time
,
min
=
0
,
max
=
tmax
,
visible
=
0
)
OL
.
setNumber
(
OL
.
name
+
'
/Progress
'
,
value
=
time
,
min
=
0
,
max
=
tmax
,
visible
=
0
)
OL
.
setNumber
(
'
Dyna/time
'
,
value
=
time
)
OL
.
setNumber
(
'
Solu/phi
'
,
value
=
phi
)
OL
.
setNumber
(
'
Solu/theta
'
,
value
=
theta
)
OL
.
addNumberChoice
(
'
Solu/phi
'
,
phi
)
OL
.
setNumber
(
'
Solu/theta
'
,
value
=
theta
)
OL
.
addNumberChoice
(
'
Solu/theta
'
,
theta
)
OL
.
setNumber
(
'
Solu/phi_dot
'
,
value
=
phi_dot
)
OL
.
setNumber
(
'
Solu/theta_dot
'
,
value
=
theta_dot
)
OL
.
addNumberChoice
(
'
Solu/phi_dot
'
,
phi_dot
)
OL
.
setNumber
(
'
Solu/theta_dot
'
,
value
=
theta_dot
)
OL
.
addNumberChoice
(
'
Solu/theta_dot
'
,
theta_dot
)
# ask Gmsh to refresh
OL
.
setString
(
'
Gmsh/Action
'
,
value
=
'
refresh
'
)
if
(
OL
.
getString
(
'
python/Action
'
)
==
'
stop
'
):
# stop if we are asked to (by Gmsh)
if
(
OL
.
getString
(
OL
.
name
+
'
/Action
'
)
==
'
stop
'
):
break
;
exportMsh
(
l1
,
l2
)
exportIter
(
iter
,
time
,
x1
,
y1
+
l1
,
x2
,
y2
+
l1
+
l2
)
OL
.
mergeFile
(
onelab
.
path
(
__file__
,
'
pend.msh
'
))
iter
+=
1
OL
.
setNumber
(
'
python
/Progress
'
,
value
=
0
)
OL
.
setNumber
(
OL
.
name
+
'
/Progress
'
,
value
=
0
)
# comment the following lines out if you do not have gnuplot on your system
# OL.preProcess(onelab.path(__file__,'pend.plt.ol'))
...
...
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