-
Notifications
You must be signed in to change notification settings - Fork 14
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
Reformat poisson #164
Reformat poisson #164
Conversation
…r the cuda based sine transformation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this great and important PR!
Co-authored-by: Severin Diederichs <65728274+SeverinDiederichs@users.noreply.github.com>
Thanks for your review, I included all your suggestions/comments. I think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great!
Dirichlet BC requires sine transformations, which differs significantly from periodic BC (that simply rely on FFTs). In the previous implementation,
FFTPoissonSolver
called theAnyFFT
wrapper functions to do the periodic-BC Poisson solves. This is modified by this PR, where:FFTPoissonSolver
is now an abstract class, with two derived classes:FFTPoissonSolverPeriodic
(theFFTPoissonSolver
of the previous implementation) andFFTPoissonSolverDirichlet
, for Dirichlet-BC Poisson solves.Fields
still holds 1 instance ofFFTPoissonSolver
, which is now a pointer to accommodate for this additional abstraction, hence the.
replaced by->
in a number of places inFields.cpp
.A new wrapper namespace
AnyDST
is created, built uponAnyFFT
, to wrap Discrete Sine Transforms from various vendors. Similar toAnyFFT
, the DST wrapper interface is declared inAnyDST.H
, and the implementation is chosen at compile time, from optionsWrapDSTW.cpp
(FFTW-based DST, on CPU) andWrapCuDST.cpp
(cuFFT-based DST, on Nvidia GPUs). FFTW essentially provides a sine transform (fftw_plan_r2r_2d
), soWrapDSTW.cpp
is not doing much. On the other hand, cuFFT doesn't provide a DST implementation, so there's more work to do intoWrapcuDST.cpp
, see next point.The CUDA-based DST requires the following operations:
m_position_array -> m_expanded_position_array
m_expanded_position_array -> m_expanded_fourier_array
m_tmpSpectralField
(real array contrary to periodic-BC), removing the symmetrym_expanded_fourier_array -> m_fourier_array
The full Dirichlet-BC Poisson solve is very similar to the periodic-BC Poisson solve, except with DST instead of FFTs:
a. DST the staging area into
m_tmpSpectralField
(1. 2. 3. above)b. Solve in "Fourier" (or "sine") space: multiply
m_tmpSpectralField
by an eigenvalue matrix (similar toinv_k2
for the periodic-BC Poisson solver). BE CAREFUL with the normalization here, as it is different from the periodic solver.c. DST
m_tmpSpectralField
back into the staging area (1. 2. 3. above). NOTE: contrary to an FFT, a DST is its own inverse (except for the normalization, depending on the implementation), so we don't care about the direction.Small enough (< few 100s of lines), otherwise it should probably be split into smaller PRs
Tested (describe the tests in the PR description)
Runs on GPU (basic: the code compiles and run well with the new module)
Contains an automated test (checksum and/or comparison with theory)
Documented: all elements (classes and their members, functions, namespaces, etc.) are documented
Constified (All that can be
const
isconst
)Code is clean (no unwanted comments, )
Style and code conventions are respected at the bottom of https://github.com/Hi-PACE/hipace
Proper label and GitHub project, if applicable