/[escript]/trunk/doc/examples/usersguide/mount.py
ViewVC logotype

Contents of /trunk/doc/examples/usersguide/mount.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2211 - (show annotations)
Tue Jan 13 03:52:13 2009 UTC (10 years, 1 month ago) by artak
Original Path: trunk/doc/examples/mount.py
File MIME type: text/x-python
File size: 1233 byte(s)
Example of a usage of Mountains class.
1 from esys.escript import *
2 from esys.escript.models import Mountains
3 from esys.finley import Brick,Rectangle
4 from math import pi, ceil
5
6 NE=16
7 DIM=3
8 H=1.
9 L=1*H
10 TOL=1.e-4
11 OMEGA=10
12 EPS=0.01
13 t=0
14 T_END=(2*pi)/OMEGA
15 n=0
16 if DIM==2:
17 mydomain=Rectangle(int(ceil(L*NE/H)),NE,l0=L,l1=H,order=1, useFullElementOrder=True,optimize=True)
18 else:
19 mydomain=Brick(int(ceil(L*NE/H)),int(ceil(L*NE/H)),NE,l0=L,l1=L,l2=H,order=1, useFullElementOrder=True,optimize=True)
20 x=mydomain.getX()
21 v = Vector(0.0, Solution(mydomain))
22 if DIM==2:
23 a0=1
24 n0=1
25 n1=0.5
26 a1=-(a0*n0)/n1
27 v[0]=a0*sin(pi*n0*x[0])* cos(pi*n1*x[1])
28 v[1]=a1*cos(pi*n0*x[0])* sin(pi*n1*x[1])
29 else:
30 a0=1
31 a1=1
32 n0=2
33 n1=2
34 n2=0.5
35 a2=-(a0*n0+a1*n1)/n2
36 v[0]=a0*sin(pi*n0*x[0])* cos(pi*n1*x[1])* cos(pi*n2*x[2])
37 v[1]=a1*cos(pi*n0*x[0])* sin(pi*n1*x[1])* cos(pi*n2*x[2])
38 v[2]=a2*cos(pi*n0*x[0])* cos(pi*n1*x[1])* sin(pi*n2*x[2])
39
40
41 H_t=Scalar(0.0, Solution(mydomain))
42 mts=Mountains(mydomain,v,eps=EPS,z=H)
43 dt=0.
44 while t<T_END:
45 print "STEP ", t
46 u=v*cos(OMEGA*t)
47 u,Z=mts.update(u=u,H_t=H_t)
48
49 saveVTK("state.%d.vtu"%n,sol=Z)
50 print "Integral(Z)=",integrate(Z),Lsup(u[DIM-1])
51 n+=1
52 H_t=Z
53 dt=mts.getDt()
54 t+=dt
55

  ViewVC Help
Powered by ViewVC 1.1.26