/[escript]/trunk/finley/test/python/axisymm-splitB.py
ViewVC logotype

Contents of /trunk/finley/test/python/axisymm-splitB.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2344 - (show annotations)
Mon Mar 30 02:13:58 2009 UTC (10 years, 5 months ago) by jfenwick
File MIME type: text/x-python
File size: 4712 byte(s)
Change __url__ to launchpad site

1
2 ########################################################
3 #
4 # Copyright (c) 2003-2008 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
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 ########################################################
13
14 __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15 Earth Systems Science Computational Center (ESSCC)
16 http://www.uq.edu.au/esscc
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="https://launchpad.net/escript-finley"
21
22 #
23 # AXI-SYMMETRIC NEWTONIAN MODEL ; UPDATED LAGRANGIAN FORMULATION
24 #
25 #
26 # step 1 rho*(v_star-v) = dt * (sigma'_ij,j-teta3*p,i+f_i)
27 # step 2 dp=-dt*B*(v_j,j+teta1*v_star_j,j-dt*teta1*((1-teta3)*p_,jj+teta2*dp_,jj))
28 # step 3 rho*(v+-v) = -dt*((1-teta3)*p_,jj+teta2*dp_,jj)
29 # step 3b p+=1/2(p+dp+abs(p+dp))
30 # step 4 sigma'i+_ij,j=f(v+,p+,...)
31 #
32 #
33 from esys.escript import *
34 from esys.escript.linearPDEs import LinearSinglePDE, LinearPDESystem
35 from esys.finley import Rectangle
36
37
38 nel = 20
39 H = 0.5
40 L = 1.0
41
42 eta = 1.0 # shear viscosity
43 ro = 1.0
44 g = 1.00
45
46 alpha_w = 1.00
47 alpha = 1.00*1000000.
48 Pen=0.
49 B=100.
50
51 nstep = 3000
52 dt = 1.
53 small = EPSILON
54 w_step=max(int(nstep/50),1)*0+1
55 toler = 0.001
56 teta1 = 0.5
57 teta2 = 0.5
58 teta3 = 1 # =0 split A; =1 split B
59
60 # create domain:
61 dom=Rectangle(int(nel*L/min(L,H)),int(nel*H/min(L,H)),order=1, l0=L, l1=H)
62 x=dom.getX()
63
64
65 momentumStep1=LinearPDESystem(dom)
66 momentumStep1.setValue(q=whereZero(x[0])*[1.,0.]+whereZero(x[1])*[0.,1.]) # fix x0=0 and x1=0
67 face_mask=whereZero(FunctionOnBoundary(dom).getX()[1])
68
69 pressureStep2=LinearSinglePDE(dom)
70 pressureStep2.setReducedOrderOn()
71 pressureStep2.setValue(q=whereZero(x[0]-L)+whereZero(x[1]-H))
72
73 momentumStep3=LinearPDESystem(dom)
74 momentumStep3.setValue(q=whereZero(x[0])*[1.,0.]+whereZero(x[1])*[0.,1.])
75 #
76 # initial values:
77 #
78 U=Vector(0.,Solution(dom))
79 p=ro*g*(L-ReducedSolution(dom).getX()[0])*(H-ReducedSolution(dom).getX()[1])/3
80 p=ro*g*(H-ReducedSolution(dom).getX()[1])
81 dev_stress=Tensor(0.,Function(dom))
82
83 t=dt
84 istep=0
85 while istep < nstep:
86 istep=istep+1
87 print "time step :",istep," t = ",t
88 r=Function(dom).getX()[0]
89 r_b=FunctionOnBoundary(dom).getX()[0]
90 print " volume : ",integrate(r)
91 #
92 # step 1:
93 #
94 # calculate normal
95 n_d=dom.getNormal()
96 t_d=matrixmult(numarray.array([[0.,-1.],[1.,0]]),n_d)
97 sigma_d=(sign(inner(t_d,U))*alpha_w*t_d-n_d)*Pen*clip(inner(n_d,U),0.)
98 print " sigma_d =",inf(sigma_d),sup(sigma_d)
99
100 momentumStep1.setValue(D=r*ro*kronecker(dom),
101 Y=r*ro*U+dt*r*[0.,-ro*g],
102 X=-dt*r*(dev_stress-teta3*p*kronecker(dom)),
103 y=sigma_d*face_mask*r_b)
104 U_star=momentumStep1.getSolution()
105 saveVTK("u.xml",u=U_star,u0=U)
106 1/0
107 #
108 # step 2:
109 #
110 # U2=U+teta1*(U_star-U)
111 U2=U+teta1*U_star
112 gg2=grad(U2)
113 div_U2=gg2[0,0]+gg2[1,1]+U2[0]/r
114
115 grad_p=grad(p)
116
117 pressureStep2.setValue(A=r*dt*B*teta1*teta2/ro*dt*kronecker(dom),
118 D=r,
119 Y=-dt*B*r*div_U2,
120 X=-r*B*dt**2/ro*teta1*(1-teta3)*grad_p)
121 dp=pressureStep2.getSolution()
122 #
123 # step 3:
124 #
125 p2=(1-teta3)*p+teta2*dp
126 grad_p2=grad(p2)
127 momentumStep3.setValue(D=r*ro*kronecker(dom),
128 Y=r*(ro*U_star-dt*teta2*grad_p2))
129 U_new=momentumStep3.getSolution()
130 #
131 # update:
132 #
133 p+=dp
134 U=U_new
135 print " U:",inf(U),sup(U)
136 print " P:",inf(p),sup(p)
137
138
139 p_pos=clip(p,small)
140 gg=grad(U)
141 vol=gg[0,0]+gg[1,1]+U[0]/r
142 gamma=sqrt(2*((gg[0,0]-vol/3)**2+(gg[1,1]-vol/3)**2+(U[0]/r-vol/3)**2+(gg[1,0]+gg[0,1])**2/2))
143 m=whereNegative(eta*gamma-alpha*p_pos)
144 eta_d=m*eta+(1.-m)*alpha*p_pos/(gamma+small)
145 print " viscosity =",inf(eta_d),sup(eta_d)
146 dev_stress=eta_d*(symmetric(gg)-2./3.*vol*kronecker(dom))
147 #
148 # step size control:
149 #
150 len=inf(dom.getSize())
151 dt1=inf(dom.getSize()/(length(U)+small))
152 dt2=inf(0.5*ro*(len**2)/eta_d)
153 dt=dt1*dt2/(dt1+dt2)
154 print " new step size = ",dt
155 #
156 # update geometry
157 #
158 dom.setX(dom.getX()+U*dt)
159 t=t+dt
160 if (istep-1)%w_step==0:saveVTK("u.%d.xml"%((istep-1)/w_step),p=p,eta=eta_d,U=U_star,U_star=U_star,gamma=gamma)
161 if istep == 3: 1/0

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26