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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4848 - (show annotations)
Wed Apr 9 00:26:32 2014 UTC (5 years, 6 months ago) by jfenwick
File MIME type: text/x-python
File size: 2451 byte(s)
lots of future print_function
1 from __future__ import print_function
2 ##############################################################################
3 #
4 # Copyright (c) 2008-2014 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 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 ######## August 2008 ########
18 ########## Leon Graham ##########
19 ## Newtonian fluid using StokesProblemCartesian class##
20
21 from esys.escript import *
22 import esys.finley
23 from esys.escript.linearPDEs import LinearPDE
24 from esys.escript.models import StokesProblemCartesian
25 from esys.weipa import saveVTK
26
27 #physical constants
28 eta=1.0
29 rho=100.0
30 g=10.0
31
32 #solver settings
33 tolerance=1.0e-4
34 max_iter=200
35 t_end=50
36 t=0.0
37 time=0
38 verbose='TRUE'
39 useUzawa='TRUE'
40
41 #define mesh
42 H=2.0
43 L=1.0
44 W=1.0
45 mesh = esys.finley.Rectangle(l0=L, l1=H, order=-1, n0=20, n1=20, useElementsOnFace=0) # use linear macro elements for pressure
46 coordinates = mesh.getX()
47
48 #gravitational force
49 Y=Vector(0.0, Function(mesh))
50 Y[1]=-rho*g
51
52 #element spacing
53 h=Lsup(mesh.getSize())
54
55 #boundary conditions for slip at base
56 boundary_cond=whereZero(coordinates[1])*[0.0,1.0]+whereZero(coordinates[0])*[1.0,0.0]
57
58 #velocity and pressure vectors
59 velocity=Vector(0.0, Solution(mesh))
60 pressure=Scalar(0.0, ReducedSolution(mesh))
61
62 #Stokes Cartesian
63 solution=StokesProblemCartesian(mesh)
64 solution.setTolerance(tolerance)
65
66 while t <= t_end:
67
68 print(" ----- Time step = %s -----"%( t ))
69 print("Time = %s seconds"%( time ))
70
71 solution.initialize(fixed_u_mask=boundary_cond,eta=eta,f=Y)
72 velocity,pressure=solution.solve(velocity,pressure,max_iter=max_iter,verbose=verbose,usePCG=True)
73
74 print("Max velocity =", Lsup(velocity), "m/s")
75
76 #Courant condition
77 dt=0.4*h/(Lsup(velocity))
78 print("dt", dt)
79
80 #displace the mesh
81 displacement = velocity * dt
82 coordinates = mesh.getX()
83 newx=interpolate(coordinates + displacement, ContinuousFunction(mesh))
84 mesh.setX(newx)
85
86 time += dt
87
88 vel_mag = length(velocity)
89
90 #save velocity and pressure output
91 saveVTK("vel.%2.2i.vtu"%(t),vel=vel_mag,vec=velocity,pressure=pressure)
92 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