Refactor case BC hooks: rename to define_BC/apply_BC and hoist BC fields to base#307
Conversation
|
|
||
| !$omp parallel do private(k_end, y_block, i_max) | ||
| do k = 1, n_y_blocks*dims(3) | ||
| y_block = (k - 1)/dims(3) + 1 |
There was a problem hiding this comment.
I think this should be:
| y_block = (k - 1)/dims(3) + 1 | |
| y_block = mod(k - 1, n_y_blocks) + 1 |
OMP reordering uses get_index_dir (line 54), which maps a Cartesian (y, z) position to the third DIR_X index as:
dir_k = n_y_blocks*(z-1) + y_blockTherefore, y-block is the fast-varying component. For n_y_blocks = 3 and nz = 2, increasing k from 1 to 6 gives y-blocks 1, 2, 3, 1, 2, 3. The current expression, (b - 1)/nz + 1 produces 1, 1, 2, 2, 3, 3 (opposite flattening order). For CUDA it calls reorder_cuda (doesn't call get_index_dir). The current expression assumes CUDA's different layout.
Also, I think in field_set_face_omp (line 848), the Y_FACE block also uses the same incorrect CUDA-style indexing and should be changed to:
case (Y_FACE)
i_mod = mod(dims(2) - 1, SZ) + 1
n_y_blocks = (dims(2) - 1)/SZ + 1
!$omp parallel do private(k_start, k_end)
do z = 1, dims(3)
k_start = 1 + (z - 1)*n_y_blocks
k_end = n_y_blocks + (z - 1)*n_y_blocks
do j = 1, dims(1)
f%data(1, j, k_start) = c_start
f%data(i_mod, j, k_end) = c_end
end do
end do
!$omp end parallel doThis follows the OMP's DIR_X layout.
| error stop 'field_set_face_from_field: only supported for DIR_X fields.' | ||
| if (f%data_loc == NULL_LOC) & | ||
| error stop 'field_set_face_from_field: requires a valid data_loc.' | ||
| if (face /= X_FACE) & |
There was a problem hiding this comment.
The channel case calls this routine with Y_FACE - we will need to implement Y_FACE path using OMP ordering:
n_mod = mod(dims(2) - 1, SZ) + 1
n_y_blocks = (dims(2) - 1)/SZ + 1
!$omp parallel do private(k_start, k_end)
do z = 1, dims(3)
k_start = 1 + (z - 1)*n_y_blocks
k_end = n_y_blocks + (z - 1)*n_y_blocks
do j = 1, dims(1)
f%data(1, j, k_start) = f_start%data(1, j, k_start)
f%data(n_mod, j, k_end) = f_start%data(n_mod, j, k_end)
end do
end do
!$omp end parallel do
ia267
left a comment
There was a problem hiding this comment.
The OMP boundary path incorrectly assumes CUDA’s z-fast block ordering. OMP uses y-block-fast ordering through get_index_dir, so the y_block calculation and Y-face indices must be corrected accordingly. Additionally, field_set_face_from_field_omp must support Y_FACE, since the channel case calls that path.
ia267
left a comment
There was a problem hiding this comment.
Approved - please fix the formatting issues before merging.
|
@x3d2bot fix style |
|
On it -- running fprettify to fix style issues. |
boundary_conditions->define_BCandpre_correction->apply_BCacross base and child cases.bc_{start,end}_{u,v,w}_{x,y}) ontobase_case_t; cases use only what they need.field_set_face_from_fieldbackend hook (CUDA + OMP) for spatially-varying face BCs.inlet_noise(3)config (replacesbc_start_u/v/wscalars).compute_outflow_paramsmoved fromapply_BCintodefine_BC; results stored onself%out_vel/self%flow_rate_diff(drops_cachedsuffix).cylinder_nmlfiles must replacebc_start_u/v/wwithinlet_noise.