551days since
Proposal Due Date

Recent site activity

Project Updates‎ > ‎

Python-wrapped GridGen Routines Available for Download

posted Oct 5, 2010 2:33 PM by Domain Admin

Bob Jackson's GridGen routines have been successfully wrapped for use with python code. A tarball (PyGridGen-dist.tgz) has been uploaded to the FieldMarshal.org website.

The files that comprise the python tool CB2.py, derived from
Robert Jackson's CreateBoundary program, can now be found here.  Bob's code
was originally written
in fortran77 and the files used from that project are almost completely
unchanged here.  The only exceptions are:

        PlotMeshPoints.f: changed the calling parameters so that
                I could pass in the names of the input and output
                files.

        InitIO.f: created this file so that I could pass input/output
                file names in from the command line, rather than just
                use the hard-coded file names found in the original
                code.

        I_O.INC: added BOUNDARY and CRV_FILE, again, so that I could
                pass file names in as arguments, rather than leave them
                hard-coded as they were in the original code.

        CreateBoundary.f: not used.  However, a python version of this can
                be found in CreateBoundary.py.  I wrote this as an interrim
                step in creating CB2.py.  CreateBoundary.py allowed me
                to test the importation of the wrapped fortran77 code,
                as well as verify that CB2.py worked correctly.  NOTE:
                as of this writing there are STILL precision differences
                between the pure fortran77 and the ftn/python code.
                Notwithstanding these, both programs should produce
                nearly identical drawings.

If you have f2py installed on  your system, you can make the module with
this command:

        f2py -c PyGridGen.pyf *.f

This will create PyGridGen.so, a linux binary of which I've included in
this tarball, just in case you have neither f2py nor f77 installed.

I've included a sample input file derived from the original inputs in
GridGen/CreateBoundary. This can be found in testdata.txt.  Each record
is a comma-separated set of values that all start with the type, label,
and tag for each element.  The remaining fields vary depending on the
type.  Null values are simply omitted, but the field delimiter (comma)
must still be present.  To represent the "str_p2" values -- essentially
last point plotted -- I've adopted a notation that uses @1 and @2 mnemonics
to represent str_p2[1] and str_p2[2] (last x and last y, respectively).
Plot point values may be integer or floating point constants, @1, @2, or
expressions involving any of these.  For example, take a look at the
element definititon for Focus Electrode-6.

To run the program and produce some output, use

        python CB2.py -o 'Bound.pts', -c 'Bound.lns', -s 'Bound.scr' \

This will create PyGridGen.so, a linux binary of which I've included in
this tarball, just in case you have neither f2py nor f77 installed.

I've included a sample input file derived from the original inputs in
GridGen/CreateBoundary. This can be found in testdata.txt.  Each record
is a comma-separated set of values that all start with the type, label,
and tag for each element.  The remaining fields vary depending on the
type.  Null values are simply omitted, but the field delimiter (comma)
must still be present.  To represent the "str_p2" values -- essentially
last point plotted -- I've adopted a notation that uses @1 and @2 mnemonics
to represent str_p2[1] and str_p2[2] (last x and last y, respectively).
Plot point values may be integer or floating point constants, @1, @2, or
expressions involving any of these.  For example, take a look at the
element definititon for Focus Electrode-6.

To run the program and produce some output, use

        python CB2.py -o 'Bound.pts', -c 'Bound.lns', -s 'Bound.scr' \
                testdata.txt

For other options, refer to the comment header in CB2.py

Originally posted by Michael McLay last modified Mar 30, 2005 11:24 AM