Skip to content

Commit 7e4d356

Browse files
author
Daniel Vickers
committed
The namelist refactor modified the merge and made the particle beds invalid. Also additional allocation protection
1 parent 2be4b64 commit 7e4d356

5 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/common/m_model.fpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,12 @@ contains
983983
dx_local = minval(dx); dy_local = minval(dy)
984984
if (p /= 0) dz_local = minval(dz)
985985

986-
@:ALLOCATE(models(num_ibs))
986+
! AMD HSA rejects zero-size GPU allocations; only create GPU mapping when there are actual models.
987+
if (num_ibs > 0) then
988+
@:ALLOCATE(models(num_ibs))
989+
else
990+
allocate (models(0))
991+
end if
987992
allocate (stl_bounding_boxes(num_ibs,1:3,1:3))
988993

989994
do patch_id = 1, num_ibs

src/simulation/m_global_parameters.fpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ module m_global_parameters
166166
#endif
167167
type(bounds_info) :: x_domain, y_domain, z_domain
168168
type(bounds_info) :: neighbor_domain_x, neighbor_domain_y, neighbor_domain_z
169-
integer :: ib_neighborhood_radius, num_gbl_ibs, num_local_ibs
169+
integer :: num_gbl_ibs, num_local_ibs
170170
$:GPU_DECLARE(create='[x_domain, y_domain, z_domain, neighbor_domain_x, neighbor_domain_y, neighbor_domain_z]')
171171
$:GPU_DECLARE(create='[down_sample]')
172172

@@ -263,7 +263,6 @@ module m_global_parameters
263263
!> @{
264264
type(ib_patch_parameters), dimension(num_ib_patches_max_namelist) :: patch_ib !< Immersed boundary patch parameters
265265
integer, dimension(num_local_ibs_max) :: local_ib_patch_ids !< lookup table of IBs in the local compute domain
266-
integer :: num_particle_beds !< Number of particle bed specifications
267266
type(particle_bed_parameters), dimension(num_particle_beds_max) :: particle_bed !< Particle bed specifications
268267
integer, allocatable, dimension(:,:,:) :: ib_neighbor_ranks !< MPI ranks of neighborhood domains, indexed (-N:N,-N:N,-N:N)
269268
type(vec3_dt), allocatable, dimension(:) :: airfoil_grid_u, airfoil_grid_l

src/simulation/m_ibm.fpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,11 @@ contains
15371537
end if
15381538

15391539
if (allocated(models)) then
1540-
@:DEALLOCATE(models)
1540+
if (size(models) > 0) then
1541+
@:DEALLOCATE(models)
1542+
else
1543+
deallocate (models)
1544+
end if
15411545
end if
15421546

15431547
if (collision_model > 0) call s_finalize_collisions_module()

src/simulation/m_start_up.fpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,11 @@ contains
11841184
integer :: num_namelist_ibs, num_bed_ibs
11851185

11861186
num_namelist_ibs = num_ibs
1187-
num_bed_ibs = size(particle_bed_ibs)
1187+
num_bed_ibs = 0
1188+
do i = 1, num_particle_beds
1189+
num_bed_ibs = num_bed_ibs + particle_bed(i)%num_particles
1190+
end do
1191+
print *, "num_bed_ibs", num_bed_ibs
11881192

11891193
! Check for moving IBs across both namelist and particle bed patches.
11901194
moving_immersed_boundary_flag = .false.
@@ -1207,6 +1211,7 @@ contains
12071211
call s_compute_ib_neighbor_ranks()
12081212

12091213
num_gbl_ibs = num_namelist_ibs + num_bed_ibs
1214+
print *, "num_gbl_ibs", num_gbl_ibs
12101215

12111216
#ifdef MFC_MPI
12121217
if (num_procs == 1) then

toolchain/mfc/params/definitions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,9 @@ def _nv(targets: set, *names: str) -> None:
12211221
"coefficient_of_restitution",
12221222
"collision_time",
12231223
"ib_coefficient_of_friction",
1224+
"num_particle_beds",
1225+
"ib_neighborhood_radius",
1226+
"particle_bed",
12241227
"tau_star",
12251228
"cont_damage_s",
12261229
"alpha_bar",

0 commit comments

Comments
 (0)