From 71ca75648289904e071b4f6ba6ce8a031ac725f2 Mon Sep 17 00:00:00 2001 From: Remi Lehe Date: Tue, 20 Sep 2022 16:54:42 -0700 Subject: Add option to deposit laser on main grid (#3235) * Add option to deposit laser on main grid * Use `deposit_on_main_grid` * Update Source/Particles/LaserParticleContainer.cpp * Add documentation * Update documentation --- Source/Particles/LaserParticleContainer.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'Source/Particles/LaserParticleContainer.cpp') diff --git a/Source/Particles/LaserParticleContainer.cpp b/Source/Particles/LaserParticleContainer.cpp index 565ac3ee1..a8df886be 100644 --- a/Source/Particles/LaserParticleContainer.cpp +++ b/Source/Particles/LaserParticleContainer.cpp @@ -550,6 +550,8 @@ LaserParticleContainer::Evolve (int lev, amrex::LayoutData* cost = WarpX::getCosts(lev); + const bool has_buffer = cjx; + #ifdef AMREX_USE_OMP #pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) #endif @@ -578,18 +580,21 @@ LaserParticleContainer::Evolve (int lev, auto& uzp = attribs[PIdx::uz]; const long np = pti.numParticles(); - // For now, laser particles do not take the current buffers into account - const long np_current = np; - plane_Xp.resize(np); plane_Yp.resize(np); amplitude_E.resize(np); + // Determine whether particles will deposit on the fine or coarse level + long np_current = np; + if (lev > 0 && m_deposit_on_main_grid && has_buffer) { + np_current = 0; + } + if (rho && ! skip_deposition && ! do_not_deposit) { int* AMREX_RESTRICT ion_lev = nullptr; DepositCharge(pti, wp, ion_lev, rho, 0, 0, np_current, thread_num, lev, lev); - if (crho) { + if (has_buffer) { DepositCharge(pti, wp, ion_lev, crho, 0, np_current, np-np_current, thread_num, lev, lev-1); } @@ -628,7 +633,6 @@ LaserParticleContainer::Evolve (int lev, 0, np_current, thread_num, lev, lev, dt, relative_time); - const bool has_buffer = cjx; if (has_buffer) { // Deposit in buffers @@ -643,7 +647,7 @@ LaserParticleContainer::Evolve (int lev, int* AMREX_RESTRICT ion_lev = nullptr; DepositCharge(pti, wp, ion_lev, rho, 1, 0, np_current, thread_num, lev, lev); - if (crho) { + if (has_buffer) { DepositCharge(pti, wp, ion_lev, crho, 1, np_current, np-np_current, thread_num, lev, lev-1); } -- cgit v1.2.3