/[escript]/trunk/escript/test/python/pdetoolsTest.py
ViewVC logotype

Contents of /trunk/escript/test/python/pdetoolsTest.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 350 - (show annotations)
Tue Dec 13 09:11:52 2005 UTC (13 years, 10 months ago) by gross
File MIME type: text/x-python
File size: 2845 byte(s)
test for time integration manger added
1 # $Id$
2
3 from esys.escript import *
4 from esys.escript.pdetools import Locator,Projector,TimeIntegrationManager
5 from esys.finley import Rectangle
6
7 def testTimeIntegrationManager():
8 t=0.
9 dt=0.1
10 tm=TimeIntegrationManager(0.,p=1)
11 while t<1.:
12 t+=dt
13 tm.checkin(dt,t)
14 v_guess=tm.extrapolate(dt)
15 e=abs(v_guess-(tm.getTime()+dt))
16 error_max,error_text=e,"testTimeIntegrationManager: scalar"
17
18 t=0.
19 dt=0.3
20 tm=TimeIntegrationManager(0.,0.,p=1)
21 while t<1.:
22 t+=dt
23 tm.checkin(dt,t,3*t)
24 v_guess=tm.extrapolate(dt)
25 e=max(abs(v_guess[0]-(tm.getTime()+dt)),abs(v_guess[1]-(tm.getTime()+dt)*3.))
26 if e>error_max: error_max,error_text=e,"testTimeIntegrationManager: vector"
27
28 return error_max,error_text
29 def testLocator(domain):
30 """runs a few test of the Locator"""
31
32 error_max=0.
33 error_text=""
34 x=domain.getX()
35 l=Locator(domain,[1.,1.])
36 print l.getFunctionSpace()
37 print l.getId()
38
39 l=Locator(ContinuousFunction(domain),[1.,1.])
40 print l.getFunctionSpace()
41 print l.getId()
42
43 text="l.getX()"
44 err=Lsup(l.getX()-numarray.ones((2,)))
45 print text," error = ",err
46 if err>=error_max: error_max,error_text=err,text
47
48 text="l(x)"
49 err=Lsup(l(x)-numarray.ones((2,)))
50 print text," error = ",err
51 if err>=error_max: error_max,error_text=err,text
52
53 text="l(x[0]+x[1])"
54 err=abs(l(x[0]+x[1])-2.)
55 print text," error = ",err
56 if err>=error_max: error_max,error_text=err,text
57
58 return error_max,error_text
59
60 def testProjector(domain):
61 """runs a few test of the Projector factory and returns the largest error plus a description of the test this error occured"""
62 error_max=0.
63 error_text=""
64 x=ContinuousFunction(domain).getX()
65 for f in [True,False]:
66 p=Projector(domain,reduce=False,fast=f)
67 for r in range(5):
68 text="range %s , fast=%s"%(r,f)
69 if r==0:
70 td_ref=x[0]
71 elif r==1:
72 td_ref=x
73 elif r==2:
74 td_ref=[[11.,12.],[21,22.]]*(x[0]+x[1])
75 elif r==3:
76 td_ref=[[[111.,112.],[121,122.]],[[211.,212.],[221,222.]]]*(x[0]+x[1])
77 elif r==3:
78 td_ref=[[[[1111.,1112.],[1121,1122.]],[[1211.,1212.],[1221,1222.]]],[[[2111.,2112.],[2121,2122.]],[[2211.,2212.],[2221,2222.]]]]*(x[0]+x[1])
79 td=p(td_ref.interpolate(Function(domain)))
80 er=Lsup(td-td_ref)/Lsup(td_ref)
81 print text," error = ",er
82 if er>error_max:
83 error_max=er
84 error_text=text
85 return error_max,error_text
86
87
88 txt=testLocator(Rectangle(56,61))
89 print "test Locator: ",txt
90
91 txt=testProjector(Rectangle(56,61))
92 print "test Projector: ",txt
93
94 print testTimeIntegrationManager()

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26