diff options
-rw-r--r-- | Example/Langmuir/inputs.multi.2d.rt | 77 | ||||
-rw-r--r-- | Source/WarpXFFT.cpp | 28 | ||||
-rw-r--r-- | Source/WarpX_f.H | 13 | ||||
-rw-r--r-- | Source/WarpX_fft.F90 | 5 |
4 files changed, 108 insertions, 15 deletions
diff --git a/Example/Langmuir/inputs.multi.2d.rt b/Example/Langmuir/inputs.multi.2d.rt new file mode 100644 index 000000000..03e68f231 --- /dev/null +++ b/Example/Langmuir/inputs.multi.2d.rt @@ -0,0 +1,77 @@ +# Maximum number of time steps +max_step = 40 + +# number of grid points +amr.n_cell = 64 64 + +# Maximum allowable size of each subdomain in the problem domain; +# this is used to decompose the domain for parallel calculations. +amr.max_grid_size = 32 + +# Maximum level in hierarchy (for now must be 0, i.e., one level in total) +amr.max_level = 0 + +amr.plot_int = 20 # How often to write plotfiles. "<= 0" means no plotfiles. + +# Geometry +geometry.coord_sys = 0 # 0: Cartesian +geometry.is_periodic = 1 1 # Is periodic? +geometry.prob_lo = -20.e-6 -20.e-6 # physical domain +geometry.prob_hi = 20.e-6 20.e-6 + +warpx.serialize_ics = 1 + +# Verbosity +warpx.verbose = 1 + +# Algorithms +algo.current_deposition = 3 +algo.charge_deposition = 0 +algo.field_gathering = 1 +algo.particle_pusher = 0 + +# Interpolation +interpolation.nox = 1 +interpolation.noy = 1 +interpolation.noz = 1 + +# CFL +warpx.cfl = 1.0 + +# Particles +particles.nspecies = 2 +particles.species_names = electrons positrons + +electrons.charge = -q_e +electrons.mass = m_e +electrons.injection_style = "NUniformPerCell" +electrons.num_particles_per_cell_each_dim = 2 2 +electrons.xmin = -20.e-6 +electrons.xmax = 20.e-6 +electrons.ymin = -20.e-6 +electrons.ymax = 20.e-6 +electrons.zmin = -20.e-6 +electrons.zmax = 20.e-6 + +electrons.profile = constant +electrons.density = 2.e24 # number of electrons per m^3 +electrons.momentum_distribution_type = "custom" +# See CustomMomentumProb for a definition of the parameters +electrons.custom_momentum_params = -0.01 4.e24 2 2 2 + +positrons.charge = q_e +positrons.mass = m_e +positrons.injection_style = "NUniformPerCell" +positrons.num_particles_per_cell_each_dim = 2 2 +positrons.xmin = -20.e-6 +positrons.xmax = 20.e-6 +positrons.ymin = -20.e-6 +positrons.ymax = 20.e-6 +positrons.zmin = -20.e-6 +positrons.zmax = 20.e-6 + +positrons.profile = constant +positrons.density = 2.e24 # number of positrons per m^3 +positrons.momentum_distribution_type = "custom" +# See CustomMomentumProb for a definition of the parameters +positrons.custom_momentum_params = 0.01 4.e24 2 2 2 diff --git a/Source/WarpXFFT.cpp b/Source/WarpXFFT.cpp index f394d5f64..810a1b29c 100644 --- a/Source/WarpXFFT.cpp +++ b/Source/WarpXFFT.cpp @@ -266,7 +266,6 @@ void WarpX::FFTDomainDecompsition (int lev, BoxArray& ba_fft, DistributionMapping& dm_fft, BoxArray& ba_valid, Box& domain_fft, const Box& domain) { - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(AMREX_SPACEDIM == 3, "PSATD only works in 3D"); IntVect nguards_fft(AMREX_D_DECL(nox_fft/2,noy_fft/2,noz_fft/2)); @@ -281,14 +280,15 @@ WarpX::FFTDomainDecompsition (int lev, BoxArray& ba_fft, DistributionMapping& dm // Ask FFTW to chop the current FFT sub-group domain in the z-direction // and give a chunk to each MPI rank in the current sub-group. int nz_fft, z0_fft; - warpx_fft_domain_decomp(&nz_fft, &z0_fft, BL_TO_FORTRAN_BOX(domain_fft)); + + warpx_fft_domain_decomp(&nz_fft, &z0_fft, WARPX_TO_FORTRAN_BOX(domain_fft)); // Each MPI rank adds a box with its chunk of the FFT grid // (given by the above decomposition) to the list `bx_fft`, // then list is shared among all MPI ranks via AllGather Vector<Box> bx_fft; if (nz_fft > 0) { Box b = domain_fft; - b.setRange(2, z0_fft+domain_fft.smallEnd(2), nz_fft); + b.setRange(AMREX_SPACEDIM-1, z0_fft+domain_fft.smallEnd(AMREX_SPACEDIM-1), nz_fft); bx_fft.push_back(b); } amrex::AllGatherBoxes(bx_fft); @@ -397,17 +397,17 @@ WarpX::PushPSATD (int lev, amrex::Real /* dt */) BL_PROFILE_VAR_START(blp_push_eb); for (MFIter mfi(*Efield_fp_fft[lev][0]); mfi.isValid(); ++mfi) { - warpx_fft_push_eb(BL_TO_FORTRAN_ANYD((*Efield_fp_fft[lev][0])[mfi]), - BL_TO_FORTRAN_ANYD((*Efield_fp_fft[lev][1])[mfi]), - BL_TO_FORTRAN_ANYD((*Efield_fp_fft[lev][2])[mfi]), - BL_TO_FORTRAN_ANYD((*Bfield_fp_fft[lev][0])[mfi]), - BL_TO_FORTRAN_ANYD((*Bfield_fp_fft[lev][1])[mfi]), - BL_TO_FORTRAN_ANYD((*Bfield_fp_fft[lev][2])[mfi]), - BL_TO_FORTRAN_ANYD((*current_fp_fft[lev][0])[mfi]), - BL_TO_FORTRAN_ANYD((*current_fp_fft[lev][1])[mfi]), - BL_TO_FORTRAN_ANYD((*current_fp_fft[lev][2])[mfi]), - BL_TO_FORTRAN_ANYD((*rho_prev_fp_fft[lev])[mfi]), - BL_TO_FORTRAN_ANYD((*rho_next_fp_fft[lev])[mfi])); + warpx_fft_push_eb(WARPX_TO_FORTRAN_ANYD((*Efield_fp_fft[lev][0])[mfi]), + WARPX_TO_FORTRAN_ANYD((*Efield_fp_fft[lev][1])[mfi]), + WARPX_TO_FORTRAN_ANYD((*Efield_fp_fft[lev][2])[mfi]), + WARPX_TO_FORTRAN_ANYD((*Bfield_fp_fft[lev][0])[mfi]), + WARPX_TO_FORTRAN_ANYD((*Bfield_fp_fft[lev][1])[mfi]), + WARPX_TO_FORTRAN_ANYD((*Bfield_fp_fft[lev][2])[mfi]), + WARPX_TO_FORTRAN_ANYD((*current_fp_fft[lev][0])[mfi]), + WARPX_TO_FORTRAN_ANYD((*current_fp_fft[lev][1])[mfi]), + WARPX_TO_FORTRAN_ANYD((*current_fp_fft[lev][2])[mfi]), + WARPX_TO_FORTRAN_ANYD((*rho_prev_fp_fft[lev])[mfi]), + WARPX_TO_FORTRAN_ANYD((*rho_next_fp_fft[lev])[mfi])); } BL_PROFILE_VAR_STOP(blp_push_eb); diff --git a/Source/WarpX_f.H b/Source/WarpX_f.H index 029c07377..377d8fd11 100644 --- a/Source/WarpX_f.H +++ b/Source/WarpX_f.H @@ -1,6 +1,19 @@ #include <AMReX_BLFort.H> +#ifdef __cplusplus + +#if AMREX_SPACEDIM==2 +#define WARPX_ARLIM_ANYD(x) std::array<int,3>{(x)[0], 0, (x)[1]}.data() +#else +#define WARPX_ARLIM_ANYD(x) x +#endif + +#define WARPX_TO_FORTRAN_BOX(x) WARPX_ARLIM_ANYD((x).loVect()), WARPX_ARLIM_ANYD((x).hiVect()) +#define WARPX_TO_FORTRAN_ANYD(x) (x).dataPtr(), WARPX_ARLIM_ANYD((x).loVect()), WARPX_ARLIM_ANYD((x).hiVect()) + +#endif + #if (AMREX_SPACEDIM == 3) #define WRPX_COMPUTE_DIVB warpx_compute_divb_3d diff --git a/Source/WarpX_fft.F90 b/Source/WarpX_fft.F90 index 406f3f90f..bdbdf7f3c 100644 --- a/Source/WarpX_fft.F90 +++ b/Source/WarpX_fft.F90 @@ -107,7 +107,6 @@ contains type(c_ptr), intent(inout) :: fft_data(ndata) real(c_double), intent(in) :: dx_wrpx(3), dt_wrpx - integer :: iret integer(idp) :: nopenmp integer :: nx_padded integer, dimension(3) :: shp @@ -297,7 +296,11 @@ contains rhoold => rhoold_wrpx ! Call the corresponding PICSAR function +#if (BL_SPACEDIM == 3) CALL push_psatd_ebfield_3d() +#elif (BL_SPACEDIM == 2) + CALL push_psatd_ebfield_2d() +#endif ex => null() ey => null() |