Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A little change on LES models #1600

Merged
merged 14 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/.depends
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,10 @@ les/les_model.lo : les/les_model.f90 math/bcknd/device/device_math.lo math/math.
les/les_model_fctry.lo : les/les_model_fctry.f90 common/utils.lo les/sigma.lo les/dynamic_smagorinsky.lo les/smagorinsky.lo les/vreman.lo les/les_model.lo
les/vreman.lo : les/vreman.f90 sem/coef.lo les/bcknd/device/vreman_device.lo les/bcknd/cpu/vreman_cpu.lo config/neko_config.lo common/utils.lo common/json_utils.lo sem/dofmap.lo les/les_model.lo field/field.lo config/num_types.lo
les/bcknd/cpu/vreman_cpu.lo : les/bcknd/cpu/vreman_cpu.f90 gs/gs_ops.lo sem/coef.lo math/operators.lo field/field.lo field/field_registry.lo field/scratch_registry.lo math/math.lo field/field_list.lo config/num_types.lo
les/bcknd/device/vreman_device.lo : les/bcknd/device/vreman_device.f90 les/bcknd/device/device_vreman_nut.lo gs/gs_ops.lo sem/coef.lo math/operators.lo field/field.lo field/field_registry.lo field/scratch_registry.lo math/math.lo config/num_types.lo
les/bcknd/device/vreman_device.lo : les/bcknd/device/vreman_device.f90 les/bcknd/device/device_vreman_nut.lo math/bcknd/device/device_math.lo gs/gs_ops.lo sem/coef.lo math/operators.lo field/field.lo field/field_registry.lo field/scratch_registry.lo math/math.lo config/num_types.lo
les/bcknd/device/device_vreman_nut.lo : les/bcknd/device/device_vreman_nut.F90 comm/comm.lo common/utils.lo config/num_types.lo
les/smagorinsky.lo : les/smagorinsky.f90 sem/coef.lo les/bcknd/device/smagorinsky_device.lo les/bcknd/cpu/smagorinsky_cpu.lo config/neko_config.lo common/utils.lo common/json_utils.lo sem/dofmap.lo les/les_model.lo field/field.lo config/num_types.lo
les/bcknd/cpu/smagorinsky_cpu.lo : les/bcknd/cpu/smagorinsky_cpu.f90 gs/gs_ops.lo sem/coef.lo math/operators.lo field/field.lo field/field_registry.lo field/scratch_registry.lo field/field_list.lo config/num_types.lo
les/bcknd/cpu/smagorinsky_cpu.lo : les/bcknd/cpu/smagorinsky_cpu.f90 math/math.lo gs/gs_ops.lo sem/coef.lo math/operators.lo field/field.lo field/field_registry.lo field/scratch_registry.lo field/field_list.lo config/num_types.lo
les/bcknd/device/smagorinsky_device.lo : les/bcknd/device/smagorinsky_device.f90 les/bcknd/device/device_smagorinsky_nut.lo math/bcknd/device/device_math.lo gs/gs_ops.lo sem/coef.lo math/operators.lo field/field.lo field/field_registry.lo field/scratch_registry.lo field/field_list.lo config/num_types.lo
les/bcknd/device/device_smagorinsky_nut.lo : les/bcknd/device/device_smagorinsky_nut.F90 comm/comm.lo common/utils.lo config/num_types.lo
les/dynamic_smagorinsky.lo : les/dynamic_smagorinsky.f90 les/bcknd/device/dynamic_smagorinsky_device.lo les/bcknd/cpu/dynamic_smagorinsky_cpu.lo les/elementwise_filter.lo sem/coef.lo config/neko_config.lo common/utils.lo common/json_utils.lo sem/dofmap.lo les/les_model.lo field/field.lo field/field_list.lo math/math.lo config/num_types.lo
Expand Down
3 changes: 3 additions & 0 deletions src/les/bcknd/cpu/dynamic_smagorinsky_cpu.f90
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ subroutine dynamic_smagorinsky_compute_cpu(t, tstep, coef, nut, delta, &
nut%x(i,1,1,1) = c_dyn%x(i,1,1,1) * delta%x(i,1,1,1)**2 * s_abs%x(i,1,1,1)
end do

call coef%gs_h%op(nut, GS_OP_ADD)
call col2(nut%x, coef%mult, nut%dof%size())

call neko_scratch_registry%relinquish_field(temp_indices)
end subroutine dynamic_smagorinsky_compute_cpu

Expand Down
5 changes: 4 additions & 1 deletion src/les/bcknd/cpu/sigma_cpu.f90
Shiyu-Sandy-Du marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module sigma_cpu
use operators, only : dudxyz
use coefs, only : coef_t
use gs_ops, only : GS_OP_ADD
use math, only : NEKO_EPS
use math, only : NEKO_EPS, col2
implicit none
private

Expand Down Expand Up @@ -272,6 +272,9 @@ subroutine sigma_compute_cpu(t, tstep, coef, nut, delta, c)
end do
end do

call coef%gs_h%op(nut, GS_OP_ADD)
call col2(nut%x, coef%mult, nut%dof%size())

call neko_scratch_registry%relinquish_field(temp_indices)
end subroutine sigma_compute_cpu

Expand Down
4 changes: 4 additions & 0 deletions src/les/bcknd/cpu/smagorinsky_cpu.f90
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module smagorinsky_cpu
use operators, only : strain_rate
use coefs, only : coef_t
use gs_ops, only : GS_OP_ADD
use math, only : col2
implicit none
private

Expand Down Expand Up @@ -111,6 +112,9 @@ subroutine smagorinsky_compute_cpu(t, tstep, coef, nut, delta, c_s)
end do
end do

call coef%gs_h%op(nut, GS_OP_ADD)
call col2(nut%x, coef%mult, nut%dof%size())

call neko_scratch_registry%relinquish_field(temp_indices)
end subroutine smagorinsky_compute_cpu

Expand Down
5 changes: 4 additions & 1 deletion src/les/bcknd/cpu/vreman_cpu.f90
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
module vreman_cpu
use num_types, only : rp
use field_list, only : field_list_t
use math, only : cadd, NEKO_EPS
use math, only : cadd, NEKO_EPS, col2
use scratch_registry, only : neko_scratch_registry
use field_registry, only : neko_field_registry
use field, only : field_t
Expand Down Expand Up @@ -156,6 +156,9 @@ subroutine vreman_compute_cpu(t, tstep, coef, nut, delta, c)
end do
end do

call coef%gs_h%op(nut, GS_OP_ADD)
call col2(nut%x, coef%mult, nut%dof%size())

call neko_scratch_registry%relinquish_field(temp_indices)
end subroutine vreman_compute_cpu

Expand Down
3 changes: 3 additions & 0 deletions src/les/bcknd/device/sigma_device.f90
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ subroutine sigma_compute_device(t, tstep, coef, nut, delta, c)
g31%x_d, g32%x_d, g33%x_d, &
delta%x_d, nut%x_d, coef%mult_d, &
c, eps, g11%dof%size())

call coef%gs_h%op(nut, GS_OP_ADD)
call device_col2(nut%x_d, coef%mult_d, nut%dof%size())

call neko_scratch_registry%relinquish_field(temp_indices)
end subroutine sigma_compute_device
Expand Down
4 changes: 4 additions & 0 deletions src/les/bcknd/device/vreman_device.f90
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module vreman_device
use operators, only : dudxyz
use coefs, only : coef_t
use gs_ops, only : GS_OP_ADD
use device_math, only : device_col2
use device_vreman_nut, only : device_vreman_nut_compute
implicit none
private
Expand Down Expand Up @@ -128,6 +129,9 @@ subroutine vreman_compute_device(t, tstep, coef, nut, delta, c)
a31%x_d, a32%x_d, a33%x_d, &
delta%x_d, nut%x_d, coef%mult_d, &
c, NEKO_EPS, a11%dof%size())

call coef%gs_h%op(nut, GS_OP_ADD)
call device_col2(nut%x_d, coef%mult_d, nut%dof%size())

call neko_scratch_registry%relinquish_field(temp_indices)
end subroutine vreman_compute_device
Expand Down
18 changes: 15 additions & 3 deletions src/les/les_model.f90
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@ subroutine les_model_compute_delta(this)
class(les_model_t), intent(inout) :: this
integer :: e, i, j, k
integer :: im, ip, jm, jp, km, kp
real(kind=rp) :: di, dj, dk, ndim_inv
real(kind=rp) :: di, dj, dk, ndim_inv, volume_element
integer :: lx_half, ly_half, lz_half

lx_half = this%coef%Xh%lx / 2
ly_half = this%coef%Xh%ly / 2
lz_half = this%coef%Xh%lz / 2

if (this%delta_type .eq. "elementwise") then
if (this%delta_type .eq. "elementwise_max") then
! use a same length scale throughout an entire element
! the length scale is based on maximum GLL spacing
do e = 1, this%coef%msh%nelv
Expand Down Expand Up @@ -205,7 +205,19 @@ subroutine les_model_compute_delta(this)
dk = sqrt(dk)
this%delta%x(:,:,:,e) = (di * dj * dk)**(1.0_rp / 3.0_rp)
end do

else if (this%delta_type .eq. "elementwise_average") then
! use a same length scale throughout an entire element
! the length scale is based on (volume)^(1/3)/(N+1)
do e = 1, this%coef%msh%nelv
volume_element = 0.0_rp
do k = 1, this%coef%Xh%lx * this%coef%Xh%ly * this%coef%Xh%lz
volume_element = volume_element + this%coef%B(k, 1, 1, e)
end do
this%delta%x(:,:,:,e) = (volume_element / this%coef%Xh%lx &
/ this%coef%Xh%ly &
/ this%coef%Xh%lz) &
**(1.0_rp / 3.0_rp)
end do
else if (this%delta_type .eq. "pointwise") then
do e = 1, this%coef%msh%nelv
do k = 1, this%coef%Xh%lz
Expand Down
12 changes: 12 additions & 0 deletions src/simulation_components/les_simcomp.f90
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ module les_simcomp
procedure, pass(this) :: free => les_simcomp_free
!> Compute the les_simcomp field.
procedure, pass(this) :: compute_ => les_simcomp_compute
!> Compute the les_simcomp field when restart.
procedure, pass(this) :: restart_ => les_simcomp_restart
end type les_simcomp_t

contains
Expand Down Expand Up @@ -114,4 +116,14 @@ subroutine les_simcomp_compute(this, t, tstep)
call this%les_model%compute(t, tstep)
end subroutine les_simcomp_compute

!> Compute the les_simcomp field when restart.
!! @param t The time value.
!! @param tstep The current time-step.
subroutine les_simcomp_restart(this, t)
class(les_simcomp_t), intent(inout) :: this
real(kind=rp), intent(in) :: t

call this%les_model%compute(t, 0)
end subroutine les_simcomp_restart

end module les_simcomp
Loading