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

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