diff options
author | 2019-04-26 21:24:14 -0700 | |
---|---|---|
committer | 2019-04-26 21:24:14 -0700 | |
commit | db115f923353e4fe483f13c5de50e9fe9dc701a9 (patch) | |
tree | 5ed62dcbace3e277f844bbc6186f40b2a193b627 /Source/FieldSolver/SpectralSolver/SpectralFieldData.H | |
parent | e9d3c12bbaf51fab7dc67be2e02a802dd22ae60f (diff) | |
parent | cd2fc39d1dae02510a9fda43eab698d044eb7bd5 (diff) | |
download | WarpX-db115f923353e4fe483f13c5de50e9fe9dc701a9.tar.gz WarpX-db115f923353e4fe483f13c5de50e9fe9dc701a9.tar.zst WarpX-db115f923353e4fe483f13c5de50e9fe9dc701a9.zip |
Merge pull request #95 from ECP-WarpX/new_spectral_structures
Implement PSATD solver in C++
Diffstat (limited to 'Source/FieldSolver/SpectralSolver/SpectralFieldData.H')
-rw-r--r-- | Source/FieldSolver/SpectralSolver/SpectralFieldData.H | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Source/FieldSolver/SpectralSolver/SpectralFieldData.H b/Source/FieldSolver/SpectralSolver/SpectralFieldData.H new file mode 100644 index 000000000..c62513de6 --- /dev/null +++ b/Source/FieldSolver/SpectralSolver/SpectralFieldData.H @@ -0,0 +1,60 @@ +#ifndef WARPX_SPECTRAL_FIELD_DATA_H_ +#define WARPX_SPECTRAL_FIELD_DATA_H_ + +#include <WarpX_Complex.H> +#include <SpectralKSpace.H> +#include <AMReX_MultiFab.H> + +// Declare type for spectral fields +using SpectralField = amrex::FabArray< amrex::BaseFab <Complex> >; + +/* Index for the fields that will be stored in spectral space */ +struct SpectralFieldIndex{ + enum { Ex=0, Ey, Ez, Bx, By, Bz, Jx, Jy, Jz, rho_old, rho_new }; +}; + +/* \brief Class that stores the fields in spectral space, and performs the + * Fourier transforms between real space and spectral space + */ +class SpectralFieldData +{ + friend class PsatdAlgorithm; + + // Define the FFTplans type, which holds one fft plan per box + // (plans are only initialized for the boxes that are owned by + // the local MPI rank) +#ifdef AMREX_USE_GPU + // Add cuFFT-specific code +#else + using FFTplans = amrex::LayoutData<fftw_plan>; +#endif + + public: + SpectralFieldData( const amrex::BoxArray& realspace_ba, + const SpectralKSpace& k_space, + const amrex::DistributionMapping& dm ); + SpectralFieldData() = default; // Default constructor + SpectralFieldData& operator=(SpectralFieldData&& field_data) = default; + ~SpectralFieldData(); + void ForwardTransform( const amrex::MultiFab& mf, + const int field_index, const int i_comp ); + void BackwardTransform( amrex::MultiFab& mf, + const int field_index, const int i_comp ); + + private: + SpectralField Ex, Ey, Ez, Bx, By, Bz, Jx, Jy, Jz, rho_old, rho_new; + // tmpRealField and tmpSpectralField store fields + // right before/after the Fourier transform + SpectralField tmpRealField, tmpSpectralField; + FFTplans forward_plan, backward_plan; + // Correcting "shift" factors when performing FFT from/to + // a cell-centered grid in real space, instead of a nodal grid + SpectralShiftFactor xshift_FFTfromCell, xshift_FFTtoCell, + zshift_FFTfromCell, zshift_FFTtoCell; +#if (AMREX_SPACEDIM==3) + SpectralShiftFactor yshift_FFTfromCell, yshift_FFTtoCell; +#endif + SpectralField& getSpectralField( const int field_index ); +}; + +#endif // WARPX_SPECTRAL_FIELD_DATA_H_ |