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

Properties

Name Value
svn:mergeinfo /branches/4.0fordebian/doc/examples/usersguide/fluid.py:5567-5588 /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 /release/4.0/doc/examples/usersguide/fluid.py:5380-5406 /trunk/ripley/test/python/doc/examples/usersguide/fluid.py:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26