Skip to content

Commit

Permalink
Merge pull request #1551 from timfelle/fix/brinkman
Browse files Browse the repository at this point in the history
Resolve some outstanding issue with brinkman
  • Loading branch information
njansson authored Oct 29, 2024
2 parents 9cfa4e7 + 52ef11d commit 58f3131
Show file tree
Hide file tree
Showing 29 changed files with 2,027 additions and 248 deletions.
2 changes: 1 addition & 1 deletion examples/immersed_zones/block.case
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"output_at_end": false,
"output_boundary": false,
"output_checkpoints": false,
"end_time": 0.01,
"end_time": 20.0,
"timestep": 5e-5,
"numerics": {
"time_order": 3,
Expand Down
2 changes: 1 addition & 1 deletion examples/immersed_zones/block_sphere.case
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"output_at_end": false,
"output_boundary": false,
"output_checkpoints": false,
"end_time": 0.01,
"end_time": 20.0,
"timestep": 5e-5,
"numerics": {
"time_order": 3,
Expand Down
2 changes: 1 addition & 1 deletion examples/immersed_zones/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function help() {
echo -e " See Readme for additional details."
exit 0
}
if [ $# -eq 0 ]; then help; fi
if [ $# -eq 0 ]; then ALL=1; fi

# Handle options
Nx=32 && Ny=8 && Nz=8
Expand Down
12 changes: 8 additions & 4 deletions src/.depends
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ math/mxm_wrapper.o : math/mxm_wrapper.F90 common/utils.o config/num_types.o
sem/speclib.o : sem/speclib.f90 common/utils.o config/num_types.o
qoi/drag_torque.o : qoi/drag_torque.f90 math/bcknd/device/device_math.o device/device.o common/utils.o config/num_types.o sem/space.o math/math.o comm/comm.o mesh/facet_zone.o mesh/mesh.o sem/coef.o field/field.o
sem/local_interpolation.o : sem/local_interpolation.f90 config/neko_config.o math/bcknd/device/device_math.o device/device.o field/field_list.o field/field.o common/utils.o math/fast3d.o math/math.o mesh/point.o config/num_types.o sem/space.o math/tensor.o
math/math.o : math/math.f90 comm/comm.o config/num_types.o
math/math.o : math/math.f90 comm/comm.o common/utils.o config/num_types.o
math/mathops.o : math/mathops.f90 config/num_types.o
math/fast3d.o : math/fast3d.f90 math/math.o sem/speclib.o config/num_types.o
sem/space.o : sem/space.f90 math/mxm_wrapper.o math/tensor.o math/math.o math/fast3d.o common/utils.o device/device.o sem/speclib.o config/num_types.o config/neko_config.o
Expand Down Expand Up @@ -106,7 +106,7 @@ math/bcknd/xsmm/fdm_xsmm.o : math/bcknd/xsmm/fdm_xsmm.f90 math/bcknd/xsmm/tensor
math/schwarz.o : math/schwarz.f90 config/neko_config.o device/device.o math/fdm.o math/bcknd/device/device_math.o math/bcknd/device/device_schwarz.o gs/gather_scatter.o bc/bc.o sem/dofmap.o sem/space.o mesh/mesh.o math/math.o config/num_types.o
math/vector.o : math/vector.f90 common/utils.o math/bcknd/device/device_math.o device/device.o config/num_types.o math/math.o config/neko_config.o
math/matrix.o : math/matrix.f90 common/utils.o math/bcknd/device/device_math.o device/device.o config/num_types.o math/math.o config/neko_config.o
math/signed_distance.o : math/signed_distance.f90 adt/stack.o mesh/search_tree/aabb.o mesh/point.o common/utils.o mesh/aabb_tree.o mesh/tri_mesh.o mesh/tri.o field/field.o config/num_types.o
math/signed_distance.o : math/signed_distance.f90 adt/stack.o mesh/search_tree/aabb.o mesh/point.o common/utils.o config/neko_config.o device/device.o mesh/aabb_tree.o mesh/tri_mesh.o mesh/tri.o field/field.o config/num_types.o
common/checkpoint.o : common/checkpoint.f90 mesh/mesh.o common/utils.o field/field.o device/device.o sem/space.o field/field_series.o config/num_types.o config/neko_config.o
io/generic_file.o : io/generic_file.f90 comm/comm.o common/utils.o config/num_types.o
io/map_file.o : io/map_file.f90 io/format/map.o comm/comm.o common/utils.o io/generic_file.o
Expand Down Expand Up @@ -293,9 +293,13 @@ source_terms/boussinesq_source_term.o : source_terms/boussinesq_source_term.f90
source_terms/bcknd/cpu/boussinesq_source_term_cpu.o : source_terms/bcknd/cpu/boussinesq_source_term_cpu.f90 math/math.o field/field.o field/field_list.o config/num_types.o
source_terms/bcknd/device/boussinesq_source_term_device.o : source_terms/bcknd/device/boussinesq_source_term_device.f90 math/bcknd/device/device_math.o field/field.o field/field_list.o config/num_types.o
source_terms/source_term_fctry.o : source_terms/source_term_fctry.f90 common/utils.o common/json_utils.o source_terms/coriolis_source_term.o source_terms/brinkman_source_term.o source_terms/boussinesq_source_term.o source_terms/const_source_term.o source_terms/source_term.o
source_terms/brinkman_source_term.o : source_terms/brinkman_source_term.f90 mesh/point_zone_registry.o mesh/point_zone.o mesh/search_tree/aabb.o common/profiler.o math/signed_distance.o source_terms/brinkman/filters.o device/device.o mesh/tri_mesh.o io/file.o math/field_math.o common/utils.o config/neko_config.o sem/coef.o source_terms/source_term.o field/field_registry.o common/json_utils.o field/field_list.o field/field.o config/num_types.o
source_terms/brinkman/filters.o : source_terms/brinkman/filters.f90 source_terms/bcknd/cpu/filters_cpu.o common/utils.o config/num_types.o config/neko_config.o field/field.o
source_terms/brinkman_source_term.o : source_terms/brinkman_source_term.f90 mesh/point_zone_registry.o mesh/point_zone.o mesh/search_tree/aabb.o common/profiler.o math/signed_distance.o source_terms/brinkman/filters.o device/device.o mesh/tri_mesh.o io/file.o math/bcknd/device/device_math.o math/math.o math/field_math.o common/utils.o config/neko_config.o sem/coef.o source_terms/source_term.o field/field_registry.o common/json_utils.o field/field_list.o field/field.o config/num_types.o
source_terms/brinkman/filters.o : source_terms/brinkman/filters.f90 source_terms/bcknd/device/filters_device.o source_terms/bcknd/cpu/filters_cpu.o common/utils.o config/num_types.o config/neko_config.o field/field.o
source_terms/bcknd/cpu/filters_cpu.o : source_terms/bcknd/cpu/filters_cpu.f90 config/num_types.o
source_terms/bcknd/device/filters_device.o : source_terms/bcknd/device/filters_device.F90 source_terms/bcknd/device/opencl/opencl_filters.o source_terms/bcknd/device/hip/hip_filters.o source_terms/bcknd/device/cuda/cuda_filters.o common/utils.o math/bcknd/device/device_math.o config/num_types.o
source_terms/bcknd/device/cuda/cuda_filters.o : source_terms/bcknd/device/cuda/cuda_filters.f90 config/num_types.o
source_terms/bcknd/device/hip/hip_filters.o : source_terms/bcknd/device/hip/hip_filters.f90 config/num_types.o
source_terms/bcknd/device/opencl/opencl_filters.o : source_terms/bcknd/device/opencl/opencl_filters.f90 config/num_types.o
les/les_model.o : les/les_model.f90 math/bcknd/device/device_math.o math/math.o device/device.o config/neko_config.o gs/gs_ops.o sem/coef.o sem/dofmap.o field/field_registry.o field/field.o config/num_types.o
les/les_model_fctry.o : les/les_model_fctry.f90 common/utils.o les/sigma.o les/dynamic_smagorinsky.o les/smagorinsky.o les/vreman.o les/les_model.o
les/vreman.o : les/vreman.f90 sem/coef.o les/bcknd/cpu/vreman_cpu.o config/neko_config.o common/utils.o common/json_utils.o sem/dofmap.o les/les_model.o field/field.o config/num_types.o
Expand Down
13 changes: 8 additions & 5 deletions src/.depends_device
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bc/bcknd/device/hip/dong_outflow.o : bc/bcknd/device/hip/dong_outflow.hip bc/bck
common/bcknd/device/hip/rhs_maker.o : common/bcknd/device/hip/rhs_maker.hip common/bcknd/device/hip/sumab_kernel.h common/bcknd/device/hip/makeext_kernel.h common/bcknd/device/hip/makebdf_kernel.h
common/bcknd/device/hip/projection.o : common/bcknd/device/hip/projection.hip common/bcknd/device/hip/projection_kernel.h
common/bcknd/device/hip/gradient_jump_penalty.o : common/bcknd/device/hip/gradient_jump_penalty.hip common/bcknd/device/hip/gradient_jump_penalty_kernel.h
fluid/bcknd/device/hip/pnpn_res.o : fluid/bcknd/device/hip/pnpn_res.hip fluid/bcknd/device/hip/vel_res_update_kernel.h fluid/bcknd/device/hip/prs_res_kernel.h
fluid/bcknd/device/hip/pnpn_res.o : fluid/bcknd/device/hip/pnpn_res.hip fluid/bcknd/device/hip/vel_res_update_kernel.h fluid/bcknd/device/hip/prs_res_kernel.h
scalar/bcknd/device/hip/scalar_residual.o : scalar/bcknd/device/hip/scalar_residual.hip scalar/bcknd/device/hip/scalar_residual_update_kernel.h
sem/bcknd/device/hip/coef.o : sem/bcknd/device/hip/coef.hip sem/bcknd/device/hip/coef_kernel.h
device/cuda/check.o : device/cuda/check.cu device/cuda/check.h
Expand All @@ -47,7 +47,7 @@ krylov/bcknd/device/cuda/pipecg_aux.o : krylov/bcknd/device/cuda/pipecg_aux.cu k
krylov/bcknd/device/cuda/fusedcg_aux.o : krylov/bcknd/device/cuda/fusedcg_aux.cu krylov/bcknd/device/cuda/fusedcg_kernel.h
krylov/bcknd/device/cuda/fusedcg_cpld_aux.o : krylov/bcknd/device/cuda/fusedcg_cpld_aux.cu krylov/bcknd/device/cuda/fusedcg_cpld_kernel.h
krylov/bcknd/device/cuda/gmres_aux.o : krylov/bcknd/device/cuda/gmres_aux.cu krylov/bcknd/device/cuda/gmres_kernel.h
gs/bcknd/device/cuda/gs.o : gs/bcknd/device/cuda/gs.cu gs/bcknd/device/cuda/gs_kernels.h
gs/bcknd/device/cuda/gs.o : gs/bcknd/device/cuda/gs.cu gs/bcknd/device/cuda/gs_kernels.h
bc/bcknd/device/cuda/dirichlet.o : bc/bcknd/device/cuda/dirichlet.cu bc/bcknd/device/cuda/dirichlet_kernel.h
bc/bcknd/device/cuda/inflow.o : bc/bcknd/device/cuda/inflow.cu bc/bcknd/device/cuda/inflow_kernel.h
bc/bcknd/device/cuda/no_slip_wall.o : bc/bcknd/device/cuda/no_slip_wall.cu bc/bcknd/device/cuda/no_slip_wall_kernel.h
Expand All @@ -58,13 +58,13 @@ bc/bcknd/device/cuda/dong_outflow.o : bc/bcknd/device/cuda/dong_outflow.cu bc/bc
common/bcknd/device/cuda/rhs_maker.o : common/bcknd/device/cuda/rhs_maker.cu common/bcknd/device/cuda/sumab_kernel.h common/bcknd/device/cuda/makeext_kernel.h common/bcknd/device/cuda/makebdf_kernel.h
common/bcknd/device/cuda/projection.o : common/bcknd/device/cuda/projection.cu common/bcknd/device/cuda/projection_kernel.h
fluid/bcknd/device/cuda/pnpn_res.o : fluid/bcknd/device/cuda/pnpn_res.cu fluid/bcknd/device/cuda/vel_res_update_kernel.h fluid/bcknd/device/cuda/prs_res_kernel.h
fluid/stress_formulation/bcknd/device/cuda/pnpn_stress_res.o : fluid/stress_formulation/bcknd/device/cuda/pnpn_stress_res.cu fluid/stress_formulation/bcknd/device/cuda/prs_stress_res_kernel.h
fluid/stress_formulation/bcknd/device/cuda/pnpn_stress_res.o : fluid/stress_formulation/bcknd/device/cuda/pnpn_stress_res.cu fluid/stress_formulation/bcknd/device/cuda/prs_stress_res_kernel.h
common/bcknd/device/cuda/gradient_jump_penalty.o : common/bcknd/device/cuda/gradient_jump_penalty.cu common/bcknd/device/cuda/gradient_jump_penalty_kernel.h
scalar/bcknd/device/cuda/scalar_residual.o : scalar/bcknd/device/cuda/scalar_residual.cu scalar/bcknd/device/cuda/scalar_residual_update_kernel.h
sem/bcknd/device/cuda/coef.o : sem/bcknd/device/cuda/coef.cu sem/bcknd/device/cuda/coef_kernel.h
device/opencl/check.o : device/opencl/check.c device/opencl/check.h
device/opencl/jit.o : device/opencl/jit.c device/opencl/jit.h
math/bcknd/device/opencl/math.o : math/bcknd/device/opencl/math.c math/bcknd/device/opencl/math_kernel.cl.h
math/bcknd/device/opencl/math.o : math/bcknd/device/opencl/math.c math/bcknd/device/opencl/math_kernel.cl.h
math/bcknd/device/opencl/schwarz.o : math/bcknd/device/opencl/schwarz.c math/bcknd/device/opencl/schwarz_kernel.cl.h
math/bcknd/device/opencl/tensor.o : math/bcknd/device/opencl/tensor.c math/bcknd/device/opencl/tensor_kernel.cl.h
math/bcknd/device/opencl/fdm.o : math/bcknd/device/opencl/fdm.c math/bcknd/device/opencl/fdm_kernel.cl.h
Expand All @@ -77,7 +77,7 @@ math/bcknd/device/opencl/opr_lambda2.o : math/bcknd/device/opencl/opr_lambda2.c
math/bcknd/device/opencl/opr_cfl.o : math/bcknd/device/opencl/opr_cfl.c math/bcknd/device/opencl/cfl_kernel.cl.h
math/bcknd/device/opencl/ax_helm.o : math/bcknd/device/opencl/ax_helm.c math/bcknd/device/opencl/ax_helm_kernel.cl.h
krylov/bcknd/device/opencl/pc_jacobi.o : krylov/bcknd/device/opencl/pc_jacobi.c krylov/bcknd/device/opencl/jacobi_kernel.cl.h
gs/bcknd/device/opencl/gs.o : gs/bcknd/device/opencl/gs.c gs/bcknd/device/opencl/gs_kernels.cl.h
gs/bcknd/device/opencl/gs.o : gs/bcknd/device/opencl/gs.c gs/bcknd/device/opencl/gs_kernels.cl.h
bc/bcknd/device/opencl/dirichlet.o : bc/bcknd/device/opencl/dirichlet.c bc/bcknd/device/opencl/dirichlet_kernel.cl.h
bc/bcknd/device/opencl/inflow.o : bc/bcknd/device/opencl/inflow.c bc/bcknd/device/opencl/inflow_kernel.cl.h
bc/bcknd/device/opencl/no_slip_wall.o : bc/bcknd/device/opencl/no_slip_wall.c bc/bcknd/device/opencl/no_slip_wall_kernel.cl.h
Expand All @@ -89,3 +89,6 @@ common/bcknd/device/opencl/rhs_maker.o : common/bcknd/device/opencl/rhs_maker.c
fluid/bcknd/device/opencl/pnpn_res.o : fluid/bcknd/device/opencl/pnpn_res.c fluid/bcknd/device/opencl/pnpn_res_kernel.cl.h
scalar/bcknd/device/opencl/scalar_residual.o : scalar/bcknd/device/opencl/scalar_residual.c scalar/bcknd/device/opencl/scalar_residual_kernel.cl.h
sem/bcknd/device/opencl/coef.o : sem/bcknd/device/opencl/coef.c sem/bcknd/device/opencl/coef_kernel.cl.h
source_terms/bcknd/device/cuda/filters.o : source_terms/bcknd/device/cuda/filters.cu source_terms/bcknd/device/cuda/filter_kernels.h
source_terms/bcknd/device/hip/filters.o : source_terms/bcknd/device/hip/filters.hip source_terms/bcknd/device/hip/filter_kernels.h
source_terms/bcknd/device/opencl/filters.o : source_terms/bcknd/device/opencl/filters.c source_terms/bcknd/device/opencl/filter_kernels.cl.h
19 changes: 15 additions & 4 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ neko_fortran_SOURCES = \
source_terms/brinkman_source_term.f90\
source_terms/brinkman/filters.f90\
source_terms/bcknd/cpu/filters_cpu.f90\
source_terms/bcknd/device/filters_device.F90\
source_terms/bcknd/device/cuda/cuda_filters.f90\
source_terms/bcknd/device/hip/hip_filters.f90\
source_terms/bcknd/device/opencl/opencl_filters.f90\
les/les_model.f90\
les/les_model_fctry.f90\
les/vreman.f90\
Expand Down Expand Up @@ -364,7 +368,8 @@ libneko_a_SOURCES += \
common/bcknd/device/hip/gradient_jump_penalty.hip\
fluid/bcknd/device/hip/pnpn_res.hip\
scalar/bcknd/device/hip/scalar_residual.hip\
sem/bcknd/device/hip/coef.hip
sem/bcknd/device/hip/coef.hip\
source_terms/bcknd/device/hip/filters.hip
endif

if ENABLE_CUDA
Expand Down Expand Up @@ -401,7 +406,8 @@ libneko_a_SOURCES += \
fluid/bcknd/device/cuda/pnpn_res.cu\
fluid/stress_formulation/bcknd/device/cuda/pnpn_stress_res.cu\
scalar/bcknd/device/cuda/scalar_residual.cu\
sem/bcknd/device/cuda/coef.cu
sem/bcknd/device/cuda/coef.cu\
source_terms/bcknd/device/cuda/filters.cu
endif

if ENABLE_OPENCL
Expand Down Expand Up @@ -432,7 +438,8 @@ libneko_a_SOURCES += \
common/bcknd/device/opencl/rhs_maker.c\
fluid/bcknd/device/opencl/pnpn_res.c\
scalar/bcknd/device/opencl/scalar_residual.c\
sem/bcknd/device/opencl/coef.c
sem/bcknd/device/opencl/coef.c\
source_terms/bcknd/device/opencl/filters.c

%.cl.h: %.cl
bash ./scripts/cltostring.sh $<
Expand Down Expand Up @@ -501,7 +508,8 @@ CLEANFILES += \
krylov/bcknd/device/opencl/*.cl.h\
fluid/bcknd/device/opencl/*.cl.h\
scalar/bcknd/device/opencl/*.cl.h\
sem/bcknd/device/opencl/*.cl.h
sem/bcknd/device/opencl/*.cl.h\
source_terms/bcknd/device/opencl/*.cl.h
endif

if ENABLE_MAKEDEPF90
Expand Down Expand Up @@ -604,6 +612,9 @@ EXTRA_DIST = \
sem/bcknd/device/opencl/coef_kernel.cl\
math/bcknd/device/device_mpi_reduce.h\
math/bcknd/device/device_mpi_op.h\
source_terms/bcknd/device/cuda/filter_kernels.h\
source_terms/bcknd/device/hip/filter_kernels.h\
source_terms/bcknd/device/opencl/filter_kernels.cl\
device/opencl/jit.h\
device/opencl/prgm_lib.h\
device/opencl/check.h\
Expand Down
10 changes: 10 additions & 0 deletions src/device/opencl/prgm_lib.F90
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ module opencl_prgm_lib
!> Device lambda2 kernels
type(c_ptr), bind(c) :: lambda2_program = C_NULL_PTR

!> Device filter kernels
type(c_ptr), bind(c) :: filter_program = C_NULL_PTR

contains

subroutine opencl_prgm_lib_release
Expand Down Expand Up @@ -261,6 +264,13 @@ subroutine opencl_prgm_lib_release
lambda2_program = C_NULL_PTR
end if

if (c_associated(filter_program)) then
if(clReleaseProgram(filter_program) .ne. CL_SUCCESS) then
call neko_error('Failed to release program')
end if
filter_program = C_NULL_PTR
end if

end subroutine opencl_prgm_lib_release

#endif
Expand Down
2 changes: 2 additions & 0 deletions src/device/opencl/prgm_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ extern void *scalar_residual_program;
/** Device lambda2 kernel */
extern void *lambda2_program;

/** Device filter kernel */
extern void *filter_program;


#endif
70 changes: 70 additions & 0 deletions src/math/bcknd/device/cuda/cuda_math.f90
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,74 @@ subroutine cuda_absval(a_d, n) &
integer(c_int) :: n
end subroutine cuda_absval
end interface

! ========================================================================== !
! Interfaces for the pointwise operations.

interface
subroutine cuda_pwmax_vec2(a_d, b_d, n) &
bind(c, name = 'cuda_pwmax_vec2')
use, intrinsic :: iso_c_binding, only: c_int, c_ptr
type(c_ptr), value :: a_d, b_d
integer(c_int) :: n
end subroutine cuda_pwmax_vec2

subroutine cuda_pwmax_vec3(a_d, b_d, c_d, n) &
bind(c, name = 'cuda_pwmax_vec3')
use, intrinsic :: iso_c_binding, only: c_int, c_ptr
type(c_ptr), value :: a_d, b_d, c_d
integer(c_int) :: n
end subroutine cuda_pwmax_vec3

subroutine cuda_pwmax_sca2(a_d, c_d, n) &
bind(c, name = 'cuda_pwmax_sca2')
use, intrinsic :: iso_c_binding, only: c_int, c_ptr
import c_rp
type(c_ptr), value :: a_d
real(c_rp) :: c_d
integer(c_int) :: n
end subroutine cuda_pwmax_sca2

subroutine cuda_pwmax_sca3(a_d, b_d, c_d, n) &
bind(c, name = 'cuda_pwmax_sca3')
use, intrinsic :: iso_c_binding, only: c_int, c_ptr
import c_rp
type(c_ptr), value :: a_d, b_d
real(c_rp) :: c_d
integer(c_int) :: n
end subroutine cuda_pwmax_sca3

subroutine cuda_pwmin_vec2(a_d, b_d, n) &
bind(c, name = 'cuda_pwmin_vec2')
use, intrinsic :: iso_c_binding, only: c_int, c_ptr
type(c_ptr), value :: a_d, b_d
integer(c_int) :: n
end subroutine cuda_pwmin_vec2

subroutine cuda_pwmin_vec3(a_d, b_d, c_d, n) &
bind(c, name = 'cuda_pwmin_vec3')
use, intrinsic :: iso_c_binding, only: c_int, c_ptr
type(c_ptr), value :: a_d, b_d, c_d
integer(c_int) :: n
end subroutine cuda_pwmin_vec3

subroutine cuda_pwmin_sca2(a_d, c_d, n) &
bind(c, name = 'cuda_pwmin_sca2')
use, intrinsic :: iso_c_binding, only: c_int, c_ptr
import c_rp
type(c_ptr), value :: a_d
real(c_rp) :: c_d
integer(c_int) :: n
end subroutine cuda_pwmin_sca2

subroutine cuda_pwmin_sca3(a_d, b_d, c_d, n) &
bind(c, name = 'cuda_pwmin_sca3')
use, intrinsic :: iso_c_binding, only: c_int, c_ptr
import c_rp
type(c_ptr), value :: a_d, b_d
real(c_rp) :: c_d
integer(c_int) :: n
end subroutine cuda_pwmin_sca3

end interface
end module cuda_math
Loading

0 comments on commit 58f3131

Please sign in to comment.