-
Notifications
You must be signed in to change notification settings - Fork 155
Expand file tree
/
Copy path3dHardcodedIC.fpp
More file actions
278 lines (246 loc) · 12.6 KB
/
Copy path3dHardcodedIC.fpp
File metadata and controls
278 lines (246 loc) · 12.6 KB
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
#:def Hardcoded3DVariables()
! Place any declaration of intermediate variables here
real(wp) :: rhoH, rhoL, pRef, pInt, h, lam, wl, amp, intH, alph, Mach
real(wp) :: eps
! IGR Jets Arrays to stor position and radii of jets from input file
real(wp), dimension(:), allocatable :: y_th_arr, z_th_arr, r_th_arr
! Variables to describe initial condition of jet
real(wp) :: r, ux_th, ux_am, p_th, p_am, rho_th, rho_am, y_th, z_th, r_th, eps_smooth
real(wp) :: rcut, xcut !< Intermediate variables for creating smooth initial condition
real(wp), dimension(0:n,0:p) :: rcut_arr
integer :: l, q, s !< Iterators for reading input files
integer :: start, end !< Ints to keep track of position in file
character(len=100000) :: line ! String to store line in file
character(len=25) :: value !< String to store value in line
integer :: NJet !< Number of jets
real(wp), allocatable, dimension(:,:) :: ih ! Array to store interface height in
logical :: file_exist ! Flag to check if file exists
eps = 1e-9_wp
if (patch_icpp(patch_id)%hcid == 303) then ! IGR Multijet
eps_smooth = 3._wp
inquire (file="njet.txt", exist=file_exist)
if (file_exist) then
open (unit=10, file="njet.txt", status="old", action="read")
read (10, *) NJet
close (10)
else
call s_mpi_abort("Error: njet.txt file specified for hcid=303 does not exist")
end if
@:ALLOCATE(y_th_arr(0:NJet - 1))
@:ALLOCATE(z_th_arr(0:NJet - 1))
@:ALLOCATE(r_th_arr(0:NJet - 1))
inquire (file="jets.csv", exist=file_exist)
if (file_exist) then
open (unit=10, file="jets.csv", status="old", action="read")
do q = 0, NJet - 1
read (10, '(A)') line ! Read a full line as a string
start = 1
do l = 0, 2
end = index(line(start:), ',') ! Find the next comma
if (end == 0) then
value = trim(adjustl(line(start:))) ! Last value in the line
else
value = trim(adjustl(line(start:start + end - 2))) ! Extract substring
start = start + end ! Move to next value
end if
if (l == 0) then
read (value, *) y_th_arr(q) ! Convert string to numeric value
else if (l == 1) then
read (value, *) z_th_arr(q)
else
read (value, *) r_th_arr(q)
end if
end do
end do
close (10)
do q = 0, p
do l = 0, n
rcut = 0._wp
do s = 0, NJet - 1
r = sqrt((y_cc(l) - y_th_arr(s))**2._wp + (z_cc(q) - z_th_arr(s))**2._wp)
rcut = rcut + f_cut_on(r - r_th_arr(s), eps_smooth)
end do
rcut_arr(l, q) = rcut
end do
end do
else
call s_mpi_abort("Error: jets.csv file specified for hcid=303 does not exist")
end if
end if
if (patch_icpp(patch_id)%hcid == 304) then ! 3D Cartesian interface from file
@:ALLOCATE(ih(0:n_glb, 0:p_glb))
if (interface_file == '.') then
call s_mpi_abort("Error: interface_file must be specified for hcid=304")
else
inquire (file=trim(interface_file), exist=file_exist)
if (file_exist) then
open (unit=10, file=trim(interface_file), status="old", action="read")
do i = 0, n_glb
read (10, '(A)') line ! Read a full line as a string
start = 1
do j = 0, p_glb
end = index(line(start:), ',') ! Find the next comma
if (end == 0) then
value = trim(adjustl(line(start:))) ! Last value in the line
else
value = trim(adjustl(line(start:start + end - 2))) ! Extract substring
start = start + end ! Move to next value
end if
read (value, *) ih(i, j) ! Convert string to numeric value
if (.not. f_is_default(normMag)) ih(i, j) = ih(i, j)*normMag
if (.not. f_is_default(normFac)) ih(i, j) = ih(i, j) + normFac
end do
end do
close (10)
else
call s_mpi_abort("Error: interface_file specified for hcid=304 does not exist")
end if
end if
end if
if (patch_icpp(patch_id)%hcid == 305) then ! 3D Axisymmetric interface from file
@:ALLOCATE(ih(0:n_glb, 0:0))
if (interface_file == '.') then
call s_mpi_abort("Error: interface_file must be specified for hcid=305")
else
inquire (file=trim(interface_file), exist=file_exist)
if (file_exist) then
open (unit=10, file=trim(interface_file), status="old", action="read")
do i = 0, n_glb
read (10, '(A)') line ! Read a full line as a string
value = trim(line)
read (value, *) ih(i, 0) ! Convert string to numeric value
if (.not. f_is_default(normMag)) ih(i, 0) = ih(i, 0)*normMag
if (.not. f_is_default(normFac)) ih(i, 0) = ih(i, 0) + normFac
end do
close (10)
else
call s_mpi_abort("Error: interface_file specified for hcid=305 does not exist")
end if
end if
end if
#:enddef
#:def Hardcoded3D()
select case (patch_icpp(patch_id)%hcid)
case (300) ! Rayleigh-Taylor instability
rhoH = 3._wp
rhoL = 1._wp
pRef = 1.e5_wp
pInt = pRef
h = 0.7_wp
lam = 0.2_wp
wl = 2._wp*pi/lam
amp = 0.025_wp/wl
intH = amp*(sin(2._wp*pi*x_cc(i)/lam - pi/2._wp) + sin(2._wp*pi*z_cc(k)/lam - pi/2._wp)) + h
alph = 5.e-1_wp*(1._wp + tanh((y_cc(j) - intH)/2.5e-3_wp))
if (alph < eps) alph = eps
if (alph > 1._wp - eps) alph = 1._wp - eps
if (y_cc(j) > intH) then
q_prim_vf(eqn_idx%adv%beg)%sf(i, j, k) = alph
q_prim_vf(eqn_idx%adv%end)%sf(i, j, k) = 1._wp - alph
q_prim_vf(eqn_idx%cont%beg)%sf(i, j, k) = alph*rhoH
q_prim_vf(eqn_idx%cont%end)%sf(i, j, k) = (1._wp - alph)*rhoL
q_prim_vf(eqn_idx%E)%sf(i, j, k) = pref + rhoH*9.81_wp*(1.2_wp - y_cc(j))
else
q_prim_vf(eqn_idx%adv%beg)%sf(i, j, k) = alph
q_prim_vf(eqn_idx%adv%end)%sf(i, j, k) = 1._wp - alph
q_prim_vf(eqn_idx%cont%beg)%sf(i, j, k) = alph*rhoH
q_prim_vf(eqn_idx%cont%end)%sf(i, j, k) = (1._wp - alph)*rhoL
pInt = pref + rhoH*9.81_wp*(1.2_wp - intH)
q_prim_vf(eqn_idx%E)%sf(i, j, k) = pInt + rhoL*9.81_wp*(intH - y_cc(j))
end if
case (301) ! (3D lung geometry in X direction, |sin(*)+sin(*)|)
h = 0.0_wp
lam = 1.0_wp
amp = patch_icpp(patch_id)%a(2)
intH = amp*abs((sin(2*pi*y_cc(j)/lam - pi/2) + sin(2*pi*z_cc(k)/lam - pi/2)) + h)
if (x_cc(i) > intH) then
q_prim_vf(eqn_idx%cont%beg)%sf(i, j, k) = patch_icpp(1)%alpha_rho(1)
q_prim_vf(eqn_idx%cont%end)%sf(i, j, k) = patch_icpp(1)%alpha_rho(2)
q_prim_vf(eqn_idx%E)%sf(i, j, k) = patch_icpp(1)%pres
q_prim_vf(eqn_idx%adv%beg)%sf(i, j, k) = patch_icpp(1)%alpha(1)
q_prim_vf(eqn_idx%adv%end)%sf(i, j, k) = patch_icpp(1)%alpha(2)
end if
case (302) ! 3D Jet with IGR
ux_th = 10*sqrt(1.4*0.4)
ux_am = 0.0*sqrt(1.4)
p_th = 2.0_wp
p_am = 1.0_wp
rho_th = 1._wp
rho_am = 1._wp
y_th = 0.0_wp
z_th = 0.0_wp
r_th = 1._wp
eps_smooth = 1._wp
eps = 1e-6
r = sqrt((y_cc(j) - y_th)**2._wp + (z_cc(k) - z_th)**2._wp)
rcut = f_cut_on(r - r_th, eps_smooth)
xcut = f_cut_on(x_cc(i), eps_smooth)
q_prim_vf(eqn_idx%mom%beg)%sf(i, j, k) = ux_th*rcut*xcut + ux_am
q_prim_vf(eqn_idx%mom%beg + 1)%sf(i, j, k) = 0._wp
q_prim_vf(eqn_idx%mom%end)%sf(i, j, k) = 0._wp
if (num_fluids == 1) then
q_prim_vf(eqn_idx%cont%beg)%sf(i, j, k) = (rho_th - rho_am)*rcut*xcut + rho_am
else
q_prim_vf(eqn_idx%adv%beg)%sf(i, j, k) = (1._wp - 2._wp*eps)*rcut*xcut + eps
q_prim_vf(eqn_idx%cont%beg)%sf(i, j, k) = rho_th*q_prim_vf(eqn_idx%adv%beg)%sf(i, j, k)
q_prim_vf(eqn_idx%cont%end)%sf(i, j, k) = rho_am*(1._wp - q_prim_vf(eqn_idx%adv%beg)%sf(i, j, k))
end if
q_prim_vf(eqn_idx%E)%sf(i, j, k) = p_th*rcut*xcut + p_am
case (303) ! 3D Multijet
eps_smooth = 3.0_wp
ux_th = 10*sqrt(1.4*0.4)
ux_am = 2.5*sqrt(1.4*0.4)
p_th = 0.8_wp
p_am = 0.4_wp
rho_th = 1._wp
rho_am = 1._wp
eps = 1e-6
rcut = rcut_arr(j, k)
xcut = f_cut_on(x_cc(i), eps_smooth)
q_prim_vf(eqn_idx%mom%beg)%sf(i, j, k) = ux_th*rcut*xcut + ux_am
q_prim_vf(eqn_idx%mom%beg + 1)%sf(i, j, k) = 0._wp
q_prim_vf(eqn_idx%mom%end)%sf(i, j, k) = 0._wp
if (num_fluids == 1) then
q_prim_vf(eqn_idx%cont%beg)%sf(i, j, k) = (rho_th - rho_am)*rcut*xcut + rho_am
else
q_prim_vf(eqn_idx%adv%beg)%sf(i, j, k) = (1._wp - 2._wp*eps)*rcut*xcut + eps
q_prim_vf(eqn_idx%cont%beg)%sf(i, j, k) = rho_th*q_prim_vf(eqn_idx%adv%beg)%sf(i, j, k)
q_prim_vf(eqn_idx%cont%end)%sf(i, j, k) = rho_am*(1._wp - q_prim_vf(eqn_idx%adv%beg)%sf(i, j, k))
end if
q_prim_vf(eqn_idx%E)%sf(i, j, k) = p_th*rcut*xcut + p_am
case (304) ! 3D Interface from file cartesian
alph = 0.5_wp*(1 + (1._wp - 2._wp*eps)*tanh((ih(start_idx(2) + j, start_idx(3) + k) - x_cc(i))*(0.5_wp/dx_min)))
q_prim_vf(eqn_idx%adv%beg)%sf(i, j, k) = alph
q_prim_vf(eqn_idx%adv%end)%sf(i, j, k) = 1._wp - alph
q_prim_vf(eqn_idx%cont%beg)%sf(i, j, k) = q_prim_vf(eqn_idx%adv%beg)%sf(i, j, k)*(950._wp/1000._wp)
q_prim_vf(eqn_idx%cont%end)%sf(i, j, k) = q_prim_vf(eqn_idx%adv%end)%sf(i, j, k)*(1._wp/1000._wp)
q_prim_vf(eqn_idx%E)%sf(i, j, k) = p0_ic + (q_prim_vf(eqn_idx%cont%beg)%sf(i, j, k) + q_prim_vf(eqn_idx%cont%end)%sf(i, &
& j, k))*g0_ic*(ih(start_idx(2) + j, start_idx(3) + k) - x_cc(i))
if (surface_tension) q_prim_vf(eqn_idx%c)%sf(i, j, k) = alph
case (305) ! 3D Interface from file axisymmetric
alph = 0.5_wp*(1 + (1._wp - 2._wp*eps)*tanh((ih(start_idx(2) + j, 0) - x_cc(i))*(0.01_wp/dx_min)))
q_prim_vf(eqn_idx%adv%beg)%sf(i, j, k) = alph
q_prim_vf(eqn_idx%adv%end)%sf(i, j, k) = 1._wp - alph
q_prim_vf(eqn_idx%cont%beg)%sf(i, j, k) = q_prim_vf(eqn_idx%adv%beg)%sf(i, j, k)*1._wp
q_prim_vf(eqn_idx%cont%end)%sf(i, j, k) = q_prim_vf(eqn_idx%adv%end)%sf(i, j, k)*(1._wp/950._wp)
q_prim_vf(eqn_idx%E)%sf(i, j, k) = p0_ic + (q_prim_vf(eqn_idx%cont%beg)%sf(i, j, k) + q_prim_vf(eqn_idx%cont%end)%sf(i, &
& j, k))*g0_ic*(ih(start_idx(1) + i, start_idx(3) + k) - y_cc(j))
if (surface_tension) q_prim_vf(eqn_idx%c)%sf(i, j, k) = alph
case (370) ! 3D extrusion of 2D profile from external data
! This hardcoded case extrudes a 2D profile to initialize a 3D simulation domain
@: HardcodedReadValues()
case (380) ! Taylor-Green vortex
! This is patch is hard-coded for test suite optimization used in the 3D_TaylorGreenVortex case: This analytic patch used
! geometry 9
Mach = 0.1
if (patch_id == 1) then
q_prim_vf(eqn_idx%E)%sf(i, j, &
& k) = 101325 + (Mach**2*376.636429464809**2/16)*(cos(2*x_cc(i)/1) + cos(2*y_cc(j)/1))*(cos(2*z_cc(k)/1) + 2)
q_prim_vf(eqn_idx%mom%beg + 0)%sf(i, j, k) = Mach*376.636429464809*sin(x_cc(i)/1)*cos(y_cc(j)/1)*sin(z_cc(k)/1)
q_prim_vf(eqn_idx%mom%beg + 1)%sf(i, j, k) = -Mach*376.636429464809*cos(x_cc(i)/1)*sin(y_cc(j)/1)*sin(z_cc(k)/1)
end if
case default
call s_int_to_str(patch_id, iStr)
call s_mpi_abort("Invalid hcid specified for patch " // trim(iStr))
end select
#:enddef