-
Notifications
You must be signed in to change notification settings - Fork 0
/
inqpr.f90
executable file
·173 lines (138 loc) · 6.33 KB
/
inqpr.f90
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
! Creates Initial condition
!
subroutine inqpr
use local_arrays, only: vy,vz,vx,temp
use param, only: xm, ym, zm, n1m, n2m, xlen, ylen, zlen, Tsol, Tliq,dx1
use mpi_param
use mls_param, only: rad_p, pos_CM
implicit none
integer :: ic,jc,kc
real :: rr
vx=0.0d0
vy=0.0d0
vz=0.0d0
temp= Tsol
!For temperature: temp = Tsol in solid interior, otherwise Tliq in liquid exterior
do kc = kstart, kend
do ic = 1, n1m
do jc = 1, n2m
!rr = sqrt ( (xm(ic) - 0.5d0*xlen )**2 + (ym(jc) - 0.5d0*ylen )**2 + (zm(kc) - 0.5d0*zlen )**2 )
rr = norm2 ( [ xm(ic),ym(jc), zm(kc) ] - pos_CM(:,1) )
! Sigmoid fit
! temp(ic,jc,kc) = Tliq - (Tliq - Tsol) / ( 1 + exp(2.0d0 / dx1 * (rr - rad_p) )
!Tanh
temp(ic,jc,kc) = Tliq - (Tliq - Tsol)*0.5* (1.0d0 - tanh( (rr - rad_p) * dx1 / 2.0 ) )
!if (rr .ge. rad_p) then !Liquid exterior
! temp(ic,jc,kc) = Tliq
!endif
! Ellipsoid
!rr = ( (xm(ic) - 0.5d0*xlen) / 0.20 )**2 + ( (ym(jc) - 0.5d0*ylen)/0.10 )**2 + &
!( ( zm(kc) - 0.5d0*zlen) / 0.1 )**2
!if (rr .gt. 1.0) then
! temp(ic,jc,kc) = Tliq
!endif
enddo !end j
enddo !end i
enddo !end k
return
end
subroutine inqpr_rotated
use local_arrays, only: vy,vz,vx,temp
use param, only: xm, ym, zm, n1m, n2m, xlen, ylen, zlen, Tsol, Tliq,dx1
use mpi_param
use mls_param, only: rad_p, pos_CM
implicit none
integer :: ic,jc,kc
real :: rr, angle
real, dimension(4) :: quaternion
real, dimension(3,3) :: rotmat
real, dimension(3) :: r, rprime
! 30 degree CCW rotation about the y axis
angle = 30.0
quaternion(1) = cosd(angle / 2.0)
quaternion(2) = 0.0
quaternion(3) = sind(angle / 2.0)
quaternion(4) = 0.0
call calc_rot_matrix(quaternion,rotmat)
! (Hard-coded) rotated geometry initial condition
vx=0.0d0
vy=0.0d0
vz=0.0d0
temp= Tsol
!For temperature: temp = Tsol in solid interior, otherwise Tliq in liquid exterior
do kc = kstart, kend
do ic = 1, n1m
do jc = 1, n2m
!rr = sqrt ( (xm(ic) - 0.5d0*xlen )**2 + (ym(jc) - 0.5d0*ylen )**2 + (zm(kc) - 0.5d0*zlen )**2 )
r = [ xm(ic) , ym(jc), zm(kc) ] - pos_CM(:,1)
rprime = matmul(rotmat, r)
rr = (rprime(1) / 0.2)**2 + (rprime(2)/0.1)**2 + ( rprime(3) / 0.1)**2
! Ellipsoid
!rr = ( (xm(ic) - 0.5d0*xlen) / 0.20 )**2 + ( (ym(jc) - 0.5d0*ylen)/0.10 )**2 + &
!( ( zm(kc) - 0.5d0*zlen) / 0.1 )**2
if (rr .gt. 1.0) then
temp(ic,jc,kc) = Tliq
endif
enddo !end j
enddo !end i
enddo !end k
return
end
! Quick and dirty routine to reset the temperature field for uniform/tanh Tsolid, Tliquid
subroutine restart_temperature
use local_arrays, only: temp
use param, only: xm, ym, zm, n1m, n2m, xlen, ylen, zlen, Tsol, Tliq,dx1
use mpi_param
use mls_param, only: rad_p, pos_CM
implicit none
integer :: ic,jc,kc
real :: rr
temp= Tsol
!For temperature: temp = Tsol in solid interior, otherwise Tliq in liquid exterior
do kc = kstart, kend
do ic = 1, n1m
do jc = 1, n2m
!rr = sqrt ( (xm(ic) - 0.5d0*xlen )**2 + (ym(jc) - 0.5d0*ylen )**2 + (zm(kc) - 0.5d0*zlen )**2 )
rr = norm2 ( [ xm(ic),ym(jc), zm(kc) ] - pos_CM(:,1) )
! Sigmoid fit
! temp(ic,jc,kc) = Tliq - (Tliq - Tsol) / ( 1 + exp(2.0d0 / dx1 * (rr - rad_p) )
!Tanh
temp(ic,jc,kc) = Tliq - (Tliq - Tsol)*0.5* (1.0d0 - tanh( (rr - rad_p) * dx1 / 2.0 ) )
!if (rr .ge. rad_p) then !Liquid exterior
! temp(ic,jc,kc) = Tliq
!endif
enddo !end j
enddo !end i
enddo !end k
return
end
subroutine inqpr_taylorGreen
use local_arrays, only: vy,vz,vx,temp
use param, only: xm, ym, zm, xc,yc,zc,n1m, n2m, xlen, ylen, zlen, Tsol, Tliq,dx1, pi
use mpi_param
use mls_param, only: rad_p, pos_CM
implicit none
integer :: ic,jc,kc
real :: rr
temp= Tsol
!For temperature: temp = Tsol in solid interior, otherwise Tliq in liquid exterior
do kc = kstart, kend
do ic = 1, n1m
do jc = 1, n2m
!rr = sqrt ( (xm(ic) - 0.5d0*xlen )**2 + (ym(jc) - 0.5d0*ylen )**2 + (zm(kc) - 0.5d0*zlen )**2 )
rr = norm2 ( [ xm(ic),ym(jc), zm(kc) ] - pos_CM(:,1) )
! Sigmoid fit
! temp(ic,jc,kc) = Tliq - (Tliq - Tsol) / ( 1 + exp(2.0d0 / dx1 * (rr - rad_p) )
!Tanh
temp(ic,jc,kc) = Tliq - (Tliq - Tsol)*0.5* (1.0d0 - tanh( (rr - rad_p) * dx1 / 2.0 ) )
! Taylor-green vortices IC
vx(ic,jc,kc) = sin(2.0 * pi * xc(ic) / xlen ) * cos(2.0 * pi * ym(jc) / ylen ) &
* cos(2.0 * pi * zm(kc) / zlen )
vy(ic,jc,kc) = -cos(2.0 * pi * xc(ic) / xlen ) * sin(2.0 * pi * yc(jc) / ylen ) &
* cos(2.0 * pi * zm(kc) / zlen )
vz(ic,jc,kc) = 0.0
enddo !end j
enddo !end i
enddo !end k
return
end