/[escript]/branches/symbolic_from_3470/dudley/test/python/axisymm-splitB.py
ViewVC logotype

Contents of /branches/symbolic_from_3470/dudley/test/python/axisymm-splitB.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3789 - (show annotations)
Tue Jan 31 04:55:05 2012 UTC (7 years, 2 months ago) by caltinay
File MIME type: text/x-python
File size: 4739 byte(s)
Fast forward to latest trunk revision 3788.

1
2 ########################################################
3 #
4 # Copyright (c) 2003-2010 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-2010 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.dudley import Rectangle
36 from esys.weipa import saveVTK
37
38
39 nel = 20
40 H = 0.5
41 L = 1.0
42
43 eta = 1.0 # shear viscosity
44 ro = 1.0
45 g = 1.00
46
47 alpha_w = 1.00
48 alpha = 1.00*1000000.
49 Pen=0.
50 B=100.
51
52 nstep = 3000
53 dt = 1.
54 small = EPSILON
55 w_step=max(int(nstep/50),1)*0+1
56 toler = 0.001
57 teta1 = 0.5
58 teta2 = 0.5
59 teta3 = 1 # =0 split A; =1 split B
60
61 # create domain:
62 dom=Rectangle(int(nel*L/min(L,H)),int(nel*H/min(L,H)),order=1, l0=L, l1=H)
63 x=dom.getX()
64
65
66 momentumStep1=LinearPDESystem(dom)
67 momentumStep1.setValue(q=whereZero(x[0])*[1.,0.]+whereZero(x[1])*[0.,1.]) # fix x0=0 and x1=0
68 face_mask=whereZero(FunctionOnBoundary(dom).getX()[1])
69
70 pressureStep2=LinearSinglePDE(dom)
71 pressureStep2.setReducedOrderOn()
72 pressureStep2.setValue(q=whereZero(x[0]-L)+whereZero(x[1]-H))
73
74 momentumStep3=LinearPDESystem(dom)
75 momentumStep3.setValue(q=whereZero(x[0])*[1.,0.]+whereZero(x[1])*[0.,1.])
76 #
77 # initial values:
78 #
79 U=Vector(0.,Solution(dom))
80 p=ro*g*(L-ReducedSolution(dom).getX()[0])*(H-ReducedSolution(dom).getX()[1])/3
81 p=ro*g*(H-ReducedSolution(dom).getX()[1])
82 dev_stress=Tensor(0.,Function(dom))
83
84 t=dt
85 istep=0
86 while istep < nstep:
87 istep=istep+1
88 print("time step :",istep," t = ",t)
89 r=Function(dom).getX()[0]
90 r_b=FunctionOnBoundary(dom).getX()[0]
91 print(" volume : ",integrate(r))
92 #
93 # step 1:
94 #
95 # calculate normal
96 n_d=dom.getNormal()
97 t_d=matrixmult(numpy.array([[0.,-1.],[1.,0]]),n_d)
98 sigma_d=(sign(inner(t_d,U))*alpha_w*t_d-n_d)*Pen*clip(inner(n_d,U),0.)
99 print(" sigma_d =",inf(sigma_d),sup(sigma_d))
100
101 momentumStep1.setValue(D=r*ro*kronecker(dom),
102 Y=r*ro*U+dt*r*[0.,-ro*g],
103 X=-dt*r*(dev_stress-teta3*p*kronecker(dom)),
104 y=sigma_d*face_mask*r_b)
105 U_star=momentumStep1.getSolution()
106 saveVTK("u.vtu",u=U_star,u0=U)
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.vtu"%((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