Skip to content

Commit

Permalink
Added function SetWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
guj committed Jan 25, 2024
1 parent f6a8e7d commit 991055b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
14 changes: 14 additions & 0 deletions Src/Extern/openPMD-api/AMReX_PlotFileOPENPMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,20 @@ namespace amrex::openpmd_api {
} // CreateWriter()


void AMReX_openPMDHandler::SetWriter(amrex::openpmd_api::AMReX_openPMDWriter* w)
{
BL_ASSERT ( w != nullptr );

// assuer that input key/values are inherited
// so the openpmd filepath assigned from input file is still in use
w->m_openPMDPrefix = m_Writer->m_openPMDPrefix;
w->m_openPMDEncoding = m_Writer->m_openPMDEncoding;
w->m_openPMDFileType = m_Writer->m_openPMDFileType;
w->m_openPMDSeriesOptions = m_Writer->m_openPMDSeriesOptions;

m_Writer.reset(w);
}

////////////////////////////////////////
//
// Class AMReX_openPMDWriter
Expand Down
1 change: 1 addition & 0 deletions Src/Extern/openPMD-api/AMReX_PlotFileUtilOPENPMD.H
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ namespace amrex::openpmd_api

std::unique_ptr<AMReX_openPMDWriter> m_Writer;

void SetWriter(amrex::openpmd_api::AMReX_openPMDWriter* w);
private:
void CreateWriter(const std::string& prefix = std::string());

Expand Down
4 changes: 1 addition & 3 deletions Src/Extern/openPMD-api/AMReX_PlotFileUtilOPENPMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ namespace amrex::openpmd_api
BL_ASSERT ( m_OpenPMDHandler != nullptr );
BL_ASSERT ( w != nullptr );

// so the openpmd filepath assigned from input file is still in use
w->m_openPMDPrefix = m_OpenPMDHandler->m_Writer->m_openPMDPrefix;
m_OpenPMDHandler->m_Writer.reset(w);
m_OpenPMDHandler->SetWriter(w);
}

void CloseHandler()
Expand Down

0 comments on commit 991055b

Please sign in to comment.