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

Annotation of /trunk/doc/examples/usersguide/fluid.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5288 - (hide annotations)
Tue Dec 2 23:18:40 2014 UTC (4 years, 10 months ago) by sshaw
File MIME type: text/x-python
File size: 2864 byte(s)
fixing tests for cases where required domains not built
1 jfenwick 4853 from __future__ import division
2 jfenwick 4848 from __future__ import print_function
3 jfenwick 3981 ##############################################################################
4 jfenwick 2549 #
5 jfenwick 4657 # Copyright (c) 2008-2014 by University of Queensland
6 jfenwick 3981 # http://www.uq.edu.au
7 jfenwick 2549 #
8     # Primary Business: Queensland, Australia
9     # Licensed under the Open Software License version 3.0
10     # http://www.opensource.org/licenses/osl-3.0.php
11     #
12 jfenwick 3981 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
13 jfenwick 4657 # Development 2012-2013 by School of Earth Sciences
14     # Development from 2014 by Centre for Geoscience Computing (GeoComp)
15 jfenwick 3981 #
16     ##############################################################################
17 jfenwick 2549
18 lgraham 2191 ######## August 2008 ########
19     ########## Leon Graham ##########
20     ## Newtonian fluid using StokesProblemCartesian class##
21    
22     from esys.escript import *
23 sshaw 5288 try:
24     from esys.finley import Rectangle
25     HAVE_FINLEY = True
26     except ImportError:
27     HAVE_FINLEY = False
28 lgraham 2191 from esys.escript.linearPDEs import LinearPDE
29     from esys.escript.models import StokesProblemCartesian
30 caltinay 3346 from esys.weipa import saveVTK
31 sshaw 5288 if not HAVE_FINLEY:
32     print("Finley module not available")
33     else:
34     #physical constants
35     eta=1.0
36     rho=100.0
37     g=10.0
38 lgraham 2191
39 sshaw 5288 #solver settings
40     tolerance=1.0e-4
41     max_iter=200
42     t_end=50
43     t=0.0
44     time=0
45     verbose='TRUE'
46     useUzawa='TRUE'
47 lgraham 2191
48 sshaw 5288 #define mesh
49     H=2.0
50     L=1.0
51     W=1.0
52     mesh = esys.finley.Rectangle(l0=L, l1=H, order=-1, n0=20, n1=20, useElementsOnFace=0) # use linear macro elements for pressure
53     coordinates = mesh.getX()
54 lgraham 2191
55 sshaw 5288 #gravitational force
56     Y=Vector(0.0, Function(mesh))
57     Y[1]=-rho*g
58 lgraham 2191
59 sshaw 5288 #element spacing
60     h=Lsup(mesh.getSize())
61 lgraham 2191
62 sshaw 5288 #boundary conditions for slip at base
63     boundary_cond=whereZero(coordinates[1])*[0.0,1.0]+whereZero(coordinates[0])*[1.0,0.0]
64 lgraham 2191
65 sshaw 5288 #velocity and pressure vectors
66     velocity=Vector(0.0, Solution(mesh))
67     pressure=Scalar(0.0, ReducedSolution(mesh))
68 lgraham 2191
69 sshaw 5288 #Stokes Cartesian
70     solution=StokesProblemCartesian(mesh)
71     solution.setTolerance(tolerance)
72 lgraham 2191
73 sshaw 5288 while t <= t_end:
74 lgraham 2191
75 sshaw 5288 print(" ----- Time step = %s -----"%( t ))
76     print("Time = %s seconds"%( time ))
77    
78     solution.initialize(fixed_u_mask=boundary_cond,eta=eta,f=Y)
79     velocity,pressure=solution.solve(velocity,pressure,max_iter=max_iter,verbose=verbose,usePCG=True)
80    
81     print("Max velocity =", Lsup(velocity), "m/s")
82    
83     #Courant condition
84     dt=0.4*h/(Lsup(velocity))
85     print("dt", dt)
86    
87     #displace the mesh
88     displacement = velocity * dt
89     coordinates = mesh.getX()
90     newx=interpolate(coordinates + displacement, ContinuousFunction(mesh))
91     mesh.setX(newx)
92    
93     time += dt
94    
95     vel_mag = length(velocity)
96 lgraham 2191
97 sshaw 5288 #save velocity and pressure output
98     saveVTK("vel.%2.2i.vtu"%(t),vel=vel_mag,vec=velocity,pressure=pressure)
99     t = t+1.0

Properties

Name Value
svn:mergeinfo /branches/lapack2681/doc/examples/usersguide/fluid.py:2682-2741 /branches/pasowrap/doc/examples/usersguide/fluid.py:3661-3674 /branches/py3_attempt2/doc/examples/usersguide/fluid.py:3871-3891 /branches/restext/doc/examples/usersguide/fluid.py:2610-2624 /branches/ripleygmg_from_3668/doc/examples/usersguide/fluid.py:3669-3791 /branches/symbolic_from_3470/doc/examples/usersguide/fluid.py:3471-3974 /branches/symbolic_from_3470/ripley/test/python/doc/examples/usersguide/fluid.py:3517-3974 /trunk/ripley/test/python/doc/examples/usersguide/fluid.py:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26