WarpX
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 ()
 

Private Member Functions

void Init (openPMD::Access access, bool isBTD)
 
openPMD::Iteration GetIteration (int const iteration, bool const 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, const unsigned long long &np, bool isBTD=false)
 
void SetConstParticleRecordsEDPIC (openPMD::ParticleSpecies &currSpecies, 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 = "bp"
 
std::string m_OpenPMDoptions = "{}"
 MPI-parallel openPMD backend: bp or h5. More...
 
int m_CurrentStep = -1
 JSON option string for openPMD::Series constructor. More...
 
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. "bp" 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]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]chargeCharge of the particles (note: fix for ions)
[in]massMass of the particles
[in,out]ParticleFlushOffsetpreviously flushed number of particles in BTD
[in]isBTDis this a backtransformed diagnostics (BTD) write?
[in]isLastBTDFlushis this the last time we will flush this BTD station?

◆ 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
inlineprivate

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 ("bp" or "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

◆ SetConstParticleRecordsEDPIC()

void WarpXOpenPMDPlot::SetConstParticleRecordsEDPIC ( openPMD::ParticleSpecies currSpecies,
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]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,
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]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 = "bp"
private

◆ m_OpenPMDoptions

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

MPI-parallel openPMD backend: bp or h5.

◆ m_Series

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

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