aboutsummaryrefslogtreecommitdiff
path: root/Source/FieldSolver/SpectralSolver/SpectralKSpace.H
diff options
context:
space:
mode:
authorGravatar Remi Lehe <remi.lehe@normalesup.org> 2019-04-26 21:24:14 -0700
committerGravatar GitHub <noreply@github.com> 2019-04-26 21:24:14 -0700
commitdb115f923353e4fe483f13c5de50e9fe9dc701a9 (patch)
tree5ed62dcbace3e277f844bbc6186f40b2a193b627 /Source/FieldSolver/SpectralSolver/SpectralKSpace.H
parente9d3c12bbaf51fab7dc67be2e02a802dd22ae60f (diff)
parentcd2fc39d1dae02510a9fda43eab698d044eb7bd5 (diff)
downloadWarpX-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/SpectralKSpace.H')
-rw-r--r--Source/FieldSolver/SpectralSolver/SpectralKSpace.H54
1 files changed, 54 insertions, 0 deletions
diff --git a/Source/FieldSolver/SpectralSolver/SpectralKSpace.H b/Source/FieldSolver/SpectralSolver/SpectralKSpace.H
new file mode 100644
index 000000000..ad17e6423
--- /dev/null
+++ b/Source/FieldSolver/SpectralSolver/SpectralKSpace.H
@@ -0,0 +1,54 @@
+#ifndef WARPX_SPECTRAL_K_SPACE_H_
+#define WARPX_SPECTRAL_K_SPACE_H_
+
+#include <WarpX_Complex.H>
+#include <AMReX_BoxArray.H>
+#include <AMReX_LayoutData.H>
+
+// `KVectorComponent` and `SpectralShiftFactor` hold one 1D array
+// ("ManagedVector") for each box ("LayoutData"). The arrays are
+// only allocated if the corresponding box is owned by the local MPI rank.
+using KVectorComponent = amrex::LayoutData<
+ amrex::Gpu::ManagedVector<amrex::Real> >;
+using SpectralShiftFactor = amrex::LayoutData<
+ amrex::Gpu::ManagedVector<Complex> >;
+
+// Indicate the type of correction "shift" factor to apply
+// when the FFT is performed from/to a cell-centered grid in real space.
+struct ShiftType {
+ enum{ TransformFromCellCentered=0, TransformToCellCentered=1 };
+};
+
+/* \brief Class that represents the spectral space.
+ *
+ * (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)
+ */
+class SpectralKSpace
+{
+ public:
+ amrex::BoxArray spectralspace_ba;
+ SpectralKSpace( const amrex::BoxArray& realspace_ba,
+ const amrex::DistributionMapping& dm,
+ const amrex::RealVect realspace_dx );
+ KVectorComponent getKComponent(
+ const amrex::DistributionMapping& dm, const int i_dim ) const;
+ KVectorComponent getModifiedKComponent(
+ const amrex::DistributionMapping& dm, const int i_dim,
+ const int n_order, const bool nodal ) const;
+ SpectralShiftFactor getSpectralShiftFactor(
+ const amrex::DistributionMapping& dm, const int i_dim,
+ const int shift_type ) const;
+
+ private:
+ amrex::Array<KVectorComponent, AMREX_SPACEDIM> k_vec;
+ // 3D: k_vec is an Array of 3 components, corresponding to kx, ky, kz
+ // 2D: k_vec is an Array of 2 components, corresponding to kx, kz
+ amrex::RealVect dx;
+};
+
+amrex::Vector<amrex::Real>
+getFonbergStencilCoefficients( const int n_order, const bool nodal );
+
+#endif