Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
! |
! ||===\\ |
! || \\ |
! || || //==\\ || || //==|| ||/==\\ |
! || || || || || || || || || || |
! || // || || || || || || || |
! ||===// \\==// \\==\\ \\==\\ || |
! |
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
! |
! DEFINE_BC_SEGMENTED_S_LINE Feb. 2009 |
! |
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
subroutine define_bc_rot_sub_init(params,osolve,vo,bcdef,nest)
!------------------------------------------------------------------------------|
!(((((((((((((((( Purpose of the routine )))))))))))))))))))))))))))))))))))))
!------------------------------------------------------------------------------|
! This routine assigns the velocity boundary conditions for the rotational |
! subduction geometry |
!------------------------------------------------------------------------------|
!(((((((((((((((( declaration of the subroutine arguments ))))))))))))))))))))
!------------------------------------------------------------------------------|
use definitions
!use mpi
implicit none
include 'mpif.h'
type (parameters) params
type (octreesolve) osolve
type (void) vo
type (bc_definition) bcdef
type (nest_info) nest
!------------------------------------------------------------------------------|
!(((((((((((((((( declaration of the subroutine internal variables )))))))))))))
!------------------------------------------------------------------------------|
integer i,iproc,nproc,ierr,tempcase,fixdomain
double precision :: eps,pi,y0,h,rx,wy,vin,vtop,vback,nelemx,nelemz,dxy,dz
double precision :: rmain,zmain,omega,theta,phi,distmain,distrot,distz0plane
double precision :: distzonerad,distzoney,distzone,distedge
double precision :: xedge,xminedge,xmaxedge,yfix_xedge, yedge,yminedge,ymaxedge
double precision :: zedge,zminedge,zmaxedge, ustart,ustart2,uend,uend2
double precision :: wstart,wstart2,wend,tempstart,tempstart2,tempend
double precision :: nl_heat,hr,depth,ztemp
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
call mpi_comm_size (mpi_comm_world,nproc,ierr)
call mpi_comm_rank (mpi_comm_world,iproc,ierr)
!basic constants
eps=1.d-10
pi=atan(1.d0)*4.d0
!set fixed to 0 everywhere
osolve%kfix=0
osolve%kfixt=0
!parameters from input file
y0=bcdef%bc_parameters(1)
h=bcdef%bc_parameters(2)
rx=bcdef%bc_parameters(3)
wy=bcdef%bc_parameters(4)
vin=bcdef%bc_parameters(5)
vtop=bcdef%bc_parameters(6)
vback=-bcdef%bc_parameters(7) !change in orientation
nelemx=bcdef%bc_parameters(8)
nelemz=bcdef%bc_parameters(9)
tempcase=idint(bcdef%bc_parameters(10))
nl_heat=bcdef%bc_parameters(11)/params%tempscale
hr=bcdef%bc_parameters(12)
fixdomain=idint(bcdef%bc_parameters(13))
dxy=nelemx/2.d0**(params%levelmax_oct+1.d0) !0.5*transition width in xy
dz=nelemz*params%vex/2.d0**(params%levelmax_oct+1.d0) !0.5*transition width in z
ztemp = params%ztemp*params%vex
!Derived parameters from input values
rmain=(h**2+rx**2)/(2.d0*h)
zmain=h-rmain
omega=vin/rmain
!rotating element is sphere
do i=1,osolve%nnode
!distance from center of sphere
distmain=sqrt(osolve%x(i)**2+((osolve%y(i)-y0)*rx/(0.5d0*wy))**2 + &
(osolve%z(i)*params%vex-zmain)**2)
!distance from axis of rotation
distrot=sqrt(osolve%x(i)**2+(osolve%z(i)*params%vex-zmain)**2)
!setting velocity in indenter
if (distmain<rmain) then
theta=asin(osolve%x(i)/distrot)
osolve%kfix((i-1)*3+1)=1
osolve%u(i)=distrot*omega*cos(theta)
osolve%kfix((i-1)*3+2)=1
osolve%v(i)=0.d0
osolve%kfix((i-1)*3+3)=1
osolve%w(i)=-osolve%x(i)*omega
elseif (distmain > rmain+2.d0*dz .AND. fixdomain > 0) then
osolve%kfix((i-1)*3+1)=1
osolve%u(i)=0.d0
osolve%kfix((i-1)*3+2)=1
osolve%v(i)=0.d0
osolve%kfix((i-1)*3+3)=1
osolve%w(i)=0.d0
end if
!y=0 face free slip
if (osolve%y(i)<eps) then
!no flux through face
osolve%kfix((i-1)*3+2)=1 ; osolve%v(i)=0.d0
!flow fixed to (vback, 0 0)
osolve%kfix((i-1)*3+1)=1 ; osolve%u(i)=vback
osolve%kfix((i-1)*3+3)=1 ; osolve%w(i)=0.d0
!rotating sphere cuts y=0 face
if (y0-0.5d0*wy < 0.d0) then
!calculate geometry for face
distedge = sqrt(max(0.0d0, rmain**2 - ((-y0)*rx/(0.5d0*wy))**2))
distzonerad = max(0.d0,min(1.d0,(distrot-distedge+dz)/(2*dz)))
!Setting velocities for inside and tranistion
!angle of rotation
theta=asin(osolve%x(i)/distrot)
!inside rotating cylinder
if (distzonerad < eps) then
!set x velocity
osolve%kfix((i-1)*3+1)=1
osolve%u(i)=distrot*omega*cos(theta)
!set z velocity
osolve%kfix((i-1)*3+3)=1
osolve%w(i)=-osolve%x(i)*omega
!in transition zone
else if (distzonerad < 1.d0) then
xminedge = osolve%x(i)*(distedge-dz)/distrot
!set x velocity
ustart=(distedge-dz)*omega*cos(theta)
uend=vback
osolve%u(i)=ustart+distzonerad*(uend-ustart)
!set z velocity
wstart=-xminedge*omega
wend=0.d0
osolve%w(i)=wstart+distzonerad*(wend-wstart)
end if
end if
end if
!y=1 face free slip
if (osolve%y(i)>(1.d0-eps)) then
!no flux through face
osolve%kfix((i-1)*3+2)=1 ; osolve%v(i)=0.d0
!flow fixed to (vback, 0 0)
osolve%kfix((i-1)*3+1)=1 ; osolve%u(i)=vback
osolve%kfix((i-1)*3+3)=1 ; osolve%w(i)=0.d0
!rotating sphere cuts y=1 face
if (y0+0.5d0*wy > 1.d0) then
!calculate geometry for face
distedge = sqrt(max(0.0d0, rmain**2 - ((1.d0-y0)*rx/(0.5d0*wy))**2))
distzonerad = max(0.d0,min(1.d0,(distrot-distedge+dz)/(2*dz)))
!Setting velocities for inside and transition
!angle of rotation
theta=asin(osolve%x(i)/distrot)
!inside rotating cylinder
if (distzonerad < eps) then
!set x velocity
osolve%kfix((i-1)*3+1)=1
osolve%u(i)=distrot*omega*cos(theta)
!set z velocity
osolve%kfix((i-1)*3+3)=1
osolve%w(i)=-osolve%x(i)*omega
!in transition zone
else if (distzonerad < 1.d0) then
xminedge = osolve%x(i)*(distedge-dz)/distrot
!set x velocity
ustart=(distedge-dz)*omega*cos(theta)
uend=vback
osolve%u(i)=ustart+distzonerad*(uend-ustart)
!set z velocity
wstart=-xminedge*omega
wend=0.d0
osolve%w(i)=wstart+distzonerad*(wend-wstart)
end if
end if
end if
!x=0 face
if (osolve%x(i)<eps) then
!set y and z velocity
osolve%kfix((i-1)*3+1)=1 !x-direction fixed
osolve%kfix((i-1)*3+2)=1 ; osolve%v(i)=0.d0 !y-direction
osolve%kfix((i-1)*3+3)=1 ; osolve%w(i)=0.d0 !z-direction
!outline of indenter
zedge = max(0.d0, zmain+sqrt(max(0.d0,rmain**2-((osolve%y(i)-y0)*rx/(0.5d0*wy))**2)))
zminedge = max(0.d0,zedge-dz)
zmaxedge = max(0.d0,zedge+dz)
!position relative to radial and y transition zones
! (0 inside, 1 outside, linear transition in zone)
distzonerad = max(0.d0,min(1.d0,(osolve%z(i)*params%vex-zminedge)/(zmaxedge-zminedge+eps)))
distzoney=min(1.d0,max(0.d0,(abs(osolve%y(i)-y0)-0.5d0*wy+dxy)/(2.d0*dxy)))
!outside rotating sphere radially
if (distzonerad > 1.d0-eps) then
ustart = vtop
uend = vback
osolve%u(i)=ustart+distzoney*(uend-ustart)
!within rotating sphere radially
elseif (distzonerad < eps) then
osolve%u(i)=omega*(osolve%z(i)*params%vex-zmain)
!inside transition zone radially
else
!uend depends on upper gradient (see distzonerad > 1)
ustart2=vtop
uend2=vback
uend=ustart2+distzoney*(uend2-ustart2)
!ustart is gradient from urot to uback
ustart2 = omega*(osolve%z(i)*params%vex-zmain)
uend2=vback
ustart=ustart2+distzoney*(uend2-ustart2)
osolve%u(i)=ustart+distzonerad*(uend-ustart)
end if
!set temperature
osolve%kfixt(i) = 1
depth = ztemp - osolve%z(i)*params%vex
select case (tempcase)
case (1)
!"typical isotherm taken from R.Bendicks simulation
!nl_heat is scaled nonlinear heat component hr^2*S_o/k_T
osolve%temp(i) = (depth/ztemp) + &
nl_heat*((1.d0-exp(-depth/hr))-(1.d0-exp(-ztemp/hr))*depth/ztemp)
case default
osolve%temp(i) = depth/ztemp
end select
end if
!z=0 face
if (osolve%z(i) < eps) then
!fix all velocities and temp, set v to 0
osolve%kfix((i-1)*3+1)=1
osolve%kfix((i-1)*3+2)=1 ; osolve%v(i)=0.d0 !y-direction
osolve%kfix((i-1)*3+3)=1
!calculating radial transition zone: radial belt of width 2dxy at indenter edge,
!circle origin is (x0, y0, 0)
!finding intersections with indenter edge radial direction
distz0plane = sqrt(osolve%x(i)**2+((osolve%y(i)-y0)*rx/(0.5d0*wy))**2)
if (distz0plane < eps) then
xedge = rx
yedge = y0
else
xedge = osolve%x(i)*rx/distz0plane
yedge = y0+(osolve%y(i)-y0)*rx/distz0plane
end if
!finding intersection with indenter edge for given x in y direction
yfix_xedge=sqrt(max(0.d0,rmain**2-((osolve%y(i)-y0)*rx/(0.5d0*wy))**2-zmain**2))
!start of transition zone radially
xminedge = xedge-dxy*xedge/sqrt(xedge**2+(yedge-y0)**2)
yminedge = yedge-dxy*(yedge-y0)/sqrt(xedge**2+(yedge-y0)**2)
!transition zone in radial >1 for outside, <0 for inside
distzonerad=(sqrt((osolve%y(i)-y0)**2+osolve%x(i)**2) - &
sqrt((yminedge-y0)**2+(xminedge)**2))/(2.d0*dxy)
!outside rotating sphere radially
if (distzonerad > 1.d0) then
!velocity
osolve%u(i) = vback
osolve%w(i) = 0.d0
!temperature
osolve%temp(i)=1.d0
osolve%kfixt(i)=1
!within rotating sphere radially
elseif (distzonerad < 0.d0) then
distrot = sqrt(osolve%x(i)**2+zmain**2)
theta = asin(osolve%x(i)/distrot)
!set x velocity
osolve%u(i) = distrot*omega*cos(theta)
!set z velocity
osolve%w(i) = -osolve%x(i)*omega
!don't set temperature
!transition zone radially
else
!start value at inner edge of transition zone
distrot = sqrt(xminedge**2+zmain**2)
theta = asin(xminedge/distrot)
ustart = distrot*omega*cos(theta)
uend = vback
wstart = -xminedge*omega
wend = 0.d0
!setting velocities
osolve%u(i)=ustart+distzonerad*(uend-ustart)
osolve%w(i)=wstart+distzonerad*(wend-wstart)
!don't set temperature
end if
end if
!x=1 face with influx vback
if (osolve%x(i)>1.d0-eps) then
osolve%kfix((i-1)*3+1)=1 ; osolve%u(i)=vback
osolve%kfix((i-1)*3+2)=1 ; osolve%v(i)=0.d0
osolve%kfix((i-1)*3+3)=1 ; osolve%w(i)=0.d0
end if
!z=1 face
if (osolve%z(i) > 1.d0-eps) then
osolve%kfix((i-1)*3+1)=1 ; osolve%u(i)=0.d0 !x-direction
osolve%kfix((i-1)*3+2)=1 ; osolve%v(i)=0.d0 !y-direction
osolve%kfix((i-1)*3+3)=1 ; osolve%w(i)=0.d0 !z-direction
osolve%kfixt(i)=1 ; osolve%temp(i)=0.d0
end if
if (.not.vo%influid(i)) then
osolve%kfixt(i)=1
osolve%temp(i)=0.d0
endif
end do
end
!------------------------------------------------------------------------------|