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

Remove m_cell_centered_data from multifab map #5322

Merged
merged 4 commits into from
Sep 26, 2024

Conversation

dpgrote
Copy link
Member

@dpgrote dpgrote commented Sep 24, 2024

The back transformed data diagnostics generates a MultiFab, m_cell_centered_data, to hold cell centered data when the output data is being generated. This was being added to the old version of the MultiFab map. Since the data is temporary and since there could be multiple copies of the MultiFab (if there are multiple BTD diagnostics), it doesn't make sense to have the MultiFab in the registry. This PR changes the code so that the MultiFab is directly allocated.

With this PR, the last MultiFab is removed from the old MultiFab map, so it can be removed in a subsequent PR.

Follow-up to #5230

@dpgrote dpgrote added the component: diagnostics all types of outputs label Sep 24, 2024
@@ -519,7 +519,8 @@ BTDiagnostics::DefineCellCenteredMultiFab(int lev)
#else
const int ncomps = static_cast<int>(m_cellcenter_varnames.size());
#endif
WarpX::AllocInitMultiFab(m_cell_centered_data[lev], ba, dmap, ncomps, amrex::IntVect(ngrow), lev, "cellcentered_BTD", 0._rt);
m_cell_centered_data[lev] = std::make_unique<amrex::MultiFab>(ba, dmap, ncomps, amrex::IntVect(ngrow));
Copy link
Member

@ax3l ax3l Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use MultiFabRegister::alloc_init and ::erase?

Copy link
Member

@ax3l ax3l Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far, we deallocated m_cell_centered_data[lev] when the BTDiagnostics is deallocated. We do not want to change that behavior here in terms of how long the lifetime goes.

Deallocation of each BTDiagnostics variable currently probably (to verify with @RevathiJambunathan) happens only at the end of the simulation. If that is true, we do not need even need to call ::erase when a station is done. If there is an earlier deallocation of BTDiagnostics (proably should be) or more logic in ~BTDiagnostics or when a station is fully done, then we should call ::erase at those points.

For the name we put in the MultiFabRegister, we should create a unique name by combining:

  • a clear BTD prefix and
  • the current BTD diagnostics name (from the inputs) and
  • the station it works on (usually called i_buffer, if I am not mistaken).

This will be nice, because we can now more easily track the overhead of BTD diags.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lifetime of the diagnostics is the same as the lifetime of the WarpX class so the erase is not needed.

Source/Diagnostics/BTDiagnostics.H Outdated Show resolved Hide resolved
Source/Diagnostics/BTDiagnostics.cpp Outdated Show resolved Hide resolved
Source/Diagnostics/BTDiagnostics.cpp Outdated Show resolved Hide resolved
Source/Diagnostics/BTDiagnostics.cpp Outdated Show resolved Hide resolved
Source/Diagnostics/BTDiagnostics.cpp Outdated Show resolved Hide resolved
Source/Diagnostics/BTDiagnostics.cpp Outdated Show resolved Hide resolved
Source/Diagnostics/BTDiagnostics.cpp Outdated Show resolved Hide resolved
Source/Diagnostics/BTDiagnostics.cpp Outdated Show resolved Hide resolved
Source/Diagnostics/BTDiagnostics.cpp Outdated Show resolved Hide resolved
Source/Diagnostics/BTDiagnostics.cpp Outdated Show resolved Hide resolved
Prepares to remove `WarpX` class altogether from here.
@ax3l ax3l added the component: boosted frame boosted frame components & logic label Sep 26, 2024
Copy link
Member

@ax3l ax3l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! :)

@ax3l ax3l enabled auto-merge (squash) September 26, 2024 07:39
@ax3l ax3l merged commit 284287d into ECP-WarpX:development Sep 26, 2024
36 of 37 checks passed
@dpgrote dpgrote deleted the register_m_cell_centered_data branch September 26, 2024 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: boosted frame boosted frame components & logic component: diagnostics all types of outputs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants