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 amrex::AmrParticleContainer< 0, 0, PIdx::nattribs, 0, amrex::PinnedArenaAllocator >
 
using ParticleIter = typename amrex::ParConstIter< 0, 0, PIdx::nattribs, 0, amrex::PinnedArenaAllocator >
 

Public Member Functions

 WarpXOpenPMDPlot (openPMD::IterationEncoding ie, std::string filetype, std::string operator_type, std::map< std::string, std::string > operator_parameters, std::vector< bool > fieldPMLdirections)
 
 ~WarpXOpenPMDPlot ()
 
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, const bool isBTD=false)
 
void WriteOpenPMDFieldsAll (const std::vector< std::string > &varnames, const amrex::Vector< amrex::MultiFab > &mf, amrex::Vector< amrex::Geometry > &geom, const int iteration, const double time, bool isBTD=false, const amrex::Geometry &full_BTD_snapshot=amrex::Geometry()) const
 

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 &full_geom, openPMD::MeshRecordComponent &mesh_comp) const
 
void GetMeshCompNames (int meshLevel, const std::string &varname, std::string &field_name, std::string &comp_name) const
 
void SetupPos (openPMD::ParticleSpecies &currSpecies, const unsigned long long &np, amrex::ParticleReal const charge, amrex::ParticleReal const mass) const
 
void SetupRealProperties (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) 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 const charge, amrex::ParticleReal const mass, const bool isBTD) const
 
std::string GetFileName (std::string &filepath)
 

Private Attributes

std::unique_ptr< openPMD::Series > m_Series
 
std::string m_dirPrefix
 
int m_file_min_digits
 
int m_MPIRank = 0
 
int m_MPISize = 1
 
int m_NumSoARealAttributes = PIdx::nattribs
 
int m_NumAoSRealAttributes = 0
 WarpX' additional real particle attributes in SoA. More...
 
int m_NumAoSIntAttributes = 0
 WarpX definition: no additional real attributes in particle AoS. More...
 
openPMD::IterationEncoding m_Encoding = openPMD::IterationEncoding::fileBased
 WarpX definition: no additional int attributes in particle AoS. More...
 
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
 

Detailed Description

Writer logic for openPMD particles and fields

Member Typedef Documentation

◆ ParticleContainer

using WarpXOpenPMDPlot::ParticleContainer = typename amrex::AmrParticleContainer<0, 0, PIdx::nattribs, 0, amrex::PinnedArenaAllocator>

◆ ParticleIter

using WarpXOpenPMDPlot::ParticleIter = typename amrex::ParConstIter<0, 0, PIdx::nattribs, 0, amrex::PinnedArenaAllocator>

Constructor & Destructor Documentation

◆ WarpXOpenPMDPlot()

WarpXOpenPMDPlot::WarpXOpenPMDPlot ( openPMD::IterationEncoding  ie,
std::string  filetype,
std::string  operator_type,
std::map< std::string, std::string >  operator_parameters,
std::vector< bool >  fieldPMLdirections 
)

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
fieldPMLdirectionsPML field solver,
See also
WarpX::getPMLdirections()

◆ ~WarpXOpenPMDPlot()

WarpXOpenPMDPlot::~WarpXOpenPMDPlot ( )

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 const  charge,
amrex::ParticleReal const  mass,
const bool  isBTD 
) const
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]isBTDis this a backtransformed diagnostics write?

◆ 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 
) const
private

◆ Init()

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

◆ 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

◆ 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 &  full_geom,
openPMD::MeshRecordComponent &  mesh_comp 
) const
private

◆ SetupPos()

void WarpXOpenPMDPlot::SetupPos ( openPMD::ParticleSpecies &  currSpecies,
const unsigned long long &  np,
amrex::ParticleReal const  charge,
amrex::ParticleReal const  mass 
) const
private

This function sets up the entries for storing the particle positions, global IDs, and constant records (charge, mass)

Parameters
[in]currSpeciesCorresponding openPMD species
[in]npNumber of particles
[in]chargeCharge of the particles (note: fix for ions)
[in]massMass of the particles

◆ SetupRealProperties()

void WarpXOpenPMDPlot::SetupRealProperties ( 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 
) const
private

This function sets up the entries for particle properties

Parameters
[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

◆ WriteOpenPMDFieldsAll()

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

◆ WriteOpenPMDParticles()

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

Member Data Documentation

◆ 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

WarpX definition: no additional int attributes in particle AoS.

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

int WarpXOpenPMDPlot::m_NumAoSIntAttributes = 0
private

WarpX definition: no additional real attributes in particle AoS.

◆ m_NumAoSRealAttributes

int WarpXOpenPMDPlot::m_NumAoSRealAttributes = 0
private

WarpX' additional real particle attributes in SoA.

◆ m_NumSoARealAttributes

int WarpXOpenPMDPlot::m_NumSoARealAttributes = PIdx::nattribs
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: