Skip to content

Commit

Permalink
Remove particles that are initialized in the EB (ECP-WarpX#4585)
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiLehe authored Jan 29, 2024
1 parent 94ae119 commit 67c9aa2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
16 changes: 16 additions & 0 deletions Source/Particles/PhysicalParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#include "Utils/WarpXAlgorithmSelection.H"
#include "Utils/WarpXConst.H"
#include "Utils/WarpXProfilerWrapper.H"
#ifdef AMREX_USE_EB
# include "EmbeddedBoundary/ParticleBoundaryProcess.H"
# include "EmbeddedBoundary/ParticleScraper.H"
#endif
#include "WarpX.H"

#include <ablastr/warn_manager/WarnManager.H>
Expand Down Expand Up @@ -1428,6 +1432,12 @@ PhysicalParticleContainer::AddPlasma (PlasmaInjector const& plasma_injector, int
}
}

// Remove particles that are inside the embedded boundaries
#ifdef AMREX_USE_EB
auto & distance_to_eb = WarpX::GetInstance().GetDistanceToEB();
scrapeParticles( *this, amrex::GetVecOfConstPtrs(distance_to_eb), ParticleBoundaryProcess::Absorb());
#endif

// The function that calls this is responsible for redistributing particles.
}

Expand Down Expand Up @@ -1920,6 +1930,12 @@ PhysicalParticleContainer::AddPlasmaFlux (PlasmaInjector const& plasma_injector,
}
}

// Remove particles that are inside the embedded boundaries
#ifdef AMREX_USE_EB
auto & distance_to_eb = WarpX::GetInstance().GetDistanceToEB();
scrapeParticles(tmp_pc, amrex::GetVecOfConstPtrs(distance_to_eb), ParticleBoundaryProcess::Absorb());
#endif

// Redistribute the new particles that were added to the temporary container.
// (This eliminates invalid particles, and makes sure that particles
// are in the right tile.)
Expand Down
11 changes: 10 additions & 1 deletion Source/Particles/WarpXParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@
#include <AMReX_ParticleUtil.H>
#include <AMReX_Random.H>
#include <AMReX_Utility.H>

#ifdef AMREX_USE_EB
# include "EmbeddedBoundary/ParticleBoundaryProcess.H"
# include "EmbeddedBoundary/ParticleScraper.H"
#endif

#ifdef AMREX_USE_OMP
# include <omp.h>
Expand Down Expand Up @@ -293,6 +296,12 @@ WarpXParticleContainer::AddNParticles (int /*lev*/, long n,
);
}

// Remove particles that are inside the embedded boundaries
#ifdef AMREX_USE_EB
auto & distance_to_eb = WarpX::GetInstance().GetDistanceToEB();
scrapeParticles( *this, amrex::GetVecOfConstPtrs(distance_to_eb), ParticleBoundaryProcess::Absorb());
#endif

Redistribute();
}

Expand Down
4 changes: 3 additions & 1 deletion Source/WarpX.H
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ public:
MacroscopicProperties& GetMacroscopicProperties () { return *m_macroscopic_properties; }
HybridPICModel& GetHybridPICModel () { return *m_hybrid_pic_model; }
MultiDiagnostics& GetMultiDiags () {return *multi_diags;}

#ifdef AMREX_USE_EB
amrex::Vector<std::unique_ptr<amrex::MultiFab> >& GetDistanceToEB () {return m_distance_to_eb;}
#endif
ParticleBoundaryBuffer& GetParticleBoundaryBuffer () { return *m_particle_boundary_buffer; }

static void shiftMF (amrex::MultiFab& mf, const amrex::Geometry& geom,
Expand Down

0 comments on commit 67c9aa2

Please sign in to comment.