Skip to content

Commit 7659813

Browse files
committed
Remove particles that are initialized in the EB
1 parent 9b48df9 commit 7659813

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

Source/Particles/PhysicalParticleContainer.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
#include "Utils/WarpXAlgorithmSelection.H"
4040
#include "Utils/WarpXConst.H"
4141
#include "Utils/WarpXProfilerWrapper.H"
42+
#ifdef AMREX_USE_EB
43+
# include "EmbeddedBoundary/ParticleBoundaryProcess.H"
44+
# include "EmbeddedBoundary/ParticleScraper.H"
45+
#endif
4246
#include "WarpX.H"
4347

4448
#include <ablastr/warn_manager/WarnManager.H>
@@ -1430,6 +1434,12 @@ PhysicalParticleContainer::AddPlasma (PlasmaInjector const& plasma_injector, int
14301434
}
14311435
}
14321436

1437+
// Remove particles that are inside the embedded boundaries
1438+
#ifdef AMREX_USE_EB
1439+
auto & distance_to_eb = WarpX::GetInstance().GetDistanceToEB();
1440+
scrapeParticles( *this, amrex::GetVecOfConstPtrs(distance_to_eb), ParticleBoundaryProcess::Absorb());
1441+
#endif
1442+
14331443
// The function that calls this is responsible for redistributing particles.
14341444
}
14351445

@@ -1923,6 +1933,12 @@ PhysicalParticleContainer::AddPlasmaFlux (PlasmaInjector const& plasma_injector,
19231933
}
19241934
}
19251935

1936+
// Remove particles that are inside the embedded boundaries
1937+
#ifdef AMREX_USE_EB
1938+
auto & distance_to_eb = WarpX::GetInstance().GetDistanceToEB();
1939+
scrapeParticles(tmp_pc, amrex::GetVecOfConstPtrs(distance_to_eb), ParticleBoundaryProcess::Absorb());
1940+
#endif
1941+
19261942
// Redistribute the new particles that were added to the temporary container.
19271943
// (This eliminates invalid particles, and makes sure that particles
19281944
// are in the right tile.)

Source/Particles/WarpXParticleContainer.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@
6060
#include <AMReX_ParticleUtil.H>
6161
#include <AMReX_Random.H>
6262
#include <AMReX_Utility.H>
63-
63+
#ifdef AMREX_USE_EB
64+
# include "EmbeddedBoundary/ParticleBoundaryProcess.H"
65+
# include "EmbeddedBoundary/ParticleScraper.H"
66+
#endif
6467

6568
#ifdef AMREX_USE_OMP
6669
# include <omp.h>
@@ -291,6 +294,12 @@ WarpXParticleContainer::AddNParticles (int /*lev*/, long n,
291294
);
292295
}
293296

297+
// Remove particles that are inside the embedded boundaries
298+
#ifdef AMREX_USE_EB
299+
auto & distance_to_eb = WarpX::GetInstance().GetDistanceToEB();
300+
scrapeParticles( *this, amrex::GetVecOfConstPtrs(distance_to_eb), ParticleBoundaryProcess::Absorb());
301+
#endif
302+
294303
Redistribute();
295304
}
296305

Source/WarpX.H

+3-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ public:
132132
MacroscopicProperties& GetMacroscopicProperties () { return *m_macroscopic_properties; }
133133
HybridPICModel& GetHybridPICModel () { return *m_hybrid_pic_model; }
134134
MultiDiagnostics& GetMultiDiags () {return *multi_diags;}
135-
135+
#ifdef AMREX_USE_EB
136+
amrex::Vector<std::unique_ptr<amrex::MultiFab> >& GetDistanceToEB () {return m_distance_to_eb;}
137+
#endif
136138
ParticleBoundaryBuffer& GetParticleBoundaryBuffer () { return *m_particle_boundary_buffer; }
137139

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

0 commit comments

Comments
 (0)