Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Oct 15, 2024
1 parent 1e0ed75 commit e7f6d06
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Src/FFT/AMReX_FFT.H
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ private:
Box m_spectral_domain;

// assuming it's double for now
fftw_plan m_fftw_plan_x = nullptr;
fftw_plan m_fftw_fwd_x = nullptr;
fftw_plan m_fftw_bwd_x = nullptr;
fftw_plan m_fftw_plan_y = nullptr;
fftw_plan m_fftw_plan_z = nullptr;

Expand Down
21 changes: 15 additions & 6 deletions Src/FFT/AMReX_FFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,35 @@ R2C::R2C (BoxArray const& ba, DistributionMapping const& dm, Box const& domain)
double* in = m_rx[myproc].dataPtr();
auto* out = (fftw_complex*)(m_cx[myproc].dataPtr());

m_fftw_plan_x = fftw_plan_many_dft_r2c(1, &nxi, howmany,
in, nullptr, 1, nxi,
out, nullptr, 1, nxo,
FFTW_ESTIMATE);
m_fftw_fwd_x = fftw_plan_many_dft_r2c(1, &nxi, howmany,
in, nullptr, 1, nxi,
out, nullptr, 1, nxo,
FFTW_ESTIMATE || FFTW_DESTROY_INPUT);
m_fftw_bwd_x = fftw_plan_many_dft_c2r(1, &nxi, howmany,
out, nullptr, 1, nxo,
in, nullptr, 1, nxi,
FFTW_ESTIMATE || FFTW_DESTROY_INPUT);
}

R2C::~R2C ()
{
fftw_destroy_plan(m_fftw_plan_x);
fftw_destroy_plan(m_fftw_fwd_x);
}

void R2C::forward_doit (MultiFab const& inmf, Scaling scaling)
{
m_rx.ParallelCopy(inmf, 0, 0, 1);
fftw_execute(m_fftw_plan_x);
fftw_execute(m_fftw_fwd_x);

// xxxxx todo: scaling
}

void R2C::backward_doit (MultiFab& outmf, Scaling scaling)
{
// xxxxx todo: scaling

fftw_execute(m_fftw_bwd_x);
outmf.ParallelCopy(m_rx, 0, 0, 1);
}

}
3 changes: 3 additions & 0 deletions Tests/FFT/Poisson/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <AMReX.H>
#include <AMReX_MultiFab.H>
#include <AMReX_ParmParse.H>
#include <AMReX_PlotFileUtil.H>

#include <AMReX_FFT.H>

Expand Down Expand Up @@ -76,6 +77,8 @@ int main (int argc, char* argv[])

FFT::R2C fft(ba, dm, geom.Domain());
fft.forwardThenBackward(rhs, soln, post_forward);

VisMF::Write(soln, "soln");
}
amrex::Finalize();
}

0 comments on commit e7f6d06

Please sign in to comment.