/[escript]/branches/split/test.py
ViewVC logotype

Contents of /branches/split/test.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4790 - (show annotations)
Fri Mar 21 01:46:38 2014 UTC (5 years ago) by jfenwick
File MIME type: text/x-python
File size: 1554 byte(s)
Subworld changes to dudley
1 from esys.escript import *
2 from esys.escriptcore.splitworld import *
3
4 from esys.finley import *
5 from esys.escript.linearPDEs import Poisson
6
7 sw=SplitWorld(getMPISizeWorld())
8 buildDomains(sw, Brick, 3, 3, 3 )
9 #buildDomains(sw, Rectangle, 3, 3)
10
11 class J1(Job):
12 def __init__(self, **kwargs):
13 super(J1,self).__init__(**kwargs)
14 print "Constructed with "+str(self.domain)+" and id="+str(self.jobid)
15 self.rounds=self.jobid+2
16 def work(self):
17 print str(self.jobid)+"is doing work "+str(self.rounds)
18 self.rounds-=1
19 return self.rounds<1
20
21 class BarrierJob(Job):
22 def __init__(self, **kwargs):
23 super(BarrierJob,self).__init__(**kwargs)
24 self.rounds=self.jobid+2
25
26 def work(self):
27 print str(self.jobid)+"is doing work "+str(self.rounds)
28 self.rounds-=1
29 #print self.domain.OnMasterProcessor()
30 #print self.domain.onMasterProcessor()
31 return self.rounds<1
32
33
34 class PoissonJob(Job):
35 def __init__(self, **kwargs):
36 super(PoissonJob, self).__init__(**kwargs)
37
38 def work(self):
39 x = self.domain.getX()
40 gammaD = whereZero(x[0])+whereZero(x[1])
41 # define PDE and get its solution u
42 mypde = Poisson(domain=self.domain)
43 mypde.setValue(f=self.jobid, q=gammaD)
44 u = mypde.getSolution()
45 print "Lsup solution=",Lsup(u)
46 return True
47
48 addJob(sw, J1)
49 addJob(sw, J1)
50 for z in range(10):
51 addJob(sw, J1)
52 addJob(sw, BarrierJob)
53 addJob(sw, PoissonJob)
54
55 try:
56 sw.runJobs()
57 except RuntimeError as e:
58 print e

  ViewVC Help
Powered by ViewVC 1.1.26