/[escript]/branches/symbolic_from_3470/dudley/test/python/blocktest.py
ViewVC logotype

Contents of /branches/symbolic_from_3470/dudley/test/python/blocktest.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3789 - (show annotations)
Tue Jan 31 04:55:05 2012 UTC (7 years, 2 months ago) by caltinay
File MIME type: text/x-python
File size: 3367 byte(s)
Fast forward to latest trunk revision 3788.

1 #
2 # this script is testing block solvers for PDEs
3 #
4 #
5 # - u_{j,ii} + b*u_j+ a*sum_{k<>j} (u_j-u_k) = F_j
6 #
7 # where a controls the degree of coupling and b the degree of diagonal dominance.
8 # a and b may have any value.
9 #
10 # The domain needs to be a unit square or cube with any type of mesh
11 #
12 #
13 ########################################################
14 #
15 # Copyright (c) 2003-2010 by University of Queensland
16 # Earth Systems Science Computational Center (ESSCC)
17 # http://www.uq.edu.au/esscc
18 #
19 # Primary Business: Queensland, Australia
20 # Licensed under the Open Software License version 3.0
21 # http://www.opensource.org/licenses/osl-3.0.php
22 #
23 ########################################################
24
25 __copyright__="""Copyright (c) 2003-2010 by University of Queensland
26 Earth Systems Science Computational Center (ESSCC)
27 http://www.uq.edu.au/esscc
28 Primary Business: Queensland, Australia"""
29 __license__="""Licensed under the Open Software License version 3.0
30 http://www.opensource.org/licenses/osl-3.0.php"""
31 __url__="https://launchpad.net/escript-finley"
32
33 from esys.escript import *
34 from esys.escript.linearPDEs import LinearPDE
35 import esys.dudley as dudley
36
37 TOL=1.e-8
38
39 def runTest(dom, n=1, a=0, b=0):
40 print("================== TEST : n= %s a=%s b=%s ================"%(n,a,b))
41 DIM=dom.getDim()
42 normal=dom.getNormal()
43 mypde=LinearPDE(dom, numEquations=n, numSolutions=n)
44 x=dom.getX()
45 A=mypde.createCoefficient("A")
46 D=mypde.createCoefficient("D")
47 Y=mypde.createCoefficient("Y")
48 y=mypde.createCoefficient("y")
49 q=mypde.createCoefficient("q")
50 if n==1:
51 u_ref=Scalar(0.,Solution(dom))
52 for j in range(DIM):
53 q+=whereZero(x[j])
54 A[j,j]=1
55 y+=sin(sqrt(2.))*normal[0]
56 Y+=b*x[0]*sin(sqrt(2.))
57 D+=b
58 u_ref=x[0]*sin(sqrt(2.))
59 else:
60 u_ref=Data(0.,(n,),Solution(dom))
61 for i in range(n):
62 for j in range(DIM):
63 q[i]+=whereZero(x[j])
64 A[i,j,i,j]=1
65 if j == i%DIM: y[i]+=sin(i+sqrt(2.))*normal[j]
66 for j in range(n):
67 if i==j:
68 D[i,i]=b+(n-1)*a
69 Y[i]+=b*x[i%DIM]*sin(i+sqrt(2.))
70 else:
71 D[i,j]=-a
72 Y[i]+=a*(x[i%DIM]*sin(i+sqrt(2.))-x[j%DIM]*sin(j+sqrt(2.)))
73 u_ref[i]=x[i%DIM]*sin(i+sqrt(2.))
74
75 # - u_{j,ii} + b*u_i+ a*sum_{k<>j} (u_i-u_k) = F_j
76
77 mypde.setValue(A=A, D=D, y=y, q=q, r=u_ref, Y=Y)
78 mypde.getSolverOptions().setVerbosityOn()
79 mypde.getSolverOptions().setTolerance(TOL)
80 mypde.setSymmetryOn()
81 u=mypde.getSolution()
82 error=Lsup(u-u_ref)/Lsup(u_ref)
83 print("error = ",error)
84 if error > 10*TOL: print("XXXXXXXXXX Error to large ! XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
85
86 domain=dudley.Rectangle(10,20,1,l0=1.,l1=1.0)
87 # or Brick or ReadMesh
88 runTest(dom=domain, n=1, b=0)
89 runTest(dom=domain, n=1, b=5)
90 runTest(dom=domain, n=1, b=50)
91
92 runTest(dom=domain, n=2, a=0, b=0)
93 runTest(dom=domain, n=2, a=5, b=0)
94 runTest(dom=domain, n=2, a=50, b=0)
95
96 runTest(dom=domain, n=2, a=0, b=10)
97 runTest(dom=domain, n=2, a=5, b=10)
98 runTest(dom=domain, n=2, a=50, b=10)
99
100 runTest(dom=domain, n=3, a=0, b=0)
101 runTest(dom=domain, n=3, a=5, b=0)
102 runTest(dom=domain, n=3, a=50, b=0)
103
104 runTest(dom=domain, n=3, a=0, b=10)
105 runTest(dom=domain, n=3, a=5, b=10)
106 runTest(dom=domain, n=3, a=50, b=10)

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26