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



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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26