/[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 155 - (show annotations)
Wed Nov 9 02:02:19 2005 UTC (13 years, 11 months ago) by jgs
File MIME type: text/x-python
File size: 2186 byte(s)
move all directories from trunk/esys2 into trunk and remove esys2

1 # $Id$
2
3 from esys.escript import *
4 from esys.escript.pdetools import Locator,Projector
5 from esys.finley import Rectangle
6
7 def testLocator(domain):
8 """runs a few test of the Locator"""
9
10 error_max=0.
11 error_text=""
12 x=domain.getX()
13 l=Locator(domain,[1.,1.])
14 print l.getFunctionSpace()
15 print l.getId()
16
17 l=Locator(ContinuousFunction(domain),[1.,1.])
18 print l.getFunctionSpace()
19 print l.getId()
20
21 text="l.getX()"
22 err=Lsup(l.getX()-numarray.ones((2,)))
23 print text," error = ",err
24 if err>=error_max: error_max,error_text=err,text
25
26 text="l(x)"
27 err=Lsup(l(x)-numarray.ones((2,)))
28 print text," error = ",err
29 if err>=error_max: error_max,error_text=err,text
30
31 text="l(x[0]+x[1])"
32 err=abs(l(x[0]+x[1])-2.)
33 print text," error = ",err
34 if err>=error_max: error_max,error_text=err,text
35
36 return error_max,error_text
37
38 def testProjector(domain):
39 """runs a few test of the Projector factory and returns the largest error plus a description of the test this error occured"""
40 error_max=0.
41 error_text=""
42 x=ContinuousFunction(domain).getX()
43 for f in [True,False]:
44 p=Projector(domain,reduce=False,fast=f)
45 for r in range(5):
46 text="range %s , fast=%s"%(r,f)
47 if r==0:
48 td_ref=x[0]
49 elif r==1:
50 td_ref=x
51 elif r==2:
52 td_ref=[[11.,12.],[21,22.]]*(x[0]+x[1])
53 elif r==3:
54 td_ref=[[[111.,112.],[121,122.]],[[211.,212.],[221,222.]]]*(x[0]+x[1])
55 elif r==3:
56 td_ref=[[[[1111.,1112.],[1121,1122.]],[[1211.,1212.],[1221,1222.]]],[[[2111.,2112.],[2121,2122.]],[[2211.,2212.],[2221,2222.]]]]*(x[0]+x[1])
57 td=p(td_ref.interpolate(Function(domain)))
58 er=Lsup(td-td_ref)/Lsup(td_ref)
59 print text," error = ",er
60 if er>error_max:
61 error_max=er
62 error_text=text
63 return error_max,error_text
64
65
66 txt=testLocator(Rectangle(56,61))
67 print "test Locator: ",txt
68
69 txt=testProjector(Rectangle(56,61))
70 print "test Projector: ",txt
71
72
73

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26