Skip to content

Commit

Permalink
Add channel case.
Browse files Browse the repository at this point in the history
  • Loading branch information
semi-h committed Dec 20, 2024
1 parent 7f3cd0b commit b42b46d
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 0 deletions.
31 changes: 31 additions & 0 deletions examples/channel/input.x3d
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
&domain_settings
! Flow case
flow_case_name = 'channel'

! Global domain length
L_global = 8d0, 2d0, 4d0

! Global number of cells in each direction
dims_global = 256, 257, 128

! Domain decomposition in each direction
nproc_dir = 1, 1, 2

! BC options are 'periodic' | 'neumann' | 'dirichlet'
BC_x = 'periodic', 'periodic'
BC_y = 'dirichlet', 'dirichlet'
BC_z = 'periodic', 'periodic'
/End

&solver_params
Re = 4200d0
time_intg = 'AB3' ! 'AB[1-4]' | 'RK[1-4]'
dt = 0.005d0
n_iters = 100000
n_output = 1000
poisson_solver_type = 'FFT' ! 'FFT' | 'CG'
der1st_scheme = 'compact6'
der2nd_scheme = 'compact6' ! 'compact6' | 'compact6-hyperviscous'
interpl_scheme = 'optimised' ! 'classic' | 'optimised' | 'aggressive'
stagder_scheme = 'compact6'
/End
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(SRC
time_integrator.f90
vector_calculus.f90
case/base_case.f90
case/channel.f90
case/generic.f90
case/tgv.f90
omp/backend.f90
Expand Down
77 changes: 77 additions & 0 deletions src/case/channel.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
module m_case_channel
use iso_fortran_env, only: stderr => error_unit

use m_allocator, only: allocator_t, field_t
use m_base_backend, only: base_backend_t
use m_base_case, only: base_case_t
use m_common, only: dp
use m_mesh, only: mesh_t
use m_solver, only: init

implicit none

type, extends(base_case_t) :: case_channel_t
contains
procedure :: boundary_conditions => boundary_conditions_channel
procedure :: initial_conditions => initial_conditions_channel
procedure :: post_transeq => post_transeq_channel
procedure :: postprocess => postprocess_channel
end type case_channel_t

interface case_channel_t
module procedure case_channel_init
end interface case_channel_t

contains

function case_channel_init(backend, mesh, host_allocator) result(flow_case)
implicit none

class(base_backend_t), target, intent(inout) :: backend
type(mesh_t), target, intent(inout) :: mesh
type(allocator_t), target, intent(inout) :: host_allocator
type(case_channel_t) :: flow_case

call flow_case%case_init(backend, mesh, host_allocator)

end function case_channel_init

subroutine boundary_conditions_channel(self)
implicit none

class(case_channel_t) :: self

end subroutine boundary_conditions_channel

subroutine initial_conditions_channel(self)
implicit none

class(case_channel_t) :: self

call self%solver%u%fill(1._dp)
call self%solver%v%fill(0._dp)
call self%solver%w%fill(0._dp)

end subroutine initial_conditions_channel

subroutine postprocess_channel(self, t)
implicit none

class(case_channel_t) :: self
real(dp), intent(in) :: t

if (self%solver%mesh%par%is_root()) print *, 'time =', t
call self%print_enstrophy(self%solver%u, self%solver%v, self%solver%w)
call self%print_div_max_mean(self%solver%u, self%solver%v, self%solver%w)

end subroutine postprocess_channel

subroutine post_transeq_channel(self, du, dv, dw)
implicit none

class(case_channel_t) :: self
class(field_t), intent(inout) :: du, dv, dw

end subroutine post_transeq_channel

end module m_case_channel
4 changes: 4 additions & 0 deletions src/xcompact.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ program xcompact
use m_solver, only: solver_t
use m_tdsops, only: tdsops_t
use m_mesh
use m_case_channel, only: case_channel_t
use m_case_generic, only: case_generic_t
use m_case_tgv, only: case_tgv_t

Expand Down Expand Up @@ -108,6 +109,9 @@ program xcompact
if (nrank == 0) print *, 'Flow case: ', flow_case_name

select case (trim(flow_case_name))
case ('channel')
allocate (case_channel_t :: flow_case)
flow_case = case_channel_t(backend, mesh, host_allocator)
case ('generic')
allocate (case_generic_t :: flow_case)
flow_case = case_generic_t(backend, mesh, host_allocator)
Expand Down

0 comments on commit b42b46d

Please sign in to comment.