/[escript]/trunk/finley/test/python/RT2D.py
ViewVC logotype

Contents of /trunk/finley/test/python/RT2D.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6651 - (show annotations)
Wed Feb 7 02:12:08 2018 UTC (14 months, 2 weeks ago) by jfenwick
File MIME type: text/x-python
File size: 3207 byte(s)
Make everyone sad by touching all the files

Copyright dates update

1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2018 by The University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Apache License, version 2.0
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 from __future__ import print_function, division
18
19 from esys.escript import *
20 import esys.finley
21 from esys.escript.models import StokesProblemCartesian
22 from esys.finley import finley
23 from esys.finley import Rectangle
24 from esys.weipa import saveVTK
25
26
27 #physical properties
28 rho1 = 1000 #fluid density on bottom
29 rho2 = 1010 #fluid density on top
30 eta1 = 100.0 #fluid viscosity on bottom
31 eta2 = 100.0 #fluid viscosity on top
32 g=10.0
33
34 #solver settings
35 dt = 0.001
36 t_step = 0
37 t_step_end = 2000
38 TOL = 1.0e-5
39 max_iter=400
40 verbose=True
41 useUzawa=True
42
43 #define mesh
44 l0=0.9142
45 l1=1.0
46 n0=200
47 n1=200
48
49 mesh=Rectangle(l0=l0, l1=l1, order=2, n0=n0, n1=n1)
50 #get mesh dimensions
51 numDim = mesh.getDim()
52 #get element size
53 h = Lsup(mesh.getSize())
54
55 #level set parameters
56 tolerance = 1.0e-6
57 reinit_max = 30
58 reinit_each = 3
59 alpha = 1
60 smooth = alpha*h
61
62 #boundary conditions
63 x = mesh.getX()
64 #left + bottom + right + top
65 b_c = whereZero(x[0])*[1.0,0.0] + whereZero(x[1])*[1.0,1.0] + whereZero(x[0]-l0)*[1.0,0.0] + whereZero(x[1]-l1)*[1.0,1.0]
66
67 velocity = Vector(0.0, ContinuousFunction(mesh))
68 pressure = Scalar(0.0, ContinuousFunction(mesh))
69 Y = Vector(0.0,Function(mesh))
70
71 #define initial interface between fluids
72 xx = mesh.getX()[0]
73 yy = mesh.getX()[1]
74 func = Scalar(0.0, ContinuousFunction(mesh))
75 h_interface = Scalar(0.0, ContinuousFunction(mesh))
76 h_interface = h_interface + (0.02*cos(math.pi*xx/l0) + 0.2)
77 func = yy - h_interface
78 func_new = func.interpolate(ReducedSolution(mesh))
79
80 #Stokes Cartesian
81 solution=StokesProblemCartesian(mesh,debug=True)
82 solution.setTolerance(TOL)
83
84 #level set
85 levelset = LevelSet(mesh, func_new, reinit_max, reinit_each, tolerance, smooth)
86
87 while t_step <= t_step_end:
88 #update density and viscosity
89 rho = levelset.update_parameter(rho1, rho2)
90 eta = levelset.update_parameter(eta1, eta2)
91
92 #get velocity and pressure of fluid
93 Y[1] = -rho*g
94 solution.initialize(fixed_u_mask=b_c,eta=eta,f=Y)
95 velocity,pressure=solution.solve(velocity,pressure,max_iter=max_iter,verbose=verbose,useUzawa=useUzawa)
96
97 #update the interface
98 func = levelset.update_phi(velocity, dt, t_step)
99
100 print("##########################################################")
101 print("time step:", t_step, " completed with dt:", dt)
102 print("Velocity: min =", inf(velocity), "max =", Lsup(velocity))
103 print("##########################################################")
104
105 #save interface, velocity and pressure
106 saveVTK("phi2D.%2.4i.vtu"%t_step,interface=func,velocity=velocity,pressure=pressure)
107 #courant condition
108 dt = 0.4*Lsup(mesh.getSize())/Lsup(velocity)
109 t_step += 1

Properties

Name Value
svn:mergeinfo /branches/4.0fordebian/finley/test/python/RT2D.py:5567-5588 /branches/lapack2681/finley/test/python/RT2D.py:2682-2741 /branches/pasowrap/finley/test/python/RT2D.py:3661-3674 /branches/py3_attempt2/finley/test/python/RT2D.py:3871-3891 /branches/restext/finley/test/python/RT2D.py:2610-2624 /branches/ripleygmg_from_3668/finley/test/python/RT2D.py:3669-3791 /branches/symbolic_from_3470/finley/test/python/RT2D.py:3471-3974 /branches/symbolic_from_3470/ripley/test/python/finley/test/python/RT2D.py:3517-3974 /branches/trilinos_from_5897/finley/test/python/RT2D.py:5898-6118 /release/4.0/finley/test/python/RT2D.py:5380-5406 /trunk/ripley/test/python/finley/test/python/RT2D.py:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26