# Contents of /trunk/finley/test/python/FCT_test1.py

Revision 1411 - (show annotations)
Thu Feb 7 08:09:15 2008 UTC (11 years, 6 months ago) by gross
File MIME type: text/x-python
File size: 2665 byte(s)
```second test for upwinding added
```
 1 # 2 # upwinding test moving a Gaussian hill around 3 # 4 # we solve U_,t + v_i u_,i =0 5 # 6 # the solution is given as u(x,t)=1/(4*pi*E*t)^{dim/2} * exp ( - |x-x_0(t)|^2/(4*E*t) ) 7 # 8 # where x_0(t) = [ cos(OMEGA0*T0)*0.5,-sin(OMEGA0*T0)*0.5 ] and v=[-y,x]*OMEGA0 for dim=2 and 9 # 10 # x_0(t) = [ cos(OMEGA0*T0)*0.5,-sin(OMEGA0*T0)*0.5 ] and v=[-y,x]*OMEGA0 for dim=3 11 # 12 # the solution is started from some time T0>0. 13 # 14 # We are using five quality messurements for u_h 15 # 16 # - inf(u_h) > 0 17 # - sup(u_h)/sup(u(x,t)) = sup(u_h)*(4*pi*E*t)^{dim/2} ~ 1 18 # - integrate(u_h) ~ 1 19 # - | x_0h-x_0 | ~ 0 where x_0h = integrate(x*u_h) 20 # - sigma_h/4*E*t ~ 1 where sigma_h=sqrt(integrate(length(x-x0h)**2 * u_h) * (DIM==3 ? sqrt(2./3.) :1 ) 21 # 22 # 23 from esys.escript import * 24 from esys.escript.linearPDEs import LinearSinglePDE, TransportPDE 25 from esys.finley import Rectangle, Brick 26 from math import pi, ceil 27 NE=128 28 DIM=2 29 THETA=0.5 30 OMEGA0=1. 31 ALPHA=pi/4 32 T0=0 33 T_END=2.*pi 34 dt=1e-3*10*10 35 E=1.e-3 36 TEST_SUPG=False or True 37 38 39 if DIM==2: 40 dom=Rectangle(NE,NE) 41 else: 42 dom=Brick(NE,NE,NE) 43 dom.setX(2*dom.getX()-1) 44 45 # set initial value 46 x=dom.getX() 47 r=sqrt(x[0]**2+(x[1]-1./3.)**2) 48 u0=whereNegative(r-1./3.)*wherePositive(wherePositive(abs(x[0])-0.05)+wherePositive(x[1]-0.5)) 49 50 x=Function(dom).getX() 51 if DIM == 2: 52 V=OMEGA0*(x[0]*[0,-1]+x[1]*[1,0]) 53 else: 54 V=OMEGA0*(x[0]*[0,cos(ALPHA),0]+x[1]*[-cos(ALPHA),0,sin(ALPHA)]+x[2]*[0.,-sin(ALPHA),0.]) 55 #=================== 56 fc=TransportPDE(dom,num_equations=1,theta=THETA) 57 x=Function(dom).getX() 58 fc.setValue(M=Scalar(1.,Function(dom)),C=V) 59 #============== 60 if TEST_SUPG: 61 supg=LinearSinglePDE(dom) 62 supg.setValue(D=1.) 63 supg.setSolverMethod(supg.LUMPING) 64 dt_supg=inf(dom.getSize()/length(V)) 65 u_supg=u0*1. 66 67 c=0 68 saveVTK("u.%s.xml"%c,u=u0) 69 fc.setInitialSolution(u0) 70 t=T0 71 print "QUALITY FCT: time = %s pi"%(t/pi),inf(u0),sup(u0),integrate(u0) 72 while t