/[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 6756 - (hide annotations)
Thu Nov 29 07:23:43 2018 UTC (20 months ago) by aellery
File MIME type: text/x-python
File size: 2827 byte(s)
Temporarily undoing last commit.
1 jfenwick 3981 ##############################################################################
2 jfenwick 2549 #
3 jfenwick 6651 # Copyright (c) 2008-2018 by The University of Queensland
4 jfenwick 3981 # http://www.uq.edu.au
5 jfenwick 2549 #
6     # Primary Business: Queensland, Australia
7 jfenwick 6112 # Licensed under the Apache License, version 2.0
8     # http://www.apache.org/licenses/LICENSE-2.0
9 jfenwick 2549 #
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 sshaw 5707 from __future__ import division, print_function
20 lgraham 2191
21     from esys.escript import *
22 sshaw 5288 try:
23     from esys.finley import Rectangle
24     HAVE_FINLEY = True
25     except ImportError:
26 sshaw 5294 print("Finley module required but not available")
27 sshaw 5288 HAVE_FINLEY = False
28 lgraham 2191 from esys.escript.linearPDEs import LinearPDE
29     from esys.escript.models import StokesProblemCartesian
30 caltinay 3346 from esys.weipa import saveVTK
31 sshaw 5294 if HAVE_FINLEY:
32 sshaw 5288 #physical constants
33     eta=1.0
34     rho=100.0
35     g=10.0
36 lgraham 2191
37 sshaw 5288 #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 lgraham 2191
46 sshaw 5288 #define mesh
47     H=2.0
48     L=1.0
49     W=1.0
50 sshaw 5292 mesh = Rectangle(l0=L, l1=H, order=-1, n0=20, n1=20, useElementsOnFace=0) # use linear macro elements for pressure
51 sshaw 5288 coordinates = mesh.getX()
52 lgraham 2191
53 sshaw 5288 #gravitational force
54     Y=Vector(0.0, Function(mesh))
55     Y[1]=-rho*g
56 lgraham 2191
57 sshaw 5288 #element spacing
58     h=Lsup(mesh.getSize())
59 lgraham 2191
60 sshaw 5288 #boundary conditions for slip at base
61     boundary_cond=whereZero(coordinates[1])*[0.0,1.0]+whereZero(coordinates[0])*[1.0,0.0]
62 lgraham 2191
63 sshaw 5288 #velocity and pressure vectors
64     velocity=Vector(0.0, Solution(mesh))
65     pressure=Scalar(0.0, ReducedSolution(mesh))
66 lgraham 2191
67 sshaw 5288 #Stokes Cartesian
68     solution=StokesProblemCartesian(mesh)
69     solution.setTolerance(tolerance)
70 lgraham 2191
71 sshaw 5288 while t <= t_end:
72 lgraham 2191
73 sshaw 5288 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 lgraham 2191
95 sshaw 5288 #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 /branches/trilinos_from_5897/doc/examples/usersguide/fluid.py:5898-6118 /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