Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WarpX class: sort_particles_for_deposition and sort_idx_type no longer static #5718

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Source/Evolve/WarpXEvolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,8 @@ void WarpX::HandleParticlesAtBoundaries (int step, amrex::Real cur_time, int num
if (verbose) {
amrex::Print() << Utils::TextMsg::Info("re-sorting particles");
}
mypc->SortParticlesByBin(sort_bin_size);
mypc->SortParticlesByBin(
sort_bin_size, m_sort_particles_for_deposition, m_sort_idx_type);
}
}

Expand Down
5 changes: 4 additions & 1 deletion Source/Particles/MultiParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ public:

void WriteHeader (std::ostream& os) const;

void SortParticlesByBin (amrex::IntVect bin_size);
void SortParticlesByBin (
const amrex::IntVect& bin_size,
bool sort_particles_for_deposition,
const amrex::IntVect& sort_idx_type);

void Redistribute ();

Expand Down
9 changes: 6 additions & 3 deletions Source/Particles/MultiParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,14 @@ MultiParticleContainer::GetChargeDensity (int lev, bool local)
}

void
MultiParticleContainer::SortParticlesByBin (amrex::IntVect bin_size)
MultiParticleContainer::SortParticlesByBin (
const amrex::IntVect& bin_size,
const bool sort_particles_for_deposition,
const amrex::IntVect& sort_idx_type)
{
for (auto& pc : allcontainers) {
if (WarpX::sort_particles_for_deposition) {
pc->SortParticlesForDeposition(WarpX::sort_idx_type);
if (sort_particles_for_deposition) {
pc->SortParticlesForDeposition(sort_idx_type);
} else {
pc->SortParticlesByBin(bin_size);
}
Expand Down
17 changes: 12 additions & 5 deletions Source/WarpX.H
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,6 @@ public:
static utils::parser::IntervalsParser sort_intervals;
static amrex::IntVect sort_bin_size;

//! If true, particles will be sorted in the order x -> y -> z -> ppc for faster deposition
static bool sort_particles_for_deposition;
//! Specifies the type of grid used for the above sorting, i.e. cell-centered, nodal, or mixed
static amrex::IntVect sort_idx_type;

static bool do_multi_J;
static int do_multi_J_n_depositions;

Expand Down Expand Up @@ -1489,6 +1484,18 @@ private:
int noy_fft = 16;
int noz_fft = 16;



//! If true, particles will be sorted in the order x -> y -> z -> ppc for faster deposition
#if defined(AMREX_USE_CUDA)
bool m_sort_particles_for_deposition = true;
#else
bool m_sort_particles_for_deposition = false;
#endif

//! Specifies the type of grid used for the above sorting, i.e. cell-centered, nodal, or mixed
amrex::IntVect m_sort_idx_type = amrex::IntVect(AMREX_D_DECL(0,0,0));

//! Solve Poisson equation when loading an external magnetic field to clean divergence
//! This is useful to remove errors that could lead to non-zero B field divergence
bool m_do_divb_cleaning_external = false;
Expand Down
12 changes: 2 additions & 10 deletions Source/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,6 @@ bool WarpX::refine_plasma = false;
utils::parser::IntervalsParser WarpX::sort_intervals;
amrex::IntVect WarpX::sort_bin_size(AMREX_D_DECL(1,1,1));

#if defined(AMREX_USE_CUDA)
bool WarpX::sort_particles_for_deposition = true;
#else
bool WarpX::sort_particles_for_deposition = false;
#endif

amrex::IntVect WarpX::sort_idx_type(AMREX_D_DECL(0,0,0));

bool WarpX::do_dynamic_scheduling = true;

bool WarpX::do_multi_J = false;
Expand Down Expand Up @@ -1385,15 +1377,15 @@ WarpX::ReadParameters ()
}
}

pp_warpx.query("sort_particles_for_deposition",sort_particles_for_deposition);
pp_warpx.query("sort_particles_for_deposition",m_sort_particles_for_deposition);
Vector<int> vect_sort_idx_type(AMREX_SPACEDIM,0);
const bool sort_idx_type_is_specified =
utils::parser::queryArrWithParser(
pp_warpx, "sort_idx_type",
vect_sort_idx_type, 0, AMREX_SPACEDIM);
if (sort_idx_type_is_specified){
for (int i=0; i<AMREX_SPACEDIM; i++) {
sort_idx_type[i] = vect_sort_idx_type[i];
m_sort_idx_type[i] = vect_sort_idx_type[i];
}
}

Expand Down
Loading