Skip to content

Commit

Permalink
abort for openpmd bp backend if species is selected. Also write parti…
Browse files Browse the repository at this point in the history
…cle output for BTD only if write_species is 1
  • Loading branch information
RevathiJambunathan committed Oct 25, 2021
1 parent dd2c6d6 commit bd81754
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
22 changes: 9 additions & 13 deletions Source/Diagnostics/BTDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,6 @@ void BTDiagnostics::DerivedInitData ()
m_output_species.resize(m_num_buffers);
m_totalParticles_flushed_already.resize(m_num_buffers);
m_totalParticles_in_buffer.resize(m_num_buffers);
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());
// initialize these values to 0
for (int isp = 0; isp < m_totalParticles_flushed_already[i].size(); ++isp) {
m_totalParticles_flushed_already[i][isp] = 0;
m_totalParticles_in_buffer[i][isp] = 0;
}
}
}

void
Expand Down Expand Up @@ -664,9 +654,12 @@ BTDiagnostics::Flush (int i_buffer)
// Reset the buffer counter to zero after flushing out data stored in the buffer.
ResetBufferCounter(i_buffer);
IncrementBufferFlushCounter(i_buffer);
UpdateTotalParticlesFlushed(i_buffer);
ResetTotalParticlesInBuffer(i_buffer);
ClearParticleBuffer(i_buffer);
// if particles are selected for output then update and reset counters
if (m_output_species_names.size() > 0) {
UpdateTotalParticlesFlushed(i_buffer);
ResetTotalParticlesInBuffer(i_buffer);
ClearParticleBuffer(i_buffer);
}
}

void BTDiagnostics::MergeBuffersForPlotfile (int i_snapshot)
Expand Down Expand Up @@ -933,6 +926,9 @@ BTDiagnostics::InitializeParticleBuffer ()
auto& warpx = WarpX::GetInstance();
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;
Expand Down
17 changes: 10 additions & 7 deletions Source/Diagnostics/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,18 @@ Diagnostics::InitData ()
InitializeFieldBufferData(i_buffer, lev);
}
}
// When particle buffers, m_particle_boundary_buffer are included,
// they will be initialized here
InitializeParticleBuffer();
InitializeParticleFunctors();

amrex::ParmParse pp_diag_name(m_diag_name);
// default for writing species output is 1
int write_species = 1;
pp_diag_name.query("write_species", write_species);
if (write_species == 1) {
// When particle buffers, m_particle_boundary_buffer are included,
// they will be initialized here
InitializeParticleBuffer();
InitializeParticleFunctors();
}

amrex::Vector <amrex::Real> dummy_val(AMREX_SPACEDIM);
if ( queryArrWithParser(pp_diag_name, "diag_lo", dummy_val, 0, AMREX_SPACEDIM) ||
queryArrWithParser(pp_diag_name, "diag_hi", dummy_val, 0, AMREX_SPACEDIM) ) {
Expand All @@ -221,9 +227,6 @@ Diagnostics::InitData ()
amrex::Print() << " WARNING: For full diagnostics on a reduced domain, particle io is not supported, yet! Therefore, particle-io is disabled for this diag " << m_diag_name << "\n";
}

// default for writing species output is 1
int write_species = 1;
pp_diag_name.query("write_species", write_species);
if (write_species == 0) {
if (m_format == "checkpoint"){
amrex::Abort("For checkpoint format, write_species flag must be 1.");
Expand Down
20 changes: 20 additions & 0 deletions Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ FlushFormatOpenPMD::FlushFormatOpenPMD (const std::string& diag_name)
operator_type, operator_parameters,
warpx.getPMLdirections()
);

// Temporarily adding Abort for adios filetype if species is selected for BTD output
bool species_output = true;
int write_species = 1;
std::vector< std::string > output_species_names;
bool species_specified = pp_diag_name.queryarr("species", output_species_names);
if (species_specified == true and output_species_names.size() > 0) {
species_output = true;
} else {
// By default species output is computed for all diagnostics, if write_species is not set to 0
species_output = true;
}
// Check user-defined option to turn off species output
pp_diag_name.query("write_species", write_species);
if (write_species == 0) species_output = false;
if (diag_type_str == "BackTransformed" and species_output == true) {
if (m_OpenPMDPlotWriter->OpenPMDFileType() == "bp") {
amrex::Abort(" Currently BackTransformed diagnostics type does not support species output for ADIOS backend. Please select h5 as openpmd backend");
}
}
}

void
Expand Down
2 changes: 2 additions & 0 deletions Source/Diagnostics/WarpXOpenPMD.H
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ public:
bool isBTD = false,
const amrex::Geometry& full_BTD_snapshot=amrex::Geometry() ) const;

/** Return OpenPMD File type ("bp" or "h5" or "json")*/
std::string OpenPMDFileType () {return m_OpenPMDFileType;}

private:
void Init (openPMD::Access access, bool isBTD);
Expand Down

0 comments on commit bd81754

Please sign in to comment.