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')
|
|
|
|
|
2011-03-30 20:37:12 -07:00
|
|
|
def work(inq, outq, g, myname):
|
2011-03-30 20:34:44 -07:00
|
|
|
outq.put((myname, "ready"))
|
|
|
|
|
|
|
|
while True:
|
|
|
|
i, o, e, X = inq.get()
|
|
|
|
if i == None:
|
2011-03-30 21:00:13 -07:00
|
|
|
return o
|
2011-03-30 20:34:44 -07:00
|
|
|
a = g.run_baker(X, order = o, extra_points = e)
|
|
|
|
outq.put((i, myname, a['qlin'], a['error'], a['final'], exact(X)))
|
|
|
|
|
2011-03-02 22:51:43 -08:00
|
|
|
|
|
|
|
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()
|
2011-03-30 20:34:44 -07:00
|
|
|
|
2011-03-30 09:36:20 -07:00
|
|
|
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
|
|
|
|
|
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 20:34:44 -07:00
|
|
|
myname = options.label
|
2011-03-30 21:00:13 -07:00
|
|
|
shutdown = False
|
|
|
|
while not shutdown:
|
|
|
|
shutdown = work(inq, outq, g, myname)
|