WarpX
Loading...
Searching...
No Matches
WarpXOpenPMDPlot Class Reference

#include <WarpXOpenPMD.H>

Public Types

using ParticleContainer = typename WarpXParticleContainer::ContainerLike<amrex::PinnedArenaAllocator>
 
using ParticleIter = typename amrex::ParConstIterSoA<PIdx::nattribs, 0, amrex::PinnedArenaAllocator>
 

Public Member Functions

 WarpXOpenPMDPlot (openPMD::IterationEncoding ie, const std::string &filetype, const std::string &operator_type, const std::map< std::string, std::string > &operator_parameters, const std::string &engine_type, const std::map< std::string, std::string > &engine_parameters, const std::vector< bool > &fieldPMLdirections, const std::string &authors)
 
 ~WarpXOpenPMDPlot ()
 
 WarpXOpenPMDPlot (WarpXOpenPMDPlot const &)=delete
 
WarpXOpenPMDPlotoperator= (WarpXOpenPMDPlot const &)=delete
 
 WarpXOpenPMDPlot (WarpXOpenPMDPlot &&)=default
 
WarpXOpenPMDPlotoperator= (WarpXOpenPMDPlot &&)=default
 
void SetStep (int ts, const std::string &dirPrefix, int file_min_digits, bool isBTD=false)
 
void CloseStep (bool isBTD=false, bool isLastBTDFlush=false)
 
void WriteOpenPMDParticles (const amrex::Vector< ParticleDiag > &particle_diags, amrex::Real time, bool use_pinned_pc=false, bool isBTD=false, bool isLastBTDFlush=false)
 
void WriteOpenPMDFieldsAll (const std::vector< std::string > &varnames, const amrex::Vector< amrex::MultiFab > &mf, amrex::Vector< amrex::Geometry > &geom, int output_levels, int iteration, double time, bool isBTD=false, const amrex::Geometry &full_BTD_snapshot=amrex::Geometry()) const
 
std::string OpenPMDFileType ()
 
void FlushBTDToDisk ()
 

Private Member Functions

void Init (openPMD::Access access, bool isBTD)
 
openPMD::Iteration GetIteration (int const iteration, bool const isBTD) const
 
void seriesFlush (bool isBTD) const
 
void SetupFields (openPMD::Container< openPMD::Mesh > &meshes, amrex::Geometry &full_geom) const
 
void SetupMeshComp (openPMD::Mesh &mesh, amrex::Geometry const &full_geom, std::string const &comp_name, std::string const &field_name, amrex::MultiFab const &mf, bool var_in_theta_mode) const
 
void GetMeshCompNames (int meshLevel, const std::string &varname, std::string &field_name, std::string &comp_name, bool var_in_theta_mode) const
 
void SetupPos (openPMD::ParticleSpecies &currSpecies, std::vector< std::string > const &positionComponents, const unsigned long long &np, bool isBTD=false)
 
void SetConstParticleRecordsEDPIC (openPMD::ParticleSpecies &currSpecies, std::vector< std::string > const &positionComponents, const unsigned long long &np, amrex::ParticleReal charge, amrex::ParticleReal mass)
 
void SetupRealProperties (ParticleContainer const *pc, openPMD::ParticleSpecies &currSpecies, const amrex::Vector< int > &write_real_comp, const amrex::Vector< std::string > &real_comp_names, const amrex::Vector< int > &write_int_comp, const amrex::Vector< std::string > &int_comp_names, unsigned long long np, bool isBTD=false) const
 
void SaveRealProperty (ParticleIter &pti, openPMD::ParticleSpecies &currSpecies, unsigned long long offset, const amrex::Vector< int > &write_real_comp, const amrex::Vector< std::string > &real_comp_names, const amrex::Vector< int > &write_int_comp, const amrex::Vector< std::string > &int_comp_names) const
 
void DumpToFile (ParticleContainer *pc, const std::string &name, int iteration, const amrex::Vector< int > &write_real_comp, const amrex::Vector< int > &write_int_comp, const amrex::Vector< std::string > &real_comp_names, const amrex::Vector< std::string > &int_comp_names, amrex::ParticleReal charge, amrex::ParticleReal mass, bool isBTD=false, bool isLastBTDFlush=false)
 
std::string GetFileName (std::string &filepath)
 

Private Attributes

std::unique_ptr< openPMD::Seriesm_Series
 
std::string m_dirPrefix
 
int m_file_min_digits
 
int m_MPIRank = 0
 
int m_MPISize = 1
 
openPMD::IterationEncoding m_Encoding = openPMD::IterationEncoding::fileBased
 
std::string m_OpenPMDFileType = "bp5"
 
std::string m_OpenPMDoptions = "{}"
 MPI-parallel openPMD backend: bp5, bp4 or h5.
 
int m_CurrentStep = -1
 JSON option string for openPMD::Series constructor.
 
std::vector< bool > m_fieldPMLdirections
 
std::string m_authors
 

Detailed Description

Writer logic for openPMD particles and fields

Member Typedef Documentation

◆ ParticleContainer

◆ ParticleIter

Constructor & Destructor Documentation

◆ WarpXOpenPMDPlot() [1/3]

WarpXOpenPMDPlot::WarpXOpenPMDPlot ( openPMD::IterationEncoding ie,
const std::string & filetype,
const std::string & operator_type,
const std::map< std::string, std::string > & operator_parameters,
const std::string & engine_type,
const std::map< std::string, std::string > & engine_parameters,
const std::vector< bool > & fieldPMLdirections,
const std::string & authors )

Initialize openPMD I/O routines

Parameters
ieiteration encoding from openPMD: "group, file, variable"
filetypefile backend, e.g. "bp5", "bp4", or "h5"
operator_typeopenPMD-api backend operator (compressor) for ADIOS2
operator_parametersopenPMD-api backend operator parameters for ADIOS2
engine_typeADIOS engine for output
engine_parametersmap of parameters for the engine
fieldPMLdirectionsPML field solver,
See also
WarpX::getPMLdirections()
Parameters
authorsa string specifying the authors of the simulation (can be empty)

◆ ~WarpXOpenPMDPlot()

WarpXOpenPMDPlot::~WarpXOpenPMDPlot ( )

◆ WarpXOpenPMDPlot() [2/3]

WarpXOpenPMDPlot::WarpXOpenPMDPlot ( WarpXOpenPMDPlot const & )
delete

◆ WarpXOpenPMDPlot() [3/3]

WarpXOpenPMDPlot::WarpXOpenPMDPlot ( WarpXOpenPMDPlot && )
default

Member Function Documentation

◆ CloseStep()

void WarpXOpenPMDPlot::CloseStep ( bool isBTD = false,
bool isLastBTDFlush = false )

Close the step

Signal that no further updates will be written for the step.

◆ DumpToFile()

void WarpXOpenPMDPlot::DumpToFile ( ParticleContainer * pc,
const std::string & name,
int iteration,
const amrex::Vector< int > & write_real_comp,
const amrex::Vector< int > & write_int_comp,
const amrex::Vector< std::string > & real_comp_names,
const amrex::Vector< std::string > & int_comp_names,
amrex::ParticleReal charge,
amrex::ParticleReal mass,
bool isBTD = false,
bool isLastBTDFlush = false )
private

This function saves the plot file

Parameters
[in]pcWarpX particle container
[in]namespecies name
[in]iterationtimestep
[in]write_real_compThe real attribute ids, from WarpX
[in]write_int_compThe int attribute ids, from WarpX
[in]real_comp_namesThe real attribute names, from WarpX
[in]int_comp_namesThe int attribute names, from WarpX
[in]chargeCharge of the particles (note: fix for ions)
[in]massMass of the particles
[in]isBTDis this a backtransformed diagnostics (BTD) write?
[in]isLastBTDFlushis this the last time we will flush this BTD station?

◆ FlushBTDToDisk()

void WarpXOpenPMDPlot::FlushBTDToDisk ( )

Ensure BTD buffers are written to disk

This function can be called to intermediately ensure ADIOS buffered "steps" are written to disk, and the valid metadata if checkpointing is required.

This is needed to read partial data while a simulation is running or to support restarting (the BTD diagnostics) in WarpX, so it can continue to append to a partially written labframe station after restart.

The frequency is controlled by FlushFormatOpenPMD::m_NumAggBTDBufferToFlush (default to 5). It can be adjusted in the input file: diag_name.buffer_flush_limit_btd

◆ GetFileName()

std::string WarpXOpenPMDPlot::GetFileName ( std::string & filepath)
private

Get the openPMD-api filename for openPMD::Series

No need for ts in the file name, openPMD handles steps (iterations).

Parameters
[in,out]filepaththe path and filename for openPMD::Series passes a prefix path in and appends the filename
Returns
pure filename w/o path

◆ GetIteration()

openPMD::Iteration WarpXOpenPMDPlot::GetIteration ( int const iteration,
bool const isBTD ) const
inlinenodiscardprivate

Get the openPMD::Iteration object of the current Series

We use this helper function to differentiate between efficient, temporally sequentially increasing writes to iteration numbers and random-access writes to iterations, e.g., as needed for back-transformed diagnostics.

Parameters
[in]iterationiteration number (lab-frame for BTD)
[in]isBTDis this a backtransformed diagnostics write?
Returns
the iteration object

◆ GetMeshCompNames()

void WarpXOpenPMDPlot::GetMeshCompNames ( int meshLevel,
const std::string & varname,
std::string & field_name,
std::string & comp_name,
bool var_in_theta_mode ) const
private

Get Component Names from WarpX name

Get component names of a field for openPMD-api book-keeping Level is reflected as _lvl<meshLevel>

Parameters
[in]meshLevellevel of mesh
[in]varnamename from WarpX
[out]field_namefield name for openPMD-api output
[in]comp_namecomp name for openPMD-api output
[in]var_in_theta_modeindicate if this field will be output with theta modes (instead of a reconstructed 2D slice)

◆ Init()

void WarpXOpenPMDPlot::Init ( openPMD::Access access,
bool isBTD )
private

◆ OpenPMDFileType()

std::string WarpXOpenPMDPlot::OpenPMDFileType ( )
inline

Return OpenPMD File type ("bp5", "bp4", "h5" or "json")

◆ operator=() [1/2]

WarpXOpenPMDPlot & WarpXOpenPMDPlot::operator= ( WarpXOpenPMDPlot && )
default

◆ operator=() [2/2]

WarpXOpenPMDPlot & WarpXOpenPMDPlot::operator= ( WarpXOpenPMDPlot const & )
delete

◆ SaveRealProperty()

void WarpXOpenPMDPlot::SaveRealProperty ( ParticleIter & pti,
openPMD::ParticleSpecies & currSpecies,
unsigned long long offset,
const amrex::Vector< int > & write_real_comp,
const amrex::Vector< std::string > & real_comp_names,
const amrex::Vector< int > & write_int_comp,
const amrex::Vector< std::string > & int_comp_names ) const
private

This function saves the values of the entries for particle properties

Parameters
[in]ptiWarpX particle iterator
[in]currSpeciesThe openPMD species to save to
[in]offsetoffset to start saving the particle iterator contents
[in]write_real_compThe real attribute ids, from WarpX
[in]real_comp_namesThe real attribute names, from WarpX
[in]write_int_compThe int attribute ids, from WarpX
[in]int_comp_namesThe int attribute names, from WarpX

◆ seriesFlush()

void WarpXOpenPMDPlot::seriesFlush ( bool isBTD) const
private

Flushing out data of the current openPMD iteration

Parameters
[in]isBTDif the current diagnostic is BTD

if isBTD=false, apply the default flush behaviour in ADIOS, the action will be PerformDataWrite if isBTD=true, in ADIOS, the action will be PerformPut because no action is taken for the span tasks. This way we can aggregate buffers before calling FlushBTDToDisk() to write out.

iteration.seriesFlush() is used instead of series.flush() because the latter flushes only if data is dirty this causes trouble when the underlying writing function is collective (like PDW)

◆ SetConstParticleRecordsEDPIC()

void WarpXOpenPMDPlot::SetConstParticleRecordsEDPIC ( openPMD::ParticleSpecies & currSpecies,
std::vector< std::string > const & positionComponents,
const unsigned long long & np,
amrex::ParticleReal charge,
amrex::ParticleReal mass )
private

This function sets constant particle records and ED-PIC attributes.

Sets the entries for storing particle position offset, constant records (charge, mass) and ED-PIC attributes.

Parameters
[in]currSpeciesCorresponding openPMD species
[in]positionComponentsuser-selected components of the particle position
[in]npNumber of particles
[in]chargeCharge of the particles (note: fix for ions)
[in]massMass of the particles

◆ SetStep()

void WarpXOpenPMDPlot::SetStep ( int ts,
const std::string & dirPrefix,
int file_min_digits,
bool isBTD = false )

Set Iteration Step for the series

Note
If an iteration has been written, then it will give a warning

◆ SetupFields()

void WarpXOpenPMDPlot::SetupFields ( openPMD::Container< openPMD::Mesh > & meshes,
amrex::Geometry & full_geom ) const
private

This function does initial setup for the fields when interation is newly created

Parameters
[in]meshesThe meshes in a series
[in]full_geomThe geometry

◆ SetupMeshComp()

void WarpXOpenPMDPlot::SetupMeshComp ( openPMD::Mesh & mesh,
amrex::Geometry const & full_geom,
std::string const & comp_name,
std::string const & field_name,
amrex::MultiFab const & mf,
bool var_in_theta_mode ) const
private

◆ SetupPos()

void WarpXOpenPMDPlot::SetupPos ( openPMD::ParticleSpecies & currSpecies,
std::vector< std::string > const & positionComponents,
const unsigned long long & np,
bool isBTD = false )
private

This function sets up the entries for storing the particle positions and global IDs

Parameters
[in]currSpeciesCorresponding openPMD species
[in]positionComponentsuser-selected components of the particle position
[in]npNumber of particles
[in]isBTDIs this a back-transformed diagnostics output?

◆ SetupRealProperties()

void WarpXOpenPMDPlot::SetupRealProperties ( ParticleContainer const * pc,
openPMD::ParticleSpecies & currSpecies,
const amrex::Vector< int > & write_real_comp,
const amrex::Vector< std::string > & real_comp_names,
const amrex::Vector< int > & write_int_comp,
const amrex::Vector< std::string > & int_comp_names,
unsigned long long np,
bool isBTD = false ) const
private

This function sets up the entries for particle properties

Parameters
[in]pcThe particle container of the species
[in]currSpeciesThe openPMD species
[in]write_real_compThe real attribute ids, from WarpX
[in]real_comp_namesThe real attribute names, from WarpX
[in]write_int_compThe int attribute ids, from WarpX
[in]int_comp_namesThe int attribute names, from WarpX
[in]npNumber of particles
[in]isBTDwhether this is a back-transformed diagnostic

◆ WriteOpenPMDFieldsAll()

void WarpXOpenPMDPlot::WriteOpenPMDFieldsAll ( const std::vector< std::string > & varnames,
const amrex::Vector< amrex::MultiFab > & mf,
amrex::Vector< amrex::Geometry > & geom,
int output_levels,
int iteration,
double time,
bool isBTD = false,
const amrex::Geometry & full_BTD_snapshot = amrex::Geometry() ) const

Write out all openPMD fields for all active MR levels

Parameters
varnamesvariable names in each multifab
mfmultifab for each level
geomfor each level
output_levelsthe finest level to output, <= maxLevel
iterationthe current iteration or reconstructed labframe station number
timethe current simulation time in the lab frame
isBTDtrue if this is part of a back-transformed diagnostics (BTD) station flush; in BTD, we write multiple times to the same iteration
full_BTD_snapshotthe geometry of the full lab frame for BTD

Write Field with all mesh levels

◆ WriteOpenPMDParticles()

void WarpXOpenPMDPlot::WriteOpenPMDParticles ( const amrex::Vector< ParticleDiag > & particle_diags,
amrex::Real time,
bool use_pinned_pc = false,
bool isBTD = false,
bool isLastBTDFlush = false )

Member Data Documentation

◆ m_authors

std::string WarpXOpenPMDPlot::m_authors
private

◆ m_CurrentStep

int WarpXOpenPMDPlot::m_CurrentStep = -1
private

JSON option string for openPMD::Series constructor.

◆ m_dirPrefix

std::string WarpXOpenPMDPlot::m_dirPrefix
private

This is the output directory

This usually does not yet end in a /. It does not yet include the file prefix of the openPMD series, which will be appended by the GetFileName function.

◆ m_Encoding

openPMD::IterationEncoding WarpXOpenPMDPlot::m_Encoding = openPMD::IterationEncoding::fileBased
private

◆ m_fieldPMLdirections

std::vector< bool > WarpXOpenPMDPlot::m_fieldPMLdirections
private

◆ m_file_min_digits

int WarpXOpenPMDPlot::m_file_min_digits
private

This is the minimum number of digits in the step number that is used as the suffix for file names when doing file based encoding

◆ m_MPIRank

int WarpXOpenPMDPlot::m_MPIRank = 0
private

◆ m_MPISize

int WarpXOpenPMDPlot::m_MPISize = 1
private

◆ m_OpenPMDFileType

std::string WarpXOpenPMDPlot::m_OpenPMDFileType = "bp5"
private

◆ m_OpenPMDoptions

std::string WarpXOpenPMDPlot::m_OpenPMDoptions = "{}"
private

MPI-parallel openPMD backend: bp5, bp4 or h5.

◆ m_Series

std::unique_ptr<openPMD::Series> WarpXOpenPMDPlot::m_Series
private

The documentation for this class was generated from the following files: