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

Annotation of /branches/split/test.py

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26