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

Contents of /branches/split/test.py

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26