diff options
author | 2019-07-22 13:30:44 -0700 | |
---|---|---|
committer | 2019-07-22 13:30:44 -0700 | |
commit | 9eff1e737a556d0e18f1a2e2b7c191ae4e2ced5d (patch) | |
tree | 0eda3fba6bc797a6f6dd874538d12db605abb902 /Source/WarpX.cpp | |
parent | 8f9c13a90feb1749d5bfff338285c3ccec7314d2 (diff) | |
parent | 8bfa6e2399c1e568d6f5305d3280397aadf9a4fe (diff) | |
download | WarpX-9eff1e737a556d0e18f1a2e2b7c191ae4e2ced5d.tar.gz WarpX-9eff1e737a556d0e18f1a2e2b7c191ae4e2ced5d.tar.zst WarpX-9eff1e737a556d0e18f1a2e2b7c191ae4e2ced5d.zip |
Merge branch 'dev' into EBpush_to_cpp
Diffstat (limited to 'Source/WarpX.cpp')
-rw-r--r-- | Source/WarpX.cpp | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 877882037..08948227c 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -37,6 +37,7 @@ Vector<int> WarpX::boost_direction = {0,0,0}; int WarpX::do_compute_max_step_from_zmax = 0; Real WarpX::zmax_plasma_to_compute_max_step = 0.; +long WarpX::use_picsar_deposition = 1; long WarpX::current_deposition_algo; long WarpX::charge_deposition_algo; long WarpX::field_gathering_algo; @@ -484,7 +485,17 @@ WarpX::ReadParameters () { ParmParse pp("algo"); + // If not in RZ mode, read use_picsar_deposition + // In RZ mode, use_picsar_deposition is on, as the C++ version + // of the deposition does not support RZ +#ifndef WARPX_RZ + pp.query("use_picsar_deposition", use_picsar_deposition); +#endif current_deposition_algo = GetAlgorithmInteger(pp, "current_deposition"); + if (!use_picsar_deposition){ + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( current_deposition_algo >= 2, + "if not use_picsar_deposition, cannot use Esirkepov deposition."); + } charge_deposition_algo = GetAlgorithmInteger(pp, "charge_deposition"); field_gathering_algo = GetAlgorithmInteger(pp, "field_gathering"); particle_pusher_algo = GetAlgorithmInteger(pp, "particle_pusher"); @@ -556,8 +567,10 @@ WarpX::MakeNewLevelFromScratch (int lev, Real time, const BoxArray& new_grids, InitLevelData(lev, time); #ifdef WARPX_USE_PSATD - AllocLevelDataFFT(lev); - InitLevelDataFFT(lev, time); + if (fft_hybrid_mpi_decomposition){ + AllocLevelDataFFT(lev); + InitLevelDataFFT(lev, time); + } #endif } @@ -693,6 +706,37 @@ WarpX::AllocLevelData (int lev, const BoxArray& ba, const DistributionMapping& d // CKC solver requires one additional guard cell if (maxwell_fdtd_solver_id == 1) ngF = std::max( ngF, 1 ); +#ifdef WARPX_USE_PSATD + if (fft_hybrid_mpi_decomposition == false){ + // All boxes should have the same number of guard cells + // (to avoid temporary parallel copies) + // Thus take the max of the required number of guards for each field + // Also: the number of guard cell should be enough to contain + // the stencil of the FFT solver. Here, this number (`ngFFT`) + // is determined *empirically* to be the order of the solver + // for nodal, and half the order of the solver for staggered. + IntVect ngFFT; + if (do_nodal) { + ngFFT = IntVect(AMREX_D_DECL(nox_fft, noy_fft, noz_fft)); + } else { + ngFFT = IntVect(AMREX_D_DECL(nox_fft/2, noy_fft/2, noz_fft/2)); + } + for (int i_dim=0; i_dim<AMREX_SPACEDIM; i_dim++ ){ + int ng_required = ngFFT[i_dim]; + // Get the max + ng_required = std::max( ng_required, ngE[i_dim] ); + ng_required = std::max( ng_required, ngJ[i_dim] ); + ng_required = std::max( ng_required, ngRho[i_dim] ); + ng_required = std::max( ng_required, ngF ); + // Set the guard cells to this max + ngE[i_dim] = ng_required; + ngJ[i_dim] = ng_required; + ngRho[i_dim] = ng_required; + ngF = ng_required; + } + } +#endif + AllocLevelMFs(lev, ba, dm, ngE, ngJ, ngRho, ngF); } @@ -743,6 +787,21 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm rho_fp[lev].reset(new MultiFab(amrex::convert(ba,IntVect::TheUnitVector()),dm,2,ngRho)); rho_fp_owner_masks[lev] = std::move(rho_fp[lev]->OwnerMask(period)); } + if (fft_hybrid_mpi_decomposition == false){ + // Allocate and initialize the spectral solver + std::array<Real,3> dx = CellSize(lev); +#if (AMREX_SPACEDIM == 3) + RealVect dx_vect(dx[0], dx[1], dx[2]); +#elif (AMREX_SPACEDIM == 2) + RealVect dx_vect(dx[0], dx[2]); +#endif + // Get the cell-centered box, with guard cells + BoxArray realspace_ba = ba; // Copy box + realspace_ba.enclosedCells().grow(ngE); // cell-centered + guard cells + // Define spectral solver + spectral_solver_fp[lev].reset( new SpectralSolver( realspace_ba, dm, + nox_fft, noy_fft, noz_fft, do_nodal, dx_vect, dt[lev] ) ); + } #endif // |