Skip to content

Instantly share code, notes, and snippets.

@wd15
Created March 21, 2014 19:10
Show Gist options
  • Save wd15/9693712 to your computer and use it in GitHub Desktop.
Save wd15/9693712 to your computer and use it in GitHub Desktop.
Workaround for FiPy ticket 668 http://matforge.org/fipy/ticket/668
#!/usr/bin/env python
import fipy as fp
import sys
from subprocess import Popen, PIPE
mshFile = 'tmsh3d.msh'
if fp.parallelComm.procID == 0:
dimensions = 3
geoFile = 'tmsh3d.geo'
gmshFlags = ["-%d" % dimensions, "-nopopup"]
gmshFlags += ["-part", "%d" % fp.parallelComm.Nproc]
gmshFlags += ["-format", "msh"]
p = Popen(["gmsh", geoFile] + gmshFlags + ["-o", mshFile],
stdout=PIPE)
p.wait()
fp.parallelComm.Barrier()
mesh = fp.Gmsh3D(mshFile)
print 'mesh from Geo done'
sys.stdout.flush()
mx,my,mz = mesh.getCellCenters()
print '3D mesh set up'
sys.stdout.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment