Open daniellivingston opened 3 years ago
@dharp Thoughts?
Nice plan, Daniel! I know we had talked about this in the past, but this is a much more well-thought-out plan than we had back then. You've obviously thought this through some more. Seems like it could be doable and would be a huge advance beyond the current pylagrit. Also, I really like how you've laid it out to use the existing pylagrit methods. Very elegant!
Right now, PyLaGriT uses
pexpect
to launch LaGriT a child process, constructs LaGriT commands as strings (i.e.,lg.create()
->cmo/create/mo1
), and haspexpect
send that string viastdin
to the LaGriT child process.This is a great approach but suffers the flaw that all data structures (x, y, z arrays of nodes, connectivity arrays, etc.) are inaccessible from Python. The only workaround is to dump the mesh object to a file and then to read the file in.
By compiling LaGriT as a library (Instead of an executable) and by using CTypes, we can directly call LaGriT functions from Python code.
Now, LaGriT source has a subroutine called
do_task(char *string)
, which performs effectively whatpexpect
does above: takes in a LaGriT command string and runs it.So, critically, almost no modification of PyLaGriT will be needed. The
sendline()
method just changes from callingpexpect
to callingdo_task()
.A huge benefit of this will be the direct access (read and write) of internal LaGriT data structures. This would allow:
and much more...
The LaGriT subroutine
cmo_get_info
exposes pointers to these data structures.So, mockup code might be: