/[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 4853 - (hide annotations)
Wed Apr 9 05:41:57 2014 UTC (5 years, 6 months ago) by jfenwick
File MIME type: text/x-python
File size: 2483 byte(s)
Added import division and changed a few / to //

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     import esys.finley
24     from esys.escript.linearPDEs import LinearPDE
25     from esys.escript.models import StokesProblemCartesian
26 caltinay 3346 from esys.weipa import saveVTK
27 lgraham 2191
28     #physical constants
29     eta=1.0
30     rho=100.0
31     g=10.0
32    
33     #solver settings
34     tolerance=1.0e-4
35     max_iter=200
36     t_end=50
37     t=0.0
38     time=0
39     verbose='TRUE'
40     useUzawa='TRUE'
41    
42     #define mesh
43     H=2.0
44     L=1.0
45     W=1.0
46 jfenwick 3901 mesh = esys.finley.Rectangle(l0=L, l1=H, order=-1, n0=20, n1=20, useElementsOnFace=0) # use linear macro elements for pressure
47 lgraham 2191 coordinates = mesh.getX()
48    
49     #gravitational force
50     Y=Vector(0.0, Function(mesh))
51     Y[1]=-rho*g
52    
53     #element spacing
54     h=Lsup(mesh.getSize())
55    
56     #boundary conditions for slip at base
57 gross 2793 boundary_cond=whereZero(coordinates[1])*[0.0,1.0]+whereZero(coordinates[0])*[1.0,0.0]
58 lgraham 2191
59     #velocity and pressure vectors
60 gross 2793 velocity=Vector(0.0, Solution(mesh))
61     pressure=Scalar(0.0, ReducedSolution(mesh))
62 lgraham 2191
63     #Stokes Cartesian
64     solution=StokesProblemCartesian(mesh)
65     solution.setTolerance(tolerance)
66    
67     while t <= t_end:
68    
69 jfenwick 3892 print(" ----- Time step = %s -----"%( t ))
70     print("Time = %s seconds"%( time ))
71 lgraham 2191
72     solution.initialize(fixed_u_mask=boundary_cond,eta=eta,f=Y)
73 gross 2432 velocity,pressure=solution.solve(velocity,pressure,max_iter=max_iter,verbose=verbose,usePCG=True)
74 lgraham 2191
75 jfenwick 3892 print("Max velocity =", Lsup(velocity), "m/s")
76 lgraham 2191
77     #Courant condition
78     dt=0.4*h/(Lsup(velocity))
79 jfenwick 3892 print("dt", dt)
80 lgraham 2191
81     #displace the mesh
82     displacement = velocity * dt
83     coordinates = mesh.getX()
84 jfenwick 3914 newx=interpolate(coordinates + displacement, ContinuousFunction(mesh))
85     mesh.setX(newx)
86 lgraham 2191
87     time += dt
88    
89     vel_mag = length(velocity)
90    
91     #save velocity and pressure output
92     saveVTK("vel.%2.2i.vtu"%(t),vel=vel_mag,vec=velocity,pressure=pressure)
93     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