Many, many more comments

This commit is contained in:
2024-12-04 17:15:04 +01:00
parent 8696517336
commit 03854339ca
100 changed files with 1702 additions and 49 deletions
+10
View File
@@ -4,13 +4,23 @@
#include <string>
#include "blitz/array.h"
// class for reading data from a hdf5-file
class Hdf5Reader {
public:
// Constructor: taking a string with the path to the directory and
// a string with the name of the file to be read (without the ".h5", which is appended by default)
Hdf5Reader(std::string directory, std::string filename);
// Constructor: taking a string of the absolute path to the file (string is not changed)
Hdf5Reader(std::string absolute_filename);
// read a 3-dimensional array from the hdf5-file specified at construction of the reader
// object at the hdf5-path "path" and return it as a blitz::Array
blitz::Array<double, 3> readD3Double(std::string path);
// read a 2-dimensional array from the hdf5-file specified at construction of the reader
// object at the hdf5-path "path" and return it as a blitz::Array
blitz::Array<double, 2> readD2Double(std::string path);
// read a 1-dimensional array from the hdf5-file specified at construction of the reader
// object at the hdf5-path "path" and return it as a blitz::Array
blitz::Array<double, 1> readD1Double(std::string path);
private:
+6 -1
View File
@@ -5,11 +5,16 @@
#include <vector>
#include "blitz/array.h"
// Class to handle hdf5 output
class Hdf5Writer {
public:
// the ".h5" is appened to the filename by default
Hdf5Writer(std::string directory = "./output",
std::string filename = "output");
// writing functions to write data to a HDF dataset specified by the path
// variable (format: path = "/Group1/Group2/.../GroupN/NameOfDataset")
// into the file specified by directory and filename
void write(const blitz::Array<double, 1>& data, std::string path);
void write(const blitz::Array<double, 2>& data, std::string path);
void write(const blitz::Array<double, 3>& data, std::string path);
+69 -1
View File
@@ -7,36 +7,57 @@
#include <vector>
#include "IO/hdf5_writer.h"
// defined in "simulation/density_field.h"
class DynamicDensityField;
class CurrentBorder;
//class CurrentBorder;
// defined in "simulation/parameter.h"
class Parameter;
// defined in "simulation/current_collector.h"
class CurrentCollector;
// defined in "simulation/logger.h"
class DeletionLogger;
// defined in "simulation/species.h"
namespace species {
class TrackedSpecie;
enum class ImplementedSpecies;
}; // namespace species
// structure to store information about output types
struct OutputTask {
// name of the particle species that output should be performed for
std::string specie_name;
// if true earlier output is overwritten
bool overwrite_last;
// how many cpu synchronization steps are inbetween two output steps
int intervall;
// selector if each or only first cpu should write can be added here
};
// class to handle output from the simulation
class SimulationOutput {
public:
// Constructor: takes the name of the output directory and
// the name of the output file (".h5" appended by default)
// directory is created if it does not exist
SimulationOutput(const std::string& output_folder,
const std::string& output_filename);
// add OutputTask for the output of the (dynamic) density field
void addDensityFieldOutput(OutputTask task);
// add OutputTask for the output of the current collector
void addCurrentBorderOutput(OutputTask task);
// add OutputTask for the output of the deletion logger
void addDeletionLoggerOutput(OutputTask task);
// write data that is initialized once at the beginning of the simulation
// for all TrackedSpecies (mass (kg), charge (C), bin volumes, bin borders, number of bins
// bin areas)
void writeMetaData(
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species);
// write data that changes during the simulation, output intervalls are defined
// wrt the number of cpu synchronization steps cpu_sync
void writeSimulationData(
int cpu_sync,
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species);
@@ -48,45 +69,92 @@ class SimulationOutput {
Hdf5Writer writer;
// function for writing simulated data in the dynamic density field
// takes the path to the hdf group of the specie the dynamic density field is defined for
// takes the number of cpu synchronization steps that have been performed
// takes whether earlier output should be overwritten
void writeSimulationData(DynamicDensityField* density_field,
std::string species_path,
int cpu_sync,
bool overwrite_last);
// write the 4d density array of the dynamic density field
// in the hdf group defined by string (has to be a total hdf path)
void writeSpectrum(DynamicDensityField* density_field, std::string path);
// write the 3d density array of the dynamic density field
// in the hdf group defined by string (has to be a total hdf path)
void writeDensity(DynamicDensityField* density_field, std::string path);
// write the 4d time in bin array (i.e. the raw data) of the dynamic density field
// in the hdf group defined by string (has to be a total hdf path)
void writeTimeInBin(DynamicDensityField* density_field, std::string path);
// write the 4d density array of the deleted particles array
// in the hdf group defined by string (has to be a total hdf path)
void writeDeletedParticles(DynamicDensityField* density_field,
std::string path);
// write the time of the Timer member object
// in the hdf group defined by string (has to be a total hdf path)
void writePhysicalTime(DynamicDensityField* density_field, std::string path);
// function for writing simulated data in the current collector
// takes the path to the hdf group of the specie the dynamic density field is defined for
// takes the number of cpu synchronization steps that have been performed
// takes whether earlier output should be overwritten
void writeSimulationData(CurrentCollector* current_collector,
std::string species_path,
int cpu_sync,
bool overwrite_last);
// write all positive and negative crossing arrays (i.e. raw data)
// in the hdf group defined by string (has to be a total hdf path)
void writeCurrentCrossings(CurrentCollector* current_collector,
std::string path);
// write all physical particle current arrays (i.e. raw data)
// in the hdf group defined by string (has to be a total hdf path)
void writeCurrent(CurrentCollector* current_collector, std::string path);
// write the time of the Timer member object
// in the hdf group defined by string (has to be a total hdf path)
void writePhysicalTime(CurrentCollector* current_collector, std::string path);
// function for writing simulated data in the deletion logger
// takes the path to the hdf group of the specie the dynamic density field is defined for
// takes the number of cpu synchronization steps that have been performed
// takes whether earlier output should be overwritten
void writeSimulationData(DeletionLogger* logger,
std::string species_path,
int cpu_sync,
bool overwrite_last);
// write the deletion trakced by the DeletionLogger
// in the hdf group defined by string (has to be a total hdf path)
void writeNumDeletions(DeletionLogger* logger, std::string path);
// write the not simulated aspects of the TrackedSpecie
// (mass (kg), charge (C))
// in the hdf group defined by string (has to be a total hdf path)
void writeMetaData(species::TrackedSpecie* specie);
// write the not simulated aspects of the DynamicDensityField
// (bin volumes, bin borders)
// in the hdf group defined by string (has to be a total hdf path)
void writeMetaData(DynamicDensityField* density_field, std::string path);
// write the not simulated aspects of the CurrentCollector
// (bin areas)
// in the hdf group defined by string (has to be a total hdf path)
void writeMetaData(CurrentCollector* current_collector, std::string path);
// void writeParameterFile(Parameter* parameter);
// write the areas of the bins used by the current collector
// in the hdf group defined by string (has to be a total hdf path)
void writeCollectorAreas(CurrentCollector* current_collector,
std::string path);
// write the volumes of the bins used by the dynamic density field
// in the hdf group defined by string (has to be a total hdf path)
void writeBinVolumes(DynamicDensityField* density_field,
std::string path_to_field);
// write the number of bins used by the dynamic density field
// in the hdf group defined by string (has to be a total hdf path)
void writeNumBins(DynamicDensityField* density_field,
std::string path_to_field);
// write the borders of the bins used by the dynamic density field
// in the hdf group defined by string (has to be a total hdf path)
void writeBinBorders(DynamicDensityField* density_field,
std::string path_to_field);
};