aboutsummaryrefslogtreecommitdiff
path: root/Source/FieldSolver/SpectralSolver
diff options
context:
space:
mode:
Diffstat (limited to 'Source/FieldSolver/SpectralSolver')
-rw-r--r--Source/FieldSolver/SpectralSolver/WarpX_Complex.H27
1 files changed, 27 insertions, 0 deletions
diff --git a/Source/FieldSolver/SpectralSolver/WarpX_Complex.H b/Source/FieldSolver/SpectralSolver/WarpX_Complex.H
new file mode 100644
index 000000000..c898c5baa
--- /dev/null
+++ b/Source/FieldSolver/SpectralSolver/WarpX_Complex.H
@@ -0,0 +1,27 @@
+#ifndef WARPX_COMPLEX_H_
+#define WARPX_COMPLEX_H_
+
+#include <AMReX_REAL.H>
+
+// Define complex type on GPU/CPU
+#ifdef AMREX_USE_GPU
+
+#include <thrust/complex.h>
+#include <cufft.h>
+using Complex = thrust::complex<amrex::Real>;
+static_assert( sizeof(Complex) == sizeof(cuDoubleComplex),
+ "The complex types in WarpX and cuFFT do not match.");
+
+#else
+
+#include <complex>
+#include <fftw3.h>
+using Complex = std::complex<amrex::Real>;
+static_assert( sizeof(Complex) == sizeof(fftw_complex),
+ "The complex types in WarpX and FFTW do not match.");
+
+#endif
+static_assert(sizeof(Complex) == sizeof(amrex::Real[2]),
+ "Unexpected complex type.");
+
+#endif //WARPX_COMPLEX_H_