Skip to content

Commit

Permalink
Fix ParticleHistogram2D (#4779)
Browse files Browse the repository at this point in the history
* fix unfreed host buffer and missing iteration and series close in ParticleHistogram2D

* More efficient resize

Co-authored-by: Weiqun Zhang <WeiqunZhang@lbl.gov>

---------

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Co-authored-by: Weiqun Zhang <WeiqunZhang@lbl.gov>
  • Loading branch information
3 people authored Mar 25, 2024
1 parent 91f3ff1 commit d7b1aba
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void ParticleHistogram2D::ComputeDiags (int step)
Array<int,2> tlo{0,0}; // lower bounds
Array<int,2> thi{m_bin_num_abs-1, m_bin_num_ord-1}; // inclusive upper bounds
amrex::TableData<amrex::Real,2> d_data_2D(tlo, thi);
m_h_data_2D = amrex::TableData<amrex::Real,2> (tlo, thi, The_Pinned_Arena());
m_h_data_2D.resize(tlo, thi, The_Pinned_Arena());
auto const& h_table_data = m_h_data_2D.table();

// Initialize data on the host
Expand Down Expand Up @@ -316,6 +316,8 @@ void ParticleHistogram2D::WriteToFile (int step) const
{static_cast<unsigned long>(m_bin_num_ord), static_cast<unsigned long>(m_bin_num_abs)});

series.flush();
i.close();
series.close();
#else
amrex::ignore_unused(step);
WARPX_ABORT_WITH_MESSAGE("ParticleHistogram2D: Needs openPMD-api compiled into WarpX, but was not found!");
Expand Down

0 comments on commit d7b1aba

Please sign in to comment.