diff options
author | 2019-05-02 10:13:23 -0700 | |
---|---|---|
committer | 2019-05-02 10:13:23 -0700 | |
commit | 51f550982f784ad30910cd16e5525ae7753f1d6c (patch) | |
tree | 763149418c927d4fc1ac09c323c4a07d12db0726 /Source/FieldSolver/SpectralSolver/SpectralSolver.cpp | |
parent | df73577bc750d6ca49458c2365e761ab7067aa7b (diff) | |
parent | f07d411bc3b6110a48e70a6b69907d5f7100759d (diff) | |
download | WarpX-51f550982f784ad30910cd16e5525ae7753f1d6c.tar.gz WarpX-51f550982f784ad30910cd16e5525ae7753f1d6c.tar.zst WarpX-51f550982f784ad30910cd16e5525ae7753f1d6c.zip |
Merge pull request #103 from ECP-WarpX/factory
Use virtual function to select the spectral algorithm
Diffstat (limited to 'Source/FieldSolver/SpectralSolver/SpectralSolver.cpp')
-rw-r--r-- | Source/FieldSolver/SpectralSolver/SpectralSolver.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Source/FieldSolver/SpectralSolver/SpectralSolver.cpp b/Source/FieldSolver/SpectralSolver/SpectralSolver.cpp new file mode 100644 index 000000000..c21c3cfb1 --- /dev/null +++ b/Source/FieldSolver/SpectralSolver/SpectralSolver.cpp @@ -0,0 +1,35 @@ +#include <SpectralKSpace.H> +#include <SpectralSolver.H> +#include <PsatdAlgorithm.H> + +/* \brief Initialize the spectral Maxwell solver + * + * This function selects the spectral algorithm to be used, allocates the + * corresponding coefficients for the discretized field update equation, + * and prepares the structures that store the fields in spectral space. + */ +SpectralSolver::SpectralSolver( + const amrex::BoxArray& realspace_ba, + const amrex::DistributionMapping& dm, + const int norder_x, const int norder_y, + const int norder_z, const bool nodal, + const amrex::RealVect dx, const amrex::Real dt ) { + + // Initialize all structures using the same distribution mapping dm + + // - Initialize k space object (Contains info about the size of + // the spectral space corresponding to each box in `realspace_ba`, + // as well as the value of the corresponding k coordinates) + const SpectralKSpace k_space= SpectralKSpace(realspace_ba, dm, dx); + + // - Select the algorithm depending on the input parameters + // Initialize the corresponding coefficients over k space + // TODO: Add more algorithms + selection depending on input parameters + // For the moment, this only uses the standard PsatdAlgorithm + algorithm = std::unique_ptr<PsatdAlgorithm>( new PsatdAlgorithm( + k_space, dm, norder_x, norder_y, norder_z, nodal, dt ) ); + + // - Initialize arrays for fields in spectral space + FFT plans + field_data = SpectralFieldData( realspace_ba, k_space, dm ); + +}; |