2011/7/28 Neilen Marais <[email protected]>:
> Hi,
>
> I would like to read some of the variable values that I set in my .geo
> file into another (python) program. My program needs certain
> coordinates (such as where the source is located) that depends on
> variables defined in the .geo file. Is there a simple way of
> extracting the values of those variables from gmsh? I'd be happy to
> run gmsh and read values from stdout if neccesary.

There's the Printf command with the syntax

   Printf ( char-expression , expression-list ) > char-expression;

  http://geuz.org/gmsh/doc/texinfo/gmsh.html#General-commands

So calling the attached lc.geo from the shell with

  gmsh - lc.geo

you get the attached lc.py which I think is valid Python.

Another approach to this kind of problem (i.e. sharing parameter
values between Gmsh and other programs) is to generate the .geo input
file from a template by macro substitution.  That is, have a file
lc.geo.in with placeholders in it, run that through a macro-processor
like m4 <http://www.gnu.org/s/m4>, PYM
<http://ray.cg.tuwien.ac.at/rft/Papers/PYM/pym.html>, or use the
template string substitution from Python's standard library
<http://docs.python.org/library/string.html?highlight=template#string.Template.substitute>.

Attachment: lc.geo
Description: Binary data

lc = 0.1
_______________________________________________
gmsh mailing list
[email protected]
http://www.geuz.org/mailman/listinfo/gmsh

Reply via email to