/[escript]/trunk/finley/test/python/blocktest.py
ViewVC logotype

Contents of /trunk/finley/test/python/blocktest.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4657 - (show annotations)
Thu Feb 6 06:12:20 2014 UTC (5 years, 4 months ago) by jfenwick
File MIME type: text/x-python
File size: 3497 byte(s)
I changed some files.
Updated copyright notices, added GeoComp.



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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26