2011-03-02 22:51:43 -08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from multiprocessing.managers import BaseManager
|
|
|
|
|
2011-03-30 09:36:20 -07:00
|
|
|
from optparse import OptionParser
|
|
|
|
|
2011-03-02 23:20:03 -08:00
|
|
|
import numpy as np
|
|
|
|
|
2011-03-02 22:51:43 -08:00
|
|
|
import interp.bootstrap
|
2011-03-30 09:36:20 -07:00
|
|
|
from interp.grid.gmsh import ggrid
|
|
|
|
from interp.tools import baker_exact_3D as exact
|
2011-03-02 22:51:43 -08:00
|
|
|
|
|
|
|
class QueueManager(BaseManager): pass
|
|
|
|
QueueManager.register('get_inqueue' )
|
|
|
|
QueueManager.register('get_outqueue')
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2011-03-30 09:36:20 -07:00
|
|
|
parser = OptionParser(usage = "usage: %s [options] <server> <gmsh file>")
|
|
|
|
|
|
|
|
parser.add_option('-l', '--label',
|
|
|
|
type="str", dest="label", default='jane',
|
|
|
|
help="specify this slave's response label (default: %default)")
|
|
|
|
|
|
|
|
parser.add_option('-p', '--port',
|
2011-03-30 18:45:47 -07:00
|
|
|
type="int", dest="port", default=6666,
|
2011-03-30 09:36:20 -07:00
|
|
|
help="specify the port to use on the server (default: %default)")
|
|
|
|
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
if len(args) != 2:
|
|
|
|
parser.print_usage()
|
2011-03-02 22:51:43 -08:00
|
|
|
sys.exit(1)
|
2011-03-30 09:36:20 -07:00
|
|
|
|
|
|
|
server, input_file = args
|
|
|
|
myname = options.label
|
|
|
|
|
2011-03-30 18:45:47 -07:00
|
|
|
m = QueueManager(address=(server, options.port), authkey='asdf')
|
2011-03-02 22:51:43 -08:00
|
|
|
m.connect()
|
|
|
|
|
|
|
|
inq = m.get_inqueue()
|
|
|
|
outq = m.get_outqueue()
|
|
|
|
|
2011-03-30 09:36:20 -07:00
|
|
|
g = ggrid(input_file)
|
2011-03-02 23:20:03 -08:00
|
|
|
g.q = np.array([exact(x) for x in g.verts])
|
|
|
|
|
2011-03-30 15:04:49 -07:00
|
|
|
outq.put((myname, "ready"))
|
2011-03-02 22:51:43 -08:00
|
|
|
|
|
|
|
while True:
|
2011-03-30 09:36:20 -07:00
|
|
|
i, o, e, X = inq.get()
|
|
|
|
if i == None:
|
|
|
|
break
|
|
|
|
a = g.run_baker(X, order = o, extra_points = e)
|
|
|
|
outq.put((i, myname, a['qlin'], a['error'], a['final'], exact(X)))
|
|
|
|
|
|
|
|
print "%s finished" % myname
|