Module: File IO
File Writers
File writer classes are used to export data to persistent files.
Primary Simulation Result Data File Writer
FileIO::TrajectoryHDF5Writer writes trajectory HDF5 files, which is the current primary trajectory data export format of IDSimF.
-
class TrajectoryHDF5Writer
Public Functions
-
TrajectoryHDF5Writer(const std::string &hdf5Filename, bool compression = true)
Constructs a new HDF5 trajectory filewriter
- Parameters:
hdf5Filename – A filename / path of a HDF5 file to write
compression – If true: the HDF5 file is written with data compression
-
void setParticleAttributes(const std::vector<std::string> &attributeNames, partAttribTransformFctType attributesTransformFct)
FIXME
- Parameters:
attributeNames –
attributesTransformFct –
-
void setParticleAttributes(const std::vector<std::string> &attributeNames, partAttribTransformFctTypeInteger attributesTransformFct)
- Parameters:
attributeNames –
attributesTransformFct –
-
void writeTimestep(std::vector<Core::Particle*> &particles, double time)
Writes a single time step to the HDF5 trajectory file
Note that an empty timestep, without any particles, is silently ignored.
- Parameters:
particles – The particle ensemble in the simulation to write to the trajectory file
time – The current simulated time
-
template<typename DT>
void writeNumericListDataset(std::string dsName, const std::vector<DT> &values, H5::Group *group = nullptr) Write a numeric vector to a dataset in the trajectory file
- Parameters:
dsName – Name of the dataset in the HDF5 file to write the vector into
values – Numeric vector with values to write to the dataset
group – FIXME
-
void write3DVectorListDataset(std::string dsName, const std::vector<Core::Vector> &values, H5::Group *group = nullptr)
-
template<typename DT, std::size_t DIMS>
void writeArrayDataSet(std::string dsName, const std::vector<std::array<DT, DIMS>> &values, H5::Group *group = nullptr)
-
void writeTrajectoryAttribute(std::string attrName, int value)
Writes an integer attribute to the trajectory file
- Parameters:
attrName – Name of the attribute to write
value – The value to write into the attribute in the trajectory file
-
void writeTrajectoryAttribute(std::string attrName, const std::vector<double> &values)
Writes an numeric vector attribute to the trajectory file
- Parameters:
attrName – Name of the attribute to write
value – The values to write into the attribute in the trajectory file
-
void writeTrajectoryAttribute(std::string attrName, const std::vector<std::string> &values)
Writes an string vector attribute to the trajectory file
- Parameters:
attrName – Name of the attribute to write
value – The values to write into the attribute in the trajectory file
-
void finalizeTrajectory()
Finalizes the trajectory, usually after the simulation has finished
-
void writeSplatTimes(std::vector<Core::Particle*> &particles)
Writes the splat (termination) times of the simulated particle ensemble to the HDF5 trajectory file
- Parameters:
particles – The simulated particle ensemble
-
void writeStartSplatData(ParticleSimulation::ParticleStartSplatTracker tracker)
-
TrajectoryHDF5Writer(const std::string &hdf5Filename, bool compression = true)
FileIO::Scalar_writer writes tables of scalar values from simulations:
-
class Scalar_writer
File writer to write scalar values to a result file
Public Functions
-
explicit Scalar_writer(std::string transientFilename)
Constructor: Creates a file writer for a given result file
- Parameters:
transientFilename – the name of the file to write to
-
~Scalar_writer()
Destructor
-
void writeTimestep(int intValue, double time)
Writes a scalar value to the result file
- Parameters:
intValue – the scalar value to write
time – the time of the current time step
-
void writeTimestep(std::size_t sizeValue, double time)
Writes a scalar value to the result file
- Parameters:
sizeValue – the scalar value to write
time – the time of the current time step
-
void writeTimestep(unsigned int unsignedIntValue, double time)
Writes a unsigned integer scalar value to the result file
- Parameters:
unsignedIntValue – the scalar value to write
time – the time of the current time step
-
void writeTimestep(double doubleValue, double time)
Writes a scalar value to the result file
- Parameters:
doubleValue – the scalar value to write
time – the time of the current time step
-
void writeTimestep(std::vector<double> doubleValues, double time)
Writes multiple values simultaneously to the result file
- Parameters:
doubleValues – vector of values to write
time – the time of the current time step
-
explicit Scalar_writer(std::string transientFilename)
Additional Result File Writer
Additional file writer provide additional export file formats.
Note
The additional file writer are currently not well maintained.
-
class SimpleVTKwriter
File writer to write particle cloud and Core data to legacy VTK files
Public Functions
-
SimpleVTKwriter(std::string basefilename)
Constructor: Creates a VTK filewriter to write to result files.
Two files are created: basefilename_particles.vtk - which the particle trajectory data is written to and basefilename_tree.vtk - which the tree / tree node data is written to
- Parameters:
basefilename – basename for the result files to create
-
~SimpleVTKwriter()
Destructor
-
SimpleVTKwriter(std::string basefilename)
Special Simulation File Writer
There are some file writers for special simulation requirements:
-
class InductionCurrentWriter
Public Functions
-
InductionCurrentWriter(std::vector<Core::Particle*> particles, std::string transientFilename, const std::vector<ParticleSimulation::SimionPotentialArray*> &weightFields, std::vector<double> weightFactors, double scale_mm_per_gu)
Constructor: Creates a induction current writer
- Parameters:
particles – vector with links to the partilces in a particle cloud to write to a file
transientFilename – the filename of the file to write to
weightFields – a vector of the weight potential arrays for the individual detection electrodes. A weight field of a detection electrode is a potential array in which the detection electrode has 1 V potential while all other electrodes are on ground
weightFactors – scaling factors for the individual weight fields
scale_mm_per_gu – scaling factor between mm and grid units of the given weight potential arrays
-
~InductionCurrentWriter()
Destructor
-
void writeTimestep(double time)
Writes a time step to the file
- Parameters:
time – the time of the current time step
-
InductionCurrentWriter(std::vector<Core::Particle*> particles, std::string transientFilename, const std::vector<ParticleSimulation::SimionPotentialArray*> &weightFields, std::vector<double> weightFactors, double scale_mm_per_gu)
-
class IdealizedQitFFTWriter
Simulation result file writer which writes the displacement current induced by a simulated ion cloud on the cap electrodes in an QIT simulation to a file.
The displacement current is approximated as the average displacement of the individual charged particles.
Public Functions
-
IdealizedQitFFTWriter(std::vector<Core::Particle*> particles, std::string transientFilename)
Constructor: Creates a filewriter with a given particle cloud and a file to write to
- Parameters:
particles – vector with links to the partilces in a particle cloud to write to a file
transientFilename – the filename of the file to write to
-
~IdealizedQitFFTWriter()
Destructor
-
void writeTimestep(double time)
Writes a time step to the file: The current state of the particles in the particle cloud is used to determine the average velocity in z direction for all particles and the result is written to the result file.
- Parameters:
time – the time of the current time step
-
void writeTimestepMassResolved(double time)
Writes a time step to the file in a mass resolved way: The current state of the particles in the particle cloud is used to determine the average velocity in z direction individually for groups containing particles with the same mass. The result is written to the result file.
- Parameters:
time – the time of the current time step
-
void writeTimestepAverageIonCloudPosition(double time)
Writes a time step to the file in a mass resolved way: The current state of the particles in the particle cloud is used to determine the average velocity in z direction individually for groups containing particles with the same mass. The result is written to the result file.
- Parameters:
time – the time of the current time step
-
IdealizedQitFFTWriter(std::vector<Core::Particle*> particles, std::string transientFilename)
-
class AverageChargePositionWriter
Filewriter to write the average position of the net charge in a Core to a file
File Readers
File readers import data from persistent files
FileIO::HDF5Reader is a general reader for HDF5 files.
-
class HDF5Reader
Public Functions
-
explicit HDF5Reader(const std::string &hdf5Filename)
-
template<typename DTYPE>
std::vector<DTYPE> readAttributeVector(std::string groupName, std::string attributeName) const
-
hsize_t numberOfObjectsInGroup(std::string groupName) const
-
std::vector<std::string> namesOfObjectsInGroup(std::string groupName) const
-
std::vector<std::string> namesOfDatasetsInGroup(std::string groupName) const
-
int datasetNDims(std::string datasetName) const
-
template<hsize_t NDIMS, typename DTYPE>
struct DataField
-
explicit HDF5Reader(const std::string &hdf5Filename)
-
class IonCloudReader
File reader for importing structured simple ion clouds / ion initialization data from files
Public Functions
-
std::vector<std::unique_ptr<Core::Particle>> readIonCloud(std::string filename)
Reads particles from an ion cloud definition file
- Parameters:
filename – a filename to read from
- Throws:
IonCloudFileException – if the ion cloud file is incorrect
- Returns:
Vector with unique pointers to the read and newly created particles
-
std::vector<std::unique_ptr<Core::Particle>> readIonCloud(std::string filename)
-
class MolecularStructureReader
Public Functions
-
std::unordered_map<std::string, std::shared_ptr<CollisionModel::MolecularStructure>> readMolecularStructure(std::string filename)
-
std::unordered_map<std::string, std::shared_ptr<CollisionModel::MolecularStructure>> readMolecularStructure(std::string filename)