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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6651 - (show annotations)
Wed Feb 7 02:12:08 2018 UTC (20 months, 2 weeks ago) by jfenwick
File MIME type: text/x-python
File size: 3036 byte(s)
Make everyone sad by touching all the files

Copyright dates update

1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2018 by The University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Apache License, version 2.0
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 from __future__ import print_function, division
18
19 __copyright__="""Copyright (c) 2003-2018 by The University of Queensland
20 http://www.uq.edu.au
21 Primary Business: Queensland, Australia"""
22 __license__="""Licensed under the Apache License, version 2.0
23 http://www.apache.org/licenses/LICENSE-2.0"""
24 __url__="https://launchpad.net/escript-finley"
25
26 from esys.escript import *
27 from esys.escript.linearPDEs import LinearPDE, TransportPDE
28 from esys.finley import Rectangle
29 from esys.weipa import saveVTK
30
31 # dom=Rectangle(12,8,l0=1.5)
32 # dom=Rectangle(24,16,l0=1.5)
33 dom=Rectangle(48,32,l0=1.5)
34 saveDataCSV("t.csv",x=dom.getX(), rho=length(dom.getX()))
35 1/0
36 # dom=Rectangle(8*48,8*32,l0=1.5)
37 # dom=Rectangle(120,80,l0=1.5)
38 V=Scalar(1.,Function(dom))*[-1.,0]
39 THETA=0.
40 fc=TransportPDE(dom,num_equations=1,theta=THETA)
41 fc.setTolerance(1.e-12)
42 fc.setValue(M=Scalar(1.,Function(dom)),C=V)
43 x=dom.getX()
44 x_0=[0.5,0.5]
45 sigma=0.075
46 u0=1.
47 for i in range(dom.getDim()):
48 u0=u0*exp(-(x[i]-x_0[i])**2/sigma**2)
49
50 u0=whereNonPositive(abs(x[0]-0.4)-0.2)*whereNonPositive(abs(x[1]-0.5)-0.2)
51 # f1=0.5
52 # f2=2.
53 # u0=f2*clip(x[0]-0.5,0.)-clip(0.5-x[0],0.)*f1+f1*0.5
54 # u0=exp(-3*(x[0]-2.)**2)
55 # u0=x[0]
56 u0/=Lsup(u0)
57 c=0
58 saveVTK("u.%s.vtu"%c,u=u0)
59 fc.setInitialSolution(u0)
60
61 t_end=0.6
62 dt=2.49999e-2*0+6.2499999e-02/4
63 dt_out=2.49999e-2*0+6.2499999e-02/4
64 c_stop=1
65 n_out=int(t_end/dt+0.5)
66 print(n_out)
67 t=0.
68 t_out=0
69 c_out=0
70 c=0
71 print(t,": range u",inf(u0),sup(u0),integrate(u0,Function(dom)))
72 while t<t_end and c< c_stop:
73 print("time step t=",t+dt)
74 u=fc.solve(dt)
75 print(t+dt,": range u",inf(u),sup(u),integrate(u,Function(dom)))
76 c+=1
77 t+=dt
78 if t>=t_out+dt_out:
79 c_out,t_out=c_out+1,t_out+dt_out
80 saveVTK("u.%s.vtu"%c_out,u=u)
81 print("write time step ",c,"(t=%s) to file u.%s.vtu"%(t,c_out))
82
83 if True:
84 pde=LinearPDE(dom)
85 pde.setValue(D=1.,C=-THETA*dt*V)
86 pde.setTolerance(1e-12)
87 t=0.
88 t_out=0
89 c_out=0
90 c=0
91 u=u0
92 print(t,": range u2",inf(u0),sup(u0),integrate(u0,Function(dom)))
93 while t<t_end and c< c_stop:
94 print("time step t=",t+dt)
95 pde.setValue(Y=u+(1.-THETA)*dt*inner(V,grad(u)))
96 u=pde.getSolution(verbose=True)
97 print(t+dt,": range u2",inf(u),sup(u),integrate(u,Function(dom)))
98 c+=1
99 t+=dt
100 if t>=t_out+dt_out:
101 c_out,t_out=c_out+1,t_out+dt_out
102 saveVTK("u2.%s.vtu"%c_out,u=u)
103 print("write time step ",c,"(t=%s) to file u2.%s.vtu"%(t,c_out))

  ViewVC Help
Powered by ViewVC 1.1.26