Skip to content

Commit

Permalink
Change the Poisson solver selection mechanism.
Browse files Browse the repository at this point in the history
  • Loading branch information
semi-h committed Mar 1, 2024
1 parent 6399546 commit 872b2d7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/common.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module m_common
integer, parameter :: RDR_X2Y = 12, RDR_X2Z = 13, RDR_Y2X = 21, &
RDR_Y2Z = 23, RDR_Z2X = 31, RDR_Z2Y = 32

integer, parameter :: POISSON_SOLVER_FFT = 0, POISSON_SOLVER_CG = 1

type :: globs_t
integer :: nx, ny, nz
integer :: nx_loc, ny_loc, nz_loc
Expand All @@ -15,7 +17,7 @@ module m_common
real(dp) :: dx, dy, dz
integer :: nproc_x = 1, nproc_y = 1, nproc_z = 1
character(len=20) :: BC_x_s, BC_x_e, BC_y_s, BC_y_e, BC_z_s, BC_z_e
logical :: use_fft
integer :: poisson_solver_type
end type globs_t

contains
Expand Down
10 changes: 6 additions & 4 deletions src/solver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module m_solver
use m_allocator, only: allocator_t, field_t
use m_base_backend, only: base_backend_t
use m_common, only: dp, globs_t, &
RDR_X2Y, RDR_X2Z, RDR_Y2X, RDR_Y2Z, RDR_Z2X, RDR_Z2Y
RDR_X2Y, RDR_X2Z, RDR_Y2X, RDR_Y2Z, RDR_Z2X, RDR_Z2Y, &
POISSON_SOLVER_FFT, POISSON_SOLVER_CG
use m_tdsops, only: tdsops_t, dirps_t
use m_time_integrator, only: time_intg_t

Expand Down Expand Up @@ -122,14 +123,15 @@ function init(backend, time_integrator, xdirps, ydirps, zdirps, globs) &
call allocate_tdsops(solver%ydirps, ny, dy, solver%backend)
call allocate_tdsops(solver%zdirps, nz, dz, solver%backend)

if (globs%use_fft) then
select case (globs%poisson_solver_type)
case (POISSON_SOLVER_FFT)
print*, 'Poisson solver: FFT'
call solver%backend%init_poisson_fft(xdirps, ydirps, zdirps)
solver%poisson => poisson_fft
else
case (POISSON_SOLVER_CG)
print*, 'Poisson solver: CG'
solver%poisson => poisson_cg
end if
end select

end function init

Expand Down
5 changes: 3 additions & 2 deletions src/xcompact.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ program xcompact

use m_allocator
use m_base_backend
use m_common, only: pi, globs_t, set_pprev_pnext
use m_common, only: pi, globs_t, set_pprev_pnext, &
POISSON_SOLVER_FFT, POISSON_SOLVER_CG
use m_solver, only: solver_t
use m_time_integrator, only: time_intg_t
use m_tdsops, only: tdsops_t
Expand Down Expand Up @@ -63,7 +64,7 @@ program xcompact
! set nprocs based on run time arguments
globs%nproc_x = 1; globs%nproc_y = 1; globs%nproc_z = 1

globs%use_fft = .true.
globs%poisson_solver_type = POISSON_SOLVER_FFT

! Lets allow a 1D decomposition for the moment
!globs%nproc_x = nproc
Expand Down

0 comments on commit 872b2d7

Please sign in to comment.