Skip to content

Commit dfe522c

Browse files
committed
update things
1 parent dc2a4c4 commit dfe522c

File tree

2 files changed

+88
-72
lines changed

2 files changed

+88
-72
lines changed

src/simulation/m_sim_helpers.f90

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ module m_sim_helpers
1414

1515
private; public :: s_compute_enthalpy, &
1616
s_compute_stability_from_dt, &
17-
s_compute_dt_from_cfl
17+
s_compute_dt_from_cfl, &
18+
s_check_cells
1819

1920
contains
2021

@@ -247,4 +248,84 @@ subroutine s_compute_dt_from_cfl(vel, c, max_dt, rho, Re_l, j, k, l)
247248

248249
end subroutine s_compute_dt_from_cfl
249250

251+
subroutine s_check_cells(q_cons_Vf, q_prim_Vf, t_step, stage, errors)
252+
253+
type(scalar_field), dimension(sys_size) :: q_cons_vf, q_prim_vf
254+
integer, intent(in) :: t_step, stage
255+
integer :: j, k, l, i
256+
integer errors
257+
logical :: exists
258+
259+
character(LEN=name_len) :: file_name = 'comp_debug.txt'
260+
character(LEN=path_len + name_len) :: file_path
261+
character(100) :: str_format
262+
263+
! Opening the run-time information file
264+
file_path = trim(case_dir)//'/'//trim(file_name)
265+
266+
str_format = "(I9, A, I3, A, I4, I4, I4, A, I2, A, I5, A, I5, I5, I5)"
267+
268+
open (12, FILE=trim(file_path), &
269+
STATUS='replace')
270+
271+
errors = 0
272+
273+
! Check all variables for NaNs
274+
do i = 1, sys_size
275+
!$acc update host(q_cons_vf(i)%sf)
276+
do l = 0, p
277+
do k = 0, n
278+
do j = 0, m
279+
if (ieee_is_nan(q_cons_vf(i)%sf(j, k, l))) then
280+
write(12, str_format) t_step, " NaN(s) in conservative variables after RK stage ", &
281+
stage, " at (j,k,l) ", j, k, l, " equation", i, " proc", proc_rank, &
282+
" (m, n, p)", m, n, p
283+
errors = errors + 1
284+
end if
285+
end do
286+
end do
287+
end do
288+
end do
289+
290+
! Check for invalid volume fractions
291+
do i = advxb, advxe
292+
do l = 0, p
293+
do k = 0, n
294+
do j = 0, m
295+
if (q_cons_vf(i)%sf(j, k, l) < 0d0) then
296+
write(12, str_format) t_step, " Volume fraction < 0 after RK stage ", &
297+
stage, " at (j,k,l) ", j, k, l, " equation", i, " proc", proc_rank, &
298+
" (m, n, p)", m, n, p
299+
errors = errors + 1
300+
elseif (q_cons_vf(i)%sf(j, k, l) > 1d0 + verysmall) then
301+
write(12, str_format) t_step, " Volume fraction > 1 after RK stage ", &
302+
stage, " at (j,k,l) ", j, k, l, " equation", i, " proc", proc_rank, &
303+
" (m, n, p)", m, n, p
304+
errors = errors + 1
305+
end if
306+
end do
307+
end do
308+
end do
309+
end do
310+
311+
! Check for invalid densities
312+
do i = contxb, contxe
313+
do l = 0, p
314+
do k = 0, n
315+
do j = 0, m
316+
if (q_cons_vf(advxb + i -1)%sf(j, k, l) < 0d0 .and. q_cons_vf(i)%sf(j, k, l) < 0d0 .or. &
317+
q_cons_vf(advxb + i -1)%sf(j, k, l) > 0d0 .and. q_cons_Vf(i)%sf(j, k, l) < 0d0) then
318+
print*, q_cons_vf(advxb + i - 1)%sf(j, k, l), q_cons_vf(i)%sf(j, k, l)
319+
write(12, str_format) t_step, " Density is negative after RK stage ", &
320+
stage, " at (j,k,l) ", j, k, l, " equation", i, " proc", proc_rank, &
321+
" (m, n, p)", m, n, p
322+
errors = errors + 1
323+
end if
324+
end do
325+
end do
326+
end do
327+
end do
328+
329+
end subroutine
330+
250331
end module m_sim_helpers

src/simulation/m_time_steppers.fpp

Lines changed: 6 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,10 @@ contains
866866
call s_pressure_relaxation_procedure(q_cons_ts(1)%vf)
867867
end if
868868

869+
q_cons_ts(1)%vf(advxb)%sf(10, 10, 0) = -1
870+
q_cons_ts(1)%vf(contxe)%sf(10, 10, 0) = -1
871+
q_Cons_ts(1)%vf(advxe)%sf(5, 5, 0) = 1.1
872+
869873
if (comp_debug) call s_comprehensive_debug(q_cons_ts(1)%vf, q_prim_vf, t_step, 3)
870874

871875
if (adv_n) call s_comp_alpha_from_n(q_cons_ts(1)%vf)
@@ -1034,79 +1038,10 @@ contains
10341038

10351039
type(scalar_field), dimension(sys_size) :: q_cons_vf, q_prim_vf
10361040
integer, intent(in) :: t_step, stage
1037-
integer :: j, k, l, i
1038-
integer errors
1039-
logical :: exists
1040-
1041-
character(LEN=name_len) :: file_name = 'comp_debug.txt'
1042-
character(LEN=path_len + name_len) :: file_path
1043-
character(100) :: str_format
1044-
1045-
! Opening the run-time information file
1046-
file_path = trim(case_dir)//'/'//trim(file_name)
1047-
1048-
str_format = "(I9, A, I3, A, I4, I4, I4, A, I2, A, I5, A, I5, I5, I5)"
10491041

1050-
open (12, FILE=trim(file_path), &
1051-
STATUS='replace')
1042+
integer :: errors
10521043

1053-
errors = 0
1054-
1055-
! Check all variables for NaNs
1056-
do i = 1, sys_size
1057-
!$acc update host(q_cons_vf(i)%sf)
1058-
do l = 0, p
1059-
do k = 0, n
1060-
do j = 0, m
1061-
if (ieee_is_nan(q_cons_vf(i)%sf(j, k, l))) then
1062-
write(12, str_format) t_step, " NaN(s) in conservative variables after RK stage ", &
1063-
stage, " at (j,k,l) ", j, k, l, " equation", i, " proc", proc_rank, &
1064-
" (m, n, p)", m, n, p
1065-
errors = errors + 1
1066-
end if
1067-
end do
1068-
end do
1069-
end do
1070-
end do
1071-
1072-
! Check for invalid volume fractions
1073-
do i = advxb, advxe
1074-
do l = 0, p
1075-
do k = 0, n
1076-
do j = 0, m
1077-
if (q_cons_vf(i)%sf(j, k, l) < 0d0) then
1078-
write(12, str_format) t_step, " Volume fraction < 0 after RK stage ", &
1079-
stage, " at (j,k,l) ", j, k, l, " equation", i, " proc", proc_rank, &
1080-
" (m, n, p)", m, n, p
1081-
errors = errors + 1
1082-
elseif (q_cons_vf(i)%sf(j, k, l) > 1d0 + verysmall) then
1083-
write(12, str_format) t_step, " Volume fraction > 1 after RK stage ", &
1084-
stage, " at (j,k,l) ", j, k, l, " equation", i, " proc", proc_rank, &
1085-
" (m, n, p)", m, n, p
1086-
errors = errors + 1
1087-
end if
1088-
end do
1089-
end do
1090-
end do
1091-
end do
1092-
1093-
! Check for invalid densities
1094-
do i = contxb, contxe
1095-
do l = 0, p
1096-
do k = 0, n
1097-
do j = 0, m
1098-
if (q_cons_vf(advxb + i -1)%sf(j, k, l) < 0d0 .and. q_cons_vf(i)%sf(j, k, l) < 0d0 .or. &
1099-
q_cons_vf(advxb + i -1)%sf(j, k, l) > 0d0 .and. q_cons_Vf(i)%sf(j, k, l) < 0d0) then
1100-
print*, q_cons_vf(advxb + i - 1)%sf(j, k, l), q_cons_vf(i)%sf(j, k, l)
1101-
write(12, str_format) t_step, " Density is negative after RK stage ", &
1102-
stage, " at (j,k,l) ", j, k, l, " equation", i, " proc", proc_rank, &
1103-
" (m, n, p)", m, n, p
1104-
errors = errors + 1
1105-
end if
1106-
end do
1107-
end do
1108-
end do
1109-
end do
1044+
call s_check_cells(q_cons_vf, q_prim_vf, t_step, stage, errors)
11101045

11111046
if (errors /= 0) then
11121047
close(12)

0 commit comments

Comments
 (0)