Skip to content

Commit

Permalink
removed comments and a few fixes to be consistant with the openPMD-api
Browse files Browse the repository at this point in the history
outputs
  • Loading branch information
Junmin Gu committed Oct 31, 2023
1 parent c6ce63c commit adb5248
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 27 deletions.
26 changes: 6 additions & 20 deletions Source/Diagnostics/FlushFormats/FlushFormatPlotPlus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ FlushFormatPlotPlus::WriteToFile (
int snapshotID,
[[maybe_unused]] int bufferID,
[[maybe_unused]] int numBuffers,
const amrex::Geometry& /*full_BTD_snapshot*/,
const amrex::Geometry& full_BTD_snapshot,
bool isLastBTDFlush, const amrex::Vector<int>& totalParticlesFlushedAlready) const
{
WARPX_PROFILE("FlushFormatPlotPlus::WriteToFile()");
Expand All @@ -101,36 +101,24 @@ FlushFormatPlotPlus::WriteToFile (
std::string plot_name = amrex::Concatenate(prefix, snapshotID, file_min_digits);
plot_name = plot_name+"/buffer";
const std::string& filename = amrex::Concatenate(plot_name, iteration[0], file_min_digits);
/*
if (!isBTD)
{
amrex::Print() << Utils::TextMsg::Info("Writing plotfile " + filename);
} else
{
amrex::Print() << Utils::TextMsg::Info("Writing buffer " + std::to_string(bufferID+1) + " of " + std::to_string(numBuffers)
+ " to snapshot " + std::to_string(snapshotID) + " in plotfile BTD " + plot_name );
if (isLastBTDFlush)
{
amrex::Print() << Utils::TextMsg::Info("Finished writing snapshot " + std::to_string(snapshotID) + " in plotfile BTD " + filename);
}
}
*/

{ // amrex-bp version
WARPX_PROFILE("FlushFormatPlotPlus_OpenPMDPlotFiles()");

std::string opmdPrefix = prefix;
if (isBTD)
{
BTDWriter(opmdPrefix, snapshotID, varnames, mf, geom, time, particle_diags, use_pinned_pc, isLastBTDFlush, totalParticlesFlushedAlready);
amrex::Vector<amrex::Geometry> btd_geoms(geom.size());
for (auto i=0; i<geom.size(); i++)
btd_geoms[i] = full_BTD_snapshot;
BTDWriter(opmdPrefix, snapshotID, varnames, mf, btd_geoms, time, particle_diags, use_pinned_pc, isLastBTDFlush, totalParticlesFlushedAlready);
}
else
DefaultWriter(opmdPrefix, iteration[0], varnames, mf, geom, time, particle_diags, use_pinned_pc);

} // end of amrex-bp version
}

//#ifdef FANCY_AMREX
void FlushFormatPlotPlus::BTDWriter(const std::string& prefix,
int output_iteration,
const amrex::Vector<std::string> varnames,
Expand Down Expand Up @@ -254,7 +242,7 @@ void FlushFormatPlotPlus::GetNames(const ParticleDiag& part_diag,
) const
{
WarpXParticleContainer* pc = part_diag.getParticleContainer();
real_names.push_back("weight");
real_names.push_back("weighting");

real_names.push_back("momentum_x");
real_names.push_back("momentum_y");
Expand Down Expand Up @@ -407,7 +395,6 @@ void AMReXWithOpenPMD::SetWriter(amrex::openpmd_api::AMReX_openPMDWriter* w)

AMReXWithOpenPMD::~AMReXWithOpenPMD()
{
amrex::Print()<<" openpmd_api::close handler "<<m_Prefix<<" \n";
openpmd_api::CloseUserHandler(m_UserHandler);
}

Expand All @@ -416,7 +403,6 @@ bool AMReXWithOpenPMD::InitLocalHandler(const std::string& prefix)
if (m_Prefix.compare(prefix) == 0)
return false;

amrex::Print()<<" openpmd_api::Init handler "<<m_Prefix<<" \n";
m_Prefix = prefix;
m_UserHandler = openpmd_api::InitUserHandler(prefix);
return true;
Expand Down
11 changes: 5 additions & 6 deletions Source/Diagnostics/FlushFormats/warpxBTD.H
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,8 @@ void AMReX_warpxBTDWriter::Init(openPMD::Access access)
{
if (m_Series != nullptr) {
m_FirstSightOfStep = ! m_Series->iterations.contains( m_CurrentStep );
amrex::Print()<<m_FirstSightOfStep<<" BTD Init "<<m_CurrentStep<<" \n ";
return;
}
amrex::Print()<<" BTD Init.. "<<m_CurrentStep<<" \n ";
m_FirstSightOfStep = true;
AMReX_openPMDWriter::Init(access);
}
Expand All @@ -133,20 +131,21 @@ bool AMReX_warpxBTDWriter::AllocatePtlProperties(openPMD::ParticleSpecies& currS
{
if (np > 0)
{
amrex::Print() <<"btd allocate np="<<np<<" m_assigned = "<<m_AssignedPtlOffset<<" \n";
//AMReX_openPMDWriter::SetupPos(currSpecies, np + m_AssignedPtlOffset);
return AMReX_openPMDWriter::AllocatePtlProperties(currSpecies, write_real_comp, real_comp_names,
write_int_comp, int_comp_names, np + GetGrandOffset());
}
// np == 0
if ( m_LastFlush && ( m_AssignedPtlOffset == 0 ) )
{
amrex::Print() <<"btd last allocate np="<<np<<" m_assigned = "<<m_AssignedPtlOffset<<" \n";
// properties were never allocated
//AMReX_openPMDWriter::SetupPos(currSpecies, np);
return AMReX_openPMDWriter::AllocatePtlProperties(currSpecies, write_real_comp, real_comp_names, write_int_comp, int_comp_names, np);
}
amrex::Print() <<"btd skip allocation np="<<np<<" m_assigned = "<<m_AssignedPtlOffset<<" \n";

if (m_LastFlush) {
return true; // no need to do more allocation
}

return false;
}

Expand Down
1 change: 0 additions & 1 deletion Source/Diagnostics/FlushFormats/warpxWriter.H
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ void AMReX_warpxWriter::SetupMeshComp (openPMD::Mesh& mesh,
amrex::Box const & global_box = full_geom.Domain();
auto global_size = amrex::openpmd_api::helper::getReversedVec(global_box.size() );

amrex::Print()<<" warpx::setupmeshcomp "<<varName.m_FieldName<<varName.m_CompName<<" global box="<<global_box<<std::endl;
// - Grid spacing
std::vector<double> const grid_spacing = amrex::openpmd_api::helper::getReversedVec(full_geom.CellSize());
mesh.setGridSpacing(grid_spacing);
Expand Down

0 comments on commit adb5248

Please sign in to comment.