/[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 4657 - (hide annotations)
Thu Feb 6 06:12:20 2014 UTC (5 years, 8 months ago) by jfenwick
File MIME type: text/x-python
File size: 2413 byte(s)
I changed some files.
Updated copyright notices, added GeoComp.



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