Skip to content

Commit 9630d35

Browse files
authored
Fix Benchmark & Add Monopole Checks & Add Monopole Tests (#497)
1 parent 0b1abfa commit 9630d35

File tree

23 files changed

+1876
-32
lines changed

23 files changed

+1876
-32
lines changed

benchmarks/viscous_weno5_sgb_mono/case.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
procs = DICT["nodes"] * DICT["tasks_per_node"]
2929
ncells = math.floor(ppg * procs * ARGS["gbpp"])
3030
s = math.floor((ncells / 2.0) ** (1/3))
31-
Nx, Ny, Nz = 2*s, s, s
31+
Nx, Ny, Nz = s, s, 2*s
3232

3333
x0 = 10.E-04
3434
y0 = 10.E-04
@@ -86,8 +86,8 @@
8686
cfl = 0.01
8787
Ldomain = 20.E-03
8888
L = Ldomain/x0
89-
dx = L/float(Nx)
90-
dt = cfl*dx*c0/cact
89+
dz = L/float(Nz)
90+
dt = cfl*dz*c0/cact
9191
Lpulse = 0.3*Ldomain
9292
Tpulse = Lpulse/cact
9393

@@ -98,12 +98,12 @@
9898
# ==========================================================
9999

100100
# Computational Domain Parameters ==========================
101-
'x_domain%beg' : -10.E-03/x0,
102-
'x_domain%end' : 10.E-03/x0,
101+
'x_domain%beg' : -5.E-03/x0,
102+
'x_domain%end' : 5.E-03/x0,
103103
'y_domain%beg' : -5.E-03/y0,
104-
'y_domain%end' : 5.E-03/y0,
105-
'z_domain%beg' : -5.E-03/z0,
106-
'z_domain%end' : 5.E-03/z0,
104+
'y_domain%end' : 5.E-03/y0,
105+
'z_domain%beg' : -10.E-03/z0,
106+
'z_domain%end' : 10.E-03/z0,
107107
'stretch_x' : 'F',
108108
'cyl_coord' : 'F',
109109
'm' : Nx,
@@ -154,9 +154,9 @@
154154
'patch_icpp(1)%x_centroid' : 0.,
155155
'patch_icpp(1)%y_centroid' : 0.,
156156
'patch_icpp(1)%z_centroid' : 0.,
157-
'patch_icpp(1)%length_x' : 20.E-03/x0,
157+
'patch_icpp(1)%length_x' : 10.E-03/x0,
158158
'patch_icpp(1)%length_y' : 10.E-03/y0,
159-
'patch_icpp(1)%length_z' : 10.E-03/z0,
159+
'patch_icpp(1)%length_z' : 20.E-03/z0,
160160
'patch_icpp(1)%vel(1)' : 0.0,
161161
'patch_icpp(1)%vel(2)' : 0.0,
162162
'patch_icpp(1)%vel(3)' : 0.0,
@@ -172,9 +172,9 @@
172172
'patch_icpp(2)%x_centroid' : 0.,
173173
'patch_icpp(2)%y_centroid' : 0.,
174174
'patch_icpp(2)%z_centroid' : 0.,
175-
'patch_icpp(2)%length_x' : 5.E-03/x0,
175+
'patch_icpp(2)%length_x' : 10.E-03/x0,
176176
'patch_icpp(2)%length_y' : 10.E-03/y0,
177-
'patch_icpp(2)%length_z' : 10.E-03/z0,
177+
'patch_icpp(2)%length_z' : 5.E-03/z0,
178178
'patch_icpp(2)%alter_patch(1)' : 'T',
179179
'patch_icpp(2)%vel(1)' : 0.0,
180180
'patch_icpp(2)%vel(2)' : 0.0,
@@ -230,7 +230,8 @@
230230
# Acoustic source ==========================================
231231
'Monopole' : 'T',
232232
'num_mono' : 1,
233-
'Mono(1)%loc(1)' : -5.E-03/x0,
233+
'Mono(1)%support' : 4,
234+
'Mono(1)%loc(3)' : -5.E-03/x0,
234235
'Mono(1)%npulse' : 1,
235236
'Mono(1)%dir' : 1.,
236237
'Mono(1)%pulse' : 1,

src/simulation/m_checker.fpp

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ contains
2929
call s_check_inputs_riemann_solver
3030
call s_check_inputs_time_stepping
3131
call s_check_inputs_model_eqns
32+
if (monopole) call s_check_inputs_monopole
3233
if (hypoelasticity) call s_check_inputs_hypoelasticity
3334
if (bubbles) call s_check_inputs_bubbles
3435
if (adap_dt) call s_check_inputs_adapt_dt
@@ -159,6 +160,82 @@ contains
159160
end if
160161
end subroutine s_check_inputs_model_eqns
161162

163+
!> Checks constraints on monopole parameters
164+
subroutine s_check_inputs_monopole
165+
integer :: j
166+
character(len=5) :: jStr
167+
168+
if (num_mono == dflt_int) then
169+
call s_mpi_abort('num_mono must be specified for monopole. Exiting ...')
170+
elseif (num_mono < 0) then
171+
call s_mpi_abort('num_mono must be non-negative. Exiting ...')
172+
end if
173+
174+
do j = 1, num_mono
175+
call s_int_to_str(j, jStr)
176+
if (mono(j)%support == dflt_int) then
177+
call s_mpi_abort('mono('//trim(jStr)//')%support must be '// &
178+
'specified. Exiting ...')
179+
elseif (f_is_default(mono(j)%mag)) then
180+
call s_mpi_abort('mono('//trim(jStr)//')%mag must be '// &
181+
'specified. Exiting ...')
182+
elseif (mono(j)%mag <= 0d0) then
183+
call s_mpi_abort('mono('//trim(jStr)//')%mag must be '// &
184+
'positive. Exiting ...')
185+
end if
186+
187+
if (n == 0) then ! 1D
188+
if (.not. any(mono(j)%support == (/0, 1/))) then ! undocumented support 0
189+
call s_mpi_abort('Only Mono(i)support = 1 is allowed for '// &
190+
'1D simulations. Exiting ...')
191+
end if
192+
if (mono(j)%support == 1 .and. f_is_default(mono(j)%loc(1))) then
193+
call s_mpi_abort('mono_loc(1) must be specified for '// &
194+
'Mono(i)support = 1. Exiting ...')
195+
end if
196+
elseif (p == 0) then ! 2D
197+
if (.not. any(mono(j)%support == (/1, 2, 3, 4, 5/))) then
198+
call s_mpi_abort('Only Mono(i)support = 1, 2, 3, 4, or 5 is '// &
199+
'allowed for 2D simulations. Exiting ...')
200+
end if
201+
if (any(mono(j)%support == (/1, 2, 3, 5/)) .and. &
202+
(f_is_default(mono(j)%loc(1)) .or. &
203+
f_is_default(mono(j)%loc(2)))) then
204+
call s_mpi_abort('mono('//trim(jStr)//')%loc(1:2) must be '// &
205+
'specified for Mono(i)support = 1, 3, or 5. '// &
206+
'Exiting ...')
207+
elseif (mono(j)%support == 4 .and. f_is_default(mono(j)%loc(1))) then
208+
call s_mpi_abort('mono('//trim(jStr)//')%loc(1) must be '// &
209+
'specified for Mono(i)support = 4. Exiting ...')
210+
end if
211+
else ! 3D
212+
if (.not. any(mono(j)%support == (/3, 4, 5, 6/))) then
213+
call s_mpi_abort('Only Mono(i)support = 3, 4, 5, or 6 is '// &
214+
'allowed for 3D simulations. Exiting ...')
215+
elseif (mono(j)%support == 6 .and. (.not. cyl_coord)) then
216+
call s_mpi_abort('Mono(i)support = 6 requires cyl_coord = true. '// &
217+
'Exiting ...')
218+
elseif (cyl_coord .and. mono(j)%support /= 6) then
219+
call s_mpi_abort('cyl_coord = true requires Mono(i)support = 6. '// &
220+
'Exiting ...')
221+
end if
222+
if (any(mono(j)%support == (/3, 5, 6/)) .and. &
223+
(f_is_default(mono(j)%loc(1)) .or. &
224+
f_is_default(mono(j)%loc(2)) .or. &
225+
f_is_default(mono(j)%loc(3)))) then
226+
call s_mpi_abort('mono('//trim(jStr)//')%loc(1:3) must be '// &
227+
'specified for Mono(i)support = 3, 5, or 6. '// &
228+
'Exiting ...')
229+
elseif (mono(j)%support == 4 .and. &
230+
(f_is_default(mono(j)%loc(3)))) then
231+
call s_mpi_abort('mono('//trim(jStr)//')%loc(3) must be '// &
232+
'specified for Mono(i)support = 4. Exiting ...')
233+
end if
234+
end if
235+
end do
236+
237+
end subroutine s_check_inputs_monopole
238+
162239
!> Checks constraints on hypoelasticity parameters
163240
subroutine s_check_inputs_hypoelasticity
164241
if (riemann_solver /= 1) then

src/simulation/m_global_parameters.fpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ contains
595595

596596
! Monopole source
597597
monopole = .false.
598-
num_mono = 1
598+
num_mono = dflt_real
599599

600600
! Surface tension
601601
sigma = dflt_real
@@ -619,16 +619,16 @@ contains
619619
mono(j)%mag = dflt_real
620620
mono(j)%length = dflt_real
621621
mono(j)%delay = dflt_real
622-
mono(j)%dir = 1.d0
623-
mono(j)%npulse = 1.d0
624-
mono(j)%pulse = 1
625-
mono(j)%support = 1
622+
mono(j)%dir = dflt_real
623+
mono(j)%npulse = dflt_int
624+
mono(j)%pulse = dflt_int
625+
mono(j)%support = dflt_int
626626
mono(j)%foc_length = dflt_real
627627
mono(j)%aperture = dflt_real
628+
mono(j)%support_width = dflt_real
628629
! The author suggested the support width is typically on the order of
629-
! the width of the characteristic cells. Here, we choose 2.5 cell width
630-
! as the default value.
631-
mono(j)%support_width = 2.5d0
630+
! the width of the characteristic cells.
631+
! The default value of support_width is 2.5 cell widths.
632632
end do
633633

634634
fd_order = dflt_int

src/simulation/m_monopole.fpp

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,39 @@ contains
6969
@:ALLOCATE_GLOBAL(mag(1:num_mono), support(1:num_mono), length(1:num_mono), npulse(1:num_mono), pulse(1:num_mono), dir(1:num_mono), delay(1:num_mono), loc_mono(1:3, 1:num_mono), foc_length(1:num_mono), aperture(1:num_mono), support_width(1:num_mono))
7070

7171
do i = 1, num_mono
72+
do j = 1, 3
73+
loc_mono(j, i) = mono(i)%loc(j)
74+
end do
7275
mag(i) = mono(i)%mag
7376
support(i) = mono(i)%support
7477
length(i) = mono(i)%length
75-
npulse(i) = mono(i)%npulse
76-
pulse(i) = mono(i)%pulse
77-
dir(i) = mono(i)%dir
78-
delay(i) = mono(i)%delay
7978
foc_length(i) = mono(i)%foc_length
8079
aperture(i) = mono(i)%aperture
81-
support_width(i) = mono(i)%support_width
82-
do j = 1, 3
83-
loc_mono(j, i) = mono(i)%loc(j)
84-
end do
80+
if (mono(i)%npulse == dflt_int) then
81+
npulse(i) = 1
82+
else
83+
npulse(i) = mono(i)%npulse
84+
end if
85+
if (mono(i)%pulse == dflt_int) then
86+
pulse(i) = 1
87+
else
88+
pulse(i) = mono(i)%pulse
89+
end if
90+
if (f_is_default(mono(i)%dir)) then
91+
dir(i) = 1d0
92+
else
93+
dir(i) = mono(i)%dir
94+
end if
95+
if (f_is_default(mono(i)%delay)) then
96+
delay(i) = 0d0
97+
else
98+
delay(i) = mono(i)%delay
99+
end if
100+
if (f_is_default(mono(i)%support_width)) then
101+
support_width(i) = 2.5d0
102+
else
103+
support_width(i) = mono(i)%support_width
104+
end if
85105
end do
86106
!$acc update device(mag, support, length, npulse, pulse, dir, delay, foc_length, aperture, loc_mono, support_width)
87107

@@ -332,7 +352,6 @@ contains
332352
if (the_time > t0 .and. the_time < sigt) then
333353
f_g = mag(nm)
334354
end if
335-
else
336355
end if
337356

338357
end function f_g

0 commit comments

Comments
 (0)