Skip to content

Commit 9d27a2d

Browse files
sbryngelsonclaude
andauthored
Fix 6 low-risk pre-process bugs (batch) (#1241)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 506c6f5 commit 9d27a2d

6 files changed

Lines changed: 26 additions & 18 deletions

File tree

src/common/m_constants.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module m_constants
4444
! Interface Compression
4545
real(wp), parameter :: dflt_ic_eps = 1e-4_wp !< Ensure compression is only applied to surface cells in THINC
4646
real(wp), parameter :: dflt_ic_beta = 1.6_wp !< Sharpness parameter's default value used in THINC
47-
integer, parameter :: moncon_cutoff = 1e-8_wp !< Monotonicity constraint's limiter to prevent extremas in THINC
47+
real(wp), parameter :: moncon_cutoff = 1e-8_wp !< Monotonicity constraint's limiter to prevent extremas in THINC
4848

4949
! Chemistry
5050
real(wp), parameter :: dflt_T_guess = 1200._wp ! Default guess for temperature (when a previous value is not available)

src/pre_process/m_assign_variables.fpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ module m_assign_variables
3838
!> Skeleton of s_assign_patch_mixture_primitive_variables
3939
!! and s_assign_patch_species_primitive_variables
4040
!! @param patch_id is the patch identifier
41-
!! @param j (x) cell index in which the mixture or species primitive variables from the indicated patch areassigned
42-
!! @param k (y,th) cell index in which the mixture or species primitive variables from the indicated patch areassigned
43-
!! @param l (z) cell index in which the mixture or species primitive variables from the indicated patch areassigned
41+
!! @param j (x) cell index in which the mixture or species primitive variables from the indicated patch are assigned
42+
!! @param k (y,th) cell index in which the mixture or species primitive variables from the indicated patch are assigned
43+
!! @param l (z) cell index in which the mixture or species primitive variables from the indicated patch are assigned
4444
!! @param eta pseudo volume fraction
4545
!! @param q_prim_vf Primitive variables
4646
!! @param patch_id_fp Array to track patch ids
@@ -233,7 +233,6 @@ contains
233233
if (qbmm) then
234234
do i = 1, nb
235235
R3bar = R3bar + weight(i)*0.5_wp*(q_prim_vf(bubxb + 1 + (i - 1)*nmom)%sf(j, k, l))**3._wp
236-
R3bar = R3bar + weight(i)*0.5_wp*(q_prim_vf(bubxb + 1 + (i - 1)*nmom)%sf(j, k, l))**3._wp
237236
end do
238237
else
239238
do i = 1, nb

src/pre_process/m_grid.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impure subroutine s_generate_serial_grid
131131
end do
132132

133133
y_cb = y_cb*length
134-
y_cc(0:m) = (y_cb(0:n) + y_cb(-1:n - 1))/2._wp
134+
y_cc(0:n) = (y_cb(0:n) + y_cb(-1:n - 1))/2._wp
135135

136136
dy = minval(y_cb(0:n) - y_cb(-1:n - 1))
137137

@@ -168,7 +168,7 @@ impure subroutine s_generate_serial_grid
168168
end do
169169

170170
z_cb = z_cb*length
171-
z_cc(0:m) = (z_cb(0:p) + z_cb(-1:p - 1))/2._wp
171+
z_cc(0:p) = (z_cb(0:p) + z_cb(-1:p - 1))/2._wp
172172

173173
dz = minval(z_cb(0:p) - z_cb(-1:p - 1))
174174

src/pre_process/m_mpi_proxy.fpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ contains
7676
call MPI_BCAST(patch_bc(i)%${VAR}$, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
7777
#:endfor
7878

79-
#:for VAR in ['vel', 'angular_vel', 'angles']
80-
call MPI_BCAST(patch_ib(i)%${VAR}$, 3, mpi_p, 0, MPI_COMM_WORLD, ierr)
81-
#:endfor
82-
8379
call MPI_BCAST(patch_bc(i)%radius, 1, mpi_p, 0, MPI_COMM_WORLD, ierr)
8480

8581
#:for VAR in ['centroid', 'length']
@@ -120,7 +116,11 @@ contains
120116
if (chemistry) then
121117
call MPI_BCAST(patch_icpp(i)%Y, size(patch_icpp(i)%Y), mpi_p, 0, MPI_COMM_WORLD, ierr)
122118
end if
123-
! Broadcast IB variables
119+
! Broadcast IB variables: patch_ib is indexed 1:num_patches_max,
120+
! not 1:num_bc_patches_max, so these must live in the num_patches_max loop.
121+
#:for VAR in ['vel', 'angular_vel', 'angles']
122+
call MPI_BCAST(patch_ib(i)%${VAR}$, size(patch_ib(i)%${VAR}$), mpi_p, 0, MPI_COMM_WORLD, ierr)
123+
#:endfor
124124
call MPI_BCAST(patch_ib(i)%geometry, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
125125
call MPI_BCAST(patch_ib(i)%model_filepath, len(patch_ib(i)%model_filepath), MPI_CHARACTER, 0, MPI_COMM_WORLD, ierr)
126126
call MPI_BCAST(patch_ib(i)%model_threshold, 1, mpi_p, 0, MPI_COMM_WORLD, ierr)

src/pre_process/m_perturbation.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ contains
8383
perturb_alpha = q_prim_vf(E_idx + perturb_flow_fluid)%sf(i, j, k)
8484
call random_number(rand_real)
8585
rand_real = rand_real*perturb_flow_mag
86-
q_prim_vf(mom_idx%beg)%sf(i, j, k) = (1._wp + rand_real)*q_prim_vf(mom_idx%beg)%sf(i, j, k)
8786
q_prim_vf(mom_idx%end)%sf(i, j, k) = rand_real*q_prim_vf(mom_idx%beg)%sf(i, j, k)
87+
q_prim_vf(mom_idx%beg)%sf(i, j, k) = (1._wp + rand_real)*q_prim_vf(mom_idx%beg)%sf(i, j, k)
8888
if (bubbles_euler) then
8989
q_prim_vf(alf_idx)%sf(i, j, k) = (1._wp + rand_real)*q_prim_vf(alf_idx)%sf(i, j, k)
9090
end if
@@ -245,7 +245,7 @@ contains
245245

246246
!> This subroutine computes velocity perturbations for a temporal mixing
247247
!! layer with a hyperbolic tangent mean streamwise velocity
248-
!! profile, using an inverter version of the spectrum-based
248+
!! profile, using an inverted version of the spectrum-based
249249
!! synthetic turbulence generation method proposed by
250250
!! Guo et al. (2023, JFM).
251251
subroutine s_perturb_mixlayer(q_prim_vf)

src/pre_process/m_start_up.fpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
!! @file
33
!! @brief Contains module m_start_up
44

5+
#:include 'macros.fpp'
6+
57
!> @brief Reads and validates user inputs, loads existing grid/IC data, and initializes pre-process modules
68
module m_start_up
79

@@ -767,7 +769,8 @@ contains
767769

768770
real(wp), intent(inout) :: start, finish
769771

770-
integer :: j, k
772+
integer :: j, k, l
773+
real(wp) :: r2
771774

772775
! Setting up the grid and the initial condition. If the grid is read in from
773776
! preexisting grid data files, it is checked for consistency. If the grid is
@@ -787,10 +790,16 @@ contains
787790

788791
! hard-coded psi
789792
if (hyper_cleaning) then
790-
do j = 0, m
793+
@:ASSERT(psi_idx > 0, "hyper_cleaning requires psi_idx to be set")
794+
do l = 0, p
791795
do k = 0, n
792-
q_cons_vf(psi_idx)%sf(j, k, 0) = 1d-2*exp(-(x_cc(j)**2 + y_cc(k)**2)/(2.0*0.05**2))
793-
q_prim_vf(psi_idx)%sf(j, k, 0) = q_cons_vf(psi_idx)%sf(j, k, 0)
796+
do j = 0, m
797+
r2 = x_cc(j)**2
798+
if (n > 0) r2 = r2 + y_cc(k)**2
799+
if (p > 0) r2 = r2 + z_cc(l)**2
800+
q_cons_vf(psi_idx)%sf(j, k, l) = 1.0e-2_wp*exp(-r2/(2.0_wp*0.05_wp**2))
801+
q_prim_vf(psi_idx)%sf(j, k, l) = q_cons_vf(psi_idx)%sf(j, k, l)
802+
end do
794803
end do
795804
end do
796805
end if

0 commit comments

Comments
 (0)