You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have some more tutorial examples in this package, especially because the Gmsh API docs are so minimal.
For example, one common desire is to be able to use .geo files, but to programmatically set parameters from Julia, so that you get some of the ease-of-use of the gmsh GUI but the flexibility of a programmatic interface. It turns out that this is possible, but it took me a while to figure out.
The trick to using a "foo.geo" from Julia is to do something like:
which behaves exactly as if you had translated each line of "foo.geo" into Julia and pasted the translation right at the point where you ran parse("foo.geo").
The powerful thing here is that you can also set variables programmatically from within Julia. Suppose we have a variable lc as in the t1.geo tutorial file. The trick is to define your .geo variables with DefineConstant — for example, in the t1.geo file, do:
DefineConstant[ lc = 1e-2 ];
Then you can override the value of lc by either the -setnumber command-line option or by the equivalent in the Julia API:
By the way, it might also be nice to have a setNumber(name, val::Real) = set_number(name, Float64[val]) method, for convenience in setting scalar variables.
(For some reason, the API defines a synonym const set_number = setNumber, but it seems less confusing to stick with setNumber to match the gmsh API docs, even if it isn't very Julian? Especially since the docstring for set_number refers to setNumber.)
The gmsh setString API is even more painful from Julia because it expects an array of Ptr{Cchar}. It would be make it a lot easier to use if you defined setString(name, ::AbstractVector{<:AbstractString}) and setString(name, ::AbstractString) higher-level methods.
It would be nice to have some more tutorial examples in this package, especially because the Gmsh API docs are so minimal.
For example, one common desire is to be able to use
.geo
files, but to programmatically set parameters from Julia, so that you get some of the ease-of-use of the gmsh GUI but the flexibility of a programmatic interface. It turns out that this is possible, but it took me a while to figure out.The trick to using a
"foo.geo"
from Julia is to do something like:which behaves exactly as if you had translated each line of
"foo.geo"
into Julia and pasted the translation right at the point where you ranparse("foo.geo")
.The powerful thing here is that you can also set variables programmatically from within Julia. Suppose we have a variable
lc
as in thet1.geo
tutorial file. The trick is to define your.geo
variables withDefineConstant
— for example, in thet1.geo
file, do:Then you can override the value of
lc
by either the-setnumber
command-line option or by the equivalent in the Julia API:The text was updated successfully, but these errors were encountered: