1 |
|
2 |
############################################################################## |
3 |
# |
4 |
# Copyright (c) 2003-2012 by University of Queensland |
5 |
# http://www.uq.edu.au |
6 |
# |
7 |
# Primary Business: Queensland, Australia |
8 |
# Licensed under the Open Software License version 3.0 |
9 |
# http://www.opensource.org/licenses/osl-3.0.php |
10 |
# |
11 |
# Development until 2012 by Earth Systems Science Computational Center (ESSCC) |
12 |
# Development since 2012 by School of Earth Sciences |
13 |
# |
14 |
############################################################################## |
15 |
|
16 |
__copyright__="""Copyright (c) 2003-2012 by University of Queensland |
17 |
http://www.uq.edu.au |
18 |
Primary Business: Queensland, Australia""" |
19 |
__license__="""Licensed under the Open Software License version 3.0 |
20 |
http://www.opensource.org/licenses/osl-3.0.php""" |
21 |
__url__="https://launchpad.net/escript-finley" |
22 |
|
23 |
from esys.escript import * |
24 |
from esys.escript.linearPDEs import TransportPDE |
25 |
from esys.finley import Rectangle, Brick |
26 |
#from esys.ripley import Rectangle, Brick |
27 |
from esys.weipa import saveVTK |
28 |
from math import pi, ceil |
29 |
|
30 |
NE=50 |
31 |
dom=Rectangle(NE,1,l1=1./NE) |
32 |
dom=Rectangle(NE,NE) |
33 |
fc=TransportPDE(dom,numEquations=1) |
34 |
fc.getSolverOptions().setVerbosityOn() |
35 |
fc.getSolverOptions().setODESolver(fc.getSolverOptions().LINEAR_CRANK_NICOLSON) |
36 |
fc.getSolverOptions().setODESolver(fc.getSolverOptions().BACKWARD_EULER) |
37 |
fc.getSolverOptions().setODESolver(fc.getSolverOptions().CRANK_NICOLSON) |
38 |
fc.setValue(M=1,C=[-1,0]) |
39 |
x=dom.getX() |
40 |
u0=whereNegative(x[0]-1./NE) |
41 |
|
42 |
c=0 |
43 |
t=0 |
44 |
|
45 |
saveVTK("u.%s.vtu"%c,u=u0) |
46 |
fc.setInitialSolution(u0) |
47 |
dt=fc.getSafeTimeStepSize() |
48 |
|
49 |
print "u0 =",u0 |
50 |
T_END=dt |
51 |
print "dt = ",dt |
52 |
while t<T_END: |
53 |
print("time step t=",t+dt) |
54 |
u=fc.getSolution(dt) |
55 |
saveVTK("u.%s.vtu"%(c+1,),u=u) |
56 |
print "u =",u |
57 |
c+=1 |
58 |
t+=dt |