-
Notifications
You must be signed in to change notification settings - Fork 200
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
Fix BTD/Scrape Flush Count with Filters #4657
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,7 +129,6 @@ void BTDiagnostics::DerivedInitData () | |
} | ||
} | ||
m_particles_buffer.resize(m_num_buffers); | ||
m_totalParticles_flushed_already.resize(m_num_buffers); | ||
m_totalParticles_in_buffer.resize(m_num_buffers); | ||
|
||
// check that simulation can fill all BTD snapshots | ||
|
@@ -1065,12 +1064,12 @@ BTDiagnostics::Flush (int i_buffer, bool force_flush) | |
} | ||
} | ||
m_flush_format->WriteToFile( | ||
m_varnames, m_mf_output[i_buffer], m_geom_output[i_buffer], warpx.getistep(), | ||
labtime, m_output_species[i_buffer], nlev_output, file_name, m_file_min_digits, | ||
m_varnames, m_mf_output.at(i_buffer), m_geom_output.at(i_buffer), warpx.getistep(), | ||
labtime, | ||
m_output_species.at(i_buffer), nlev_output, file_name, m_file_min_digits, | ||
m_plot_raw_fields, m_plot_raw_fields_guards, | ||
use_pinned_pc, isBTD, i_buffer, m_buffer_flush_counter[i_buffer], | ||
m_max_buffer_multifabs[i_buffer], m_geom_snapshot[i_buffer][0], isLastBTDFlush, | ||
m_totalParticles_flushed_already[i_buffer]); | ||
use_pinned_pc, isBTD, i_buffer, m_buffer_flush_counter.at(i_buffer), | ||
m_max_buffer_multifabs.at(i_buffer), m_geom_snapshot.at(i_buffer).at(0), isLastBTDFlush); | ||
|
||
// Rescaling the box for plotfile after WriteToFile. This is because, for plotfiles, when writing particles, amrex checks if the particles are within the bounds defined by the box. However, in BTD, particles can be (at max) 1 cell outside the bounds of the geometry. So we keep a one-cell bigger box for plotfile when writing out the particle data and rescale after. | ||
if (m_format == "plotfile") { | ||
|
@@ -1104,7 +1103,6 @@ BTDiagnostics::Flush (int i_buffer, bool force_flush) | |
NullifyFirstFlush(i_buffer); | ||
// if particles are selected for output then update and reset counters | ||
if (!m_output_species_names.empty()) { | ||
UpdateTotalParticlesFlushed(i_buffer); | ||
ResetTotalParticlesInBuffer(i_buffer); | ||
ClearParticleBuffer(i_buffer); | ||
} | ||
|
@@ -1271,10 +1269,10 @@ void BTDiagnostics::MergeBuffersForPlotfile (int i_snapshot) | |
InterleaveSpeciesHeader(recent_species_Header,snapshot_species_Header, | ||
m_output_species_names[i], m_buffer_flush_counter[i_snapshot]); | ||
if (BufferSpeciesHeader.m_total_particles == 0) { continue; } | ||
if (m_totalParticles_flushed_already[i_snapshot][i]==0) { | ||
WARPX_ALWAYS_ASSERT_WITH_MESSAGE( | ||
std::rename(recent_ParticleHdrFilename.c_str(), snapshot_ParticleHdrFilename.c_str()) == 0, | ||
std::string("Renaming ").append(recent_ParticleHdrFilename).append(" to ").append(snapshot_ParticleHdrFilename).append(" has failed")); | ||
if (!amrex::FileExists(snapshot_ParticleHdrFilename)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RevathiJambunathan @atmyers highlighting this: I want to remove Let me know if you would add another check for this line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is good! |
||
WARPX_ALWAYS_ASSERT_WITH_MESSAGE( | ||
std::rename(recent_ParticleHdrFilename.c_str(), snapshot_ParticleHdrFilename.c_str()) == 0, | ||
std::string("Renaming ").append(recent_ParticleHdrFilename).append(" to ").append(snapshot_ParticleHdrFilename).append(" has failed")); | ||
} else { | ||
InterleaveParticleDataHeader(recent_ParticleHdrFilename, | ||
snapshot_ParticleHdrFilename); | ||
|
@@ -1435,10 +1433,8 @@ BTDiagnostics::InitializeParticleBuffer () | |
const MultiParticleContainer& mpc = warpx.GetPartContainer(); | ||
for (int i = 0; i < m_num_buffers; ++i) { | ||
m_particles_buffer[i].resize(m_output_species_names.size()); | ||
m_totalParticles_flushed_already[i].resize(m_output_species_names.size()); | ||
m_totalParticles_in_buffer[i].resize(m_output_species_names.size()); | ||
for (int isp = 0; isp < m_particles_buffer[i].size(); ++isp) { | ||
m_totalParticles_flushed_already[i][isp] = 0; | ||
m_totalParticles_in_buffer[i][isp] = 0; | ||
m_particles_buffer[i][isp] = std::make_unique<PinnedMemoryParticleContainer>(WarpX::GetInstance().GetParGDB()); | ||
const int idx = mpc.getSpeciesID(m_output_species_names[isp]); | ||
|
@@ -1489,15 +1485,6 @@ BTDiagnostics::PrepareParticleDataForOutput() | |
} | ||
} | ||
|
||
void | ||
BTDiagnostics::UpdateTotalParticlesFlushed(int i_buffer) | ||
{ | ||
for (int isp = 0; isp < m_totalParticles_flushed_already[i_buffer].size(); ++isp) { | ||
m_totalParticles_flushed_already[i_buffer][isp] += static_cast<int>( | ||
m_particles_buffer[i_buffer][isp]->TotalNumberOfParticles()); | ||
} | ||
} | ||
|
||
void | ||
BTDiagnostics::ResetTotalParticlesInBuffer(int i_buffer) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed and delegated to the I/O backend, which currently does the filtering and thus knows what number of particles is truly written.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this also done for plotfile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I see - its not needed for plotfile - because we just merge headers and interleave data . this was needed mainly for openpmd.
all good!