WarpX
SpectralKSpace.H
Go to the documentation of this file.
1 /* Copyright 2019 David Grote, Maxence Thevenet, Remi Lehe
2  *
3  *
4  * This file is part of WarpX.
5  *
6  * License: BSD-3-Clause-LBNL
7  */
8 #ifndef WARPX_SPECTRAL_K_SPACE_H_
9 #define WARPX_SPECTRAL_K_SPACE_H_
10 
11 #include "SpectralKSpace_fwd.H"
12 
13 #include "Utils/WarpX_Complex.H"
14 
15 #include <AMReX_Array.H>
16 #include <AMReX_BoxArray.H>
17 #include <AMReX_Config.H>
18 #include <AMReX_GpuContainers.H>
19 #include <AMReX_LayoutData.H>
20 #include <AMReX_REAL.H>
21 #include <AMReX_RealVect.H>
22 #include <AMReX_Vector.H>
23 
24 #include <AMReX_BaseFwd.H>
25 
26 // `KVectorComponent` and `SpectralShiftFactor` hold one 1D array
27 // ("DeviceVector") for each box ("LayoutData"). The arrays are
28 // only allocated if the corresponding box is owned by the local MPI rank.
29 using RealKVector = amrex::Gpu::DeviceVector<amrex::Real>;
30 using KVectorComponent = amrex::LayoutData< RealKVector >;
31 using SpectralShiftFactor = amrex::LayoutData<
32  amrex::Gpu::DeviceVector<Complex> >;
33 
34 // Indicate the type of correction "shift" factor to apply
35 // when the FFT is performed from/to a cell-centered grid in real space.
36 struct ShiftType {
38 };
39 
48 {
49  public:
50  amrex::BoxArray spectralspace_ba;
51  SpectralKSpace() : dx(amrex::RealVect::Zero) {}
52  SpectralKSpace( const amrex::BoxArray& realspace_ba,
53  const amrex::DistributionMapping& dm,
54  const amrex::RealVect realspace_dx );
55  KVectorComponent getKComponent(
56  const amrex::DistributionMapping& dm,
57  const amrex::BoxArray& realspace_ba,
58  const int i_dim, const bool only_positive_k ) const;
59  KVectorComponent getModifiedKComponent(
60  const amrex::DistributionMapping& dm, const int i_dim,
61  const int n_order, const bool nodal ) const;
62  SpectralShiftFactor getSpectralShiftFactor(
63  const amrex::DistributionMapping& dm, const int i_dim,
64  const int shift_type ) const;
65 
66  protected:
67  amrex::Array<KVectorComponent, AMREX_SPACEDIM> k_vec;
68  // 3D: k_vec is an Array of 3 components, corresponding to kx, ky, kz
69  // 2D: k_vec is an Array of 2 components, corresponding to kx, kz
70  amrex::RealVect dx;
71 };
72 
82 amrex::Vector<amrex::Real>
83 getFornbergStencilCoefficients(const int n_order, const bool nodal);
84 
85 #endif
amrex::Vector< amrex::Real > getFornbergStencilCoefficients(const int n_order, const bool nodal)
Returns an array of coefficients (Fornberg coefficients), corresponding to the weight of each point i...
Definition: SpectralKSpace.cpp:281
Definition: SpectralKSpace.H:37
amrex::Array< KVectorComponent, AMREX_SPACEDIM > k_vec
Definition: SpectralKSpace.H:67
Class that represents the spectral space.
Definition: SpectralKSpace.H:47
amrex::RealVect dx
Definition: SpectralKSpace.H:70
int dx
Definition: compute_domain.py:35
Definition: SpectralKSpace.H:36
amrex::BoxArray spectralspace_ba
Definition: SpectralKSpace.H:50
SpectralKSpace()
Definition: SpectralKSpace.H:51
amrex::Gpu::DeviceVector< amrex::Real > RealKVector
Definition: SpectralKSpace.H:29
Definition: SpectralKSpace.H:37
amrex::LayoutData< amrex::Gpu::DeviceVector< Complex > > SpectralShiftFactor
Definition: SpectralKSpace.H:32
amrex::LayoutData< RealKVector > KVectorComponent
Definition: SpectralKSpace.H:30
Definition: BreitWheelerEngineWrapper.H:35