smbinterp/bin/slave.py

37 lines
852 B
Python

#!/usr/bin/env python
import sys
from multiprocessing.managers import BaseManager
import numpy as np
import interp.bootstrap
from interp.grid.gmsh import gmsh_grid3D
from interp.tools import exact
class QueueManager(BaseManager): pass
QueueManager.register('get_inqueue' )
QueueManager.register('get_outqueue')
if __name__ == '__main__':
if len(sys.argv) != 3:
print >> sys.stderr, "usage: %s <gmsh file> <id>" % sys.argv[0]
sys.exit(1)
m = QueueManager(address=('gannon', 50000), authkey='asdf')
m.connect()
inq = m.get_inqueue()
outq = m.get_outqueue()
g = gmsh_grid3D(sys.argv[1])
g.q = np.array([exact(x) for x in g.verts])
my_name = sys.argv[2]
while True:
i, X = inq.get()
a = g.run_baker(X, order = 3, extra_points = 32)
outq.put((i, my_name, a['qlin'], a['error'], a['final'], exact(X)))