OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
DataSink Class Reference

#include <DataSink.h>

Collaboration diagram for DataSink:
Collaboration graph

Public Member Functions

 DataSink ()
 Default constructor.
 
 DataSink (const std::vector< H5PartWrapper * > &h5wrappers, bool restart, size_t numParticleContainers)
 
 DataSink (H5PartWrapper *h5wrapper, bool restart)
 
 DataSink (H5PartWrapper *h5wrapper)
 
void dumpH5 (PartBunch_t &beam, Vector_t< double, 3 > FDext[]) const
 Write H5 phase-space data for all particle containers.
 
void dumpH5 (PartBunch_t &beam, const std::vector< std::array< Vector_t< double, 3 >, 2 > > &fdextPerContainer) const
 Write H5 phase-space data with per-container external fields.
 
int dumpH5 (PartBunch_t &beam, Vector_t< double, 3 > FDext[], double meanEnergy, double refPr, double refPt, double refPz, double refR, double refTheta, double refZ, double azimuth, double elevation, bool local) const
 Write single-container H5 phase-space data with reference quantities.
 
void dumpSDDS (PartBunch_t &beam, const std::vector< std::array< Vector_t< double, 3 >, 2 > > &fdextPerContainer, const double &azimuth) const
 Write SDDS statistics with per-container external fields.
 
void dumpSDDS (PartBunch_t &beam, const std::vector< std::array< Vector_t< double, 3 >, 2 > > &fdextPerContainer, const losses_t &losses, const double &azimuth) const
 Write SDDS statistics and losses with per-container external fields.
 
void storeCavityInformation ()
 Write cavity information from H5 file.
 
void changeH5Wrappers (const std::vector< H5PartWrapper * > &h5wrappers)
 
void writeGeomToVtk (BoundaryGeometry &bg, std::string fn)
 
void writeImpactStatistics (const PartBunch_t &beam, long long int &step, size_t &impact, double &sey_num, size_t numberOfFieldEmittedParticles, bool nEmissionMode, std::string fn)
 
void dumpBinConfig (long long step, double time, bool preMerge, const std::vector< std::size_t > &binCounts, const std::vector< double > &binWidths, double xMin, const std::string &fileName)
 Append a binning configuration snapshot to a JSON file.
 
template<typename FieldType >
DirichletPlaneWriter::PlaneDiagnostics dumpDirichletPlane (long long step, double time, double zPlane, const FieldType &field, const std::string &solveTag)
 Interpolate and dump potential values on a 2D z-plane.
 

Static Public Member Functions

static std::string diagnosticStemForContainer (const std::string &inputBasename, size_t numContainers, size_t index)
 

Private Types

typedef StatWriter::losses_t losses_t
 
typedef std::unique_ptr< StatWriterstatWriter_t
 
typedef std::unique_ptr< SDDSWritersddsWriter_t
 
typedef std::unique_ptr< H5Writerh5Writer_t
 

Private Member Functions

 DataSink (const DataSink &ds)=delete
 
DataSinkoperator= (const DataSink &)=delete
 
void rewindLines ()
 
void init (bool restart, const std::vector< H5PartWrapper * > &h5wrappers, size_t numParticleContainers)
 

Static Private Member Functions

static std::string convertToString (int number, int setw=5)
 

Private Attributes

std::vector< h5Writer_th5Writers_m
 
std::vector< statWriter_tstatWriters_m
 
std::vector< sddsWriter_tsddsWriter_m
 
std::unique_ptr< BinConfigWriterbinConfigWriter_m
 
std::unique_ptr< DirichletPlaneWriterdirichletPlaneWriter_m
 
unsigned int lossWrCounter_m
 needed to create index for vtk file
 
IpplTimings::TimerRef StatMarkerTimer_m
 Timer to track statistics write time.
 

Detailed Description

Definition at line 48 of file DataSink.h.

Member Typedef Documentation

◆ h5Writer_t

typedef std::unique_ptr<H5Writer> DataSink::h5Writer_t
private

Definition at line 53 of file DataSink.h.

◆ losses_t

Definition at line 50 of file DataSink.h.

◆ sddsWriter_t

typedef std::unique_ptr<SDDSWriter> DataSink::sddsWriter_t
private

Definition at line 52 of file DataSink.h.

◆ statWriter_t

typedef std::unique_ptr<StatWriter> DataSink::statWriter_t
private

Definition at line 51 of file DataSink.h.

Constructor & Destructor Documentation

◆ DataSink() [1/5]

DataSink::DataSink ( )

Default constructor.

The default constructor is called at the start of a new calculation (as opposed to a calculation restart).

Definition at line 51 of file DataSink.cpp.

References init().

Here is the call graph for this function:

◆ DataSink() [2/5]

DataSink::DataSink ( const std::vector< H5PartWrapper * > &  h5wrappers,
bool  restart,
size_t  numParticleContainers 
)

One H5 wrapper per particle container (when HDF5 enabled); sizes must match numParticleContainers.

Definition at line 53 of file DataSink.cpp.

References Options::enableHDF5, init(), and rewindLines().

Here is the call graph for this function:

◆ DataSink() [3/5]

DataSink::DataSink ( H5PartWrapper h5wrapper,
bool  restart 
)

Definition at line 66 of file DataSink.cpp.

◆ DataSink() [4/5]

DataSink::DataSink ( H5PartWrapper h5wrapper)

Definition at line 69 of file DataSink.cpp.

◆ DataSink() [5/5]

DataSink::DataSink ( const DataSink ds)
privatedelete

Member Function Documentation

◆ changeH5Wrappers()

void DataSink::changeH5Wrappers ( const std::vector< H5PartWrapper * > &  h5wrappers)

Definition at line 180 of file DataSink.cpp.

References Options::enableHDF5, and h5Writers_m.

Referenced by TrackRun::initDataSink().

◆ convertToString()

std::string DataSink::convertToString ( int  number,
int  setw = 5 
)
inlinestaticprivate

Definition at line 207 of file DataSink.h.

◆ diagnosticStemForContainer()

std::string DataSink::diagnosticStemForContainer ( const std::string &  inputBasename,
size_t  numContainers,
size_t  index 
)
static

Basename stem for per-container diagnostics: basename if numContainers<=1 else basename_cN.

Definition at line 43 of file DataSink.cpp.

Referenced by init(), and TrackRun::initDataSink().

◆ dumpBinConfig()

void DataSink::dumpBinConfig ( long long  step,
double  time,
bool  preMerge,
const std::vector< std::size_t > &  binCounts,
const std::vector< double > &  binWidths,
double  xMin,
const std::string &  fileName 
)

Append a binning configuration snapshot to a JSON file.

Parameters
stepGlobal tracking step index.
timeAbsolute simulation time (in seconds).
preMergetrue for pre-merge histogram, false for post-merge.
binCountsPer-bin particle counts.
binWidthsPer-bin bin widths (same length as binCounts).
xMinLower bound of the histogram coordinate.
fileNameTarget JSON file name (typically from BinningCmd::getDumpBinsFileName()).

Definition at line 246 of file DataSink.cpp.

References binConfigWriter_m.

◆ dumpDirichletPlane()

template<typename FieldType >
DirichletPlaneWriter::PlaneDiagnostics DataSink::dumpDirichletPlane ( long long  step,
double  time,
double  zPlane,
const FieldType &  field,
const std::string &  solveTag 
)

Interpolate and dump potential values on a 2D z-plane.

The interpolation and plane extraction are performed on device by DirichletPlaneWriter; only the 2D plane is copied to host for output.

Template Parameters
FieldTypeIPPL scalar field type.
Parameters
stepGlobal tracking step index.
timeAbsolute simulation time (seconds).
zPlanePhysical z location of the sampled plane (meters).
fieldScalar field to sample (rho/phi depending on solver).
solveTagLabel for the solver pass (e.g. legacy, binned).
Returns
Plane diagnostics (mean/variance/sample count).

Definition at line 214 of file DataSink.h.

References dirichletPlaneWriter_m.

◆ dumpH5() [1/3]

void DataSink::dumpH5 ( PartBunch_t beam,
const std::vector< std::array< Vector_t< double, 3 >, 2 > > &  fdextPerContainer 
) const

Write H5 phase-space data with per-container external fields.

Parameters
beamBorrowed particle bunch; DataSink does not own or retain it.
fdextPerContainerExternal field values indexed by particle container.

Definition at line 81 of file DataSink.cpp.

References Options::enableHDF5, and h5Writers_m.

◆ dumpH5() [2/3]

void DataSink::dumpH5 ( PartBunch_t beam,
Vector_t< double, 3 >  FDext[] 
) const

Write H5 phase-space data for all particle containers.

Parameters
beamBorrowed particle bunch; DataSink does not own or retain it.
FDextExternal magnetic/electric field values reused for each container.

Definition at line 71 of file DataSink.cpp.

References dumpH5().

Referenced by dumpH5(), and ParallelTracker::writePhaseSpace().

Here is the call graph for this function:

◆ dumpH5() [3/3]

int DataSink::dumpH5 ( PartBunch_t beam,
Vector_t< double, 3 >  FDext[],
double  meanEnergy,
double  refPr,
double  refPt,
double  refPz,
double  refR,
double  refTheta,
double  refZ,
double  azimuth,
double  elevation,
bool  local 
) const

Write single-container H5 phase-space data with reference quantities.

Parameters
beamBorrowed particle bunch; DataSink does not own or retain it.

Definition at line 109 of file DataSink.cpp.

References Options::enableHDF5, and h5Writers_m.

◆ dumpSDDS() [1/2]

void DataSink::dumpSDDS ( PartBunch_t beam,
const std::vector< std::array< Vector_t< double, 3 >, 2 > > &  fdextPerContainer,
const double &  azimuth 
) const

Write SDDS statistics with per-container external fields.

Parameters
beamBorrowed particle bunch; DataSink does not own or retain it.

Definition at line 122 of file DataSink.cpp.

References dumpSDDS().

Referenced by dumpSDDS(), and ParallelTracker::writePhaseSpace().

Here is the call graph for this function:

◆ dumpSDDS() [2/2]

void DataSink::dumpSDDS ( PartBunch_t beam,
const std::vector< std::array< Vector_t< double, 3 >, 2 > > &  fdextPerContainer,
const losses_t losses,
const double &  azimuth 
) const

Write SDDS statistics and losses with per-container external fields.

Parameters
beamBorrowed particle bunch; DataSink does not own or retain it.

Definition at line 128 of file DataSink.cpp.

References Options::beamHaloBoundary, PartBunch< T, Dim >::calcBeamParameters(), PartBunch< T, Dim >::calcNumPartsOutside(), PartBunch< T, Dim >::gatherLoadBalanceStatistics(), StatMarkerTimer_m, statWriters_m, and PartBunch< T, Dim >::updateMoments().

Here is the call graph for this function:

◆ init()

void DataSink::init ( bool  restart,
const std::vector< H5PartWrapper * > &  h5wrappers,
size_t  numParticleContainers 
)
private

◆ operator=()

DataSink & DataSink::operator= ( const DataSink )
privatedelete

◆ rewindLines()

void DataSink::rewindLines ( )
private

Definition at line 275 of file DataSink.cpp.

References h5Writers_m, sddsWriter_m, and statWriters_m.

Referenced by DataSink().

◆ storeCavityInformation()

void DataSink::storeCavityInformation ( )

Write cavity information from H5 file.

Definition at line 172 of file DataSink.cpp.

References Options::enableHDF5, and h5Writers_m.

Referenced by ParallelTracker::saveCavityPhases().

◆ writeGeomToVtk()

void DataSink::writeGeomToVtk ( BoundaryGeometry bg,
std::string  fn 
)

Write geometry points and surface triangles to vtk file

Parameters
fnspecifies the name of vtk file contains the geometry

Definition at line 197 of file DataSink.cpp.

References Options::enableVTK, and BoundaryGeometry::writeGeomToVtk().

Here is the call graph for this function:

◆ writeImpactStatistics()

void DataSink::writeImpactStatistics ( const PartBunch_t beam,
long long int &  step,
size_t &  impact,
double &  sey_num,
size_t  numberOfFieldEmittedParticles,
bool  nEmissionMode,
std::string  fn 
)

Write impact number and outgoing secondaries in each time step

Parameters
fnspecifies the name of vtk file contains the geometry

Definition at line 203 of file DataSink.cpp.

References PartBunch< T, Dim >::getT(), PartBunch< T, Dim >::getTotalCharge(), and Units::s2ns.

Here is the call graph for this function:

Member Data Documentation

◆ binConfigWriter_m

std::unique_ptr<BinConfigWriter> DataSink::binConfigWriter_m
private

Definition at line 193 of file DataSink.h.

Referenced by dumpBinConfig().

◆ dirichletPlaneWriter_m

std::unique_ptr<DirichletPlaneWriter> DataSink::dirichletPlaneWriter_m
private

Definition at line 196 of file DataSink.h.

Referenced by dumpDirichletPlane().

◆ h5Writers_m

std::vector<h5Writer_t> DataSink::h5Writers_m
private

Definition at line 188 of file DataSink.h.

Referenced by changeH5Wrappers(), dumpH5(), dumpH5(), init(), rewindLines(), and storeCavityInformation().

◆ lossWrCounter_m

unsigned int DataSink::lossWrCounter_m
private

needed to create index for vtk file

Definition at line 201 of file DataSink.h.

Referenced by init().

◆ sddsWriter_m

std::vector<sddsWriter_t> DataSink::sddsWriter_m
private

Definition at line 190 of file DataSink.h.

Referenced by init(), and rewindLines().

◆ StatMarkerTimer_m

IpplTimings::TimerRef DataSink::StatMarkerTimer_m
private

Timer to track statistics write time.

Definition at line 204 of file DataSink.h.

Referenced by dumpSDDS(), and init().

◆ statWriters_m

std::vector<statWriter_t> DataSink::statWriters_m
private

Definition at line 189 of file DataSink.h.

Referenced by dumpSDDS(), init(), and rewindLines().


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