HDF5Output Class Reference#
|
DiFfRG
Discretization Framework for functional Renormalization Group flows
|
A class to output data to a CSV file. More...
#include <hdf5_output.hh>
Classes | |
| struct | ScalarInfo |
Public Member Functions | |
| HDF5Output (const std::string top_folder, const std::string output_name, const std::string &configuration_json="{}") | |
| Construct a new Csv Output object. | |
| HDF5Output (const std::string top_folder, const std::string output_name, const ConfigTree &config) | |
| ~HDF5Output () | |
| template<typename T > | |
| void | scalar (const std::string &name, const T value) |
| Add a value to the output. | |
| void | scalar (const std::string &name, const char *value) |
| template<typename COORD > requires is_coordinates<COORD> | |
| void | map (const std::string &name, const COORD &coordinates) |
| template<typename COORD , typename T > requires is_coordinates<COORD> | |
| void | map (const std::string &name, const COORD &coordinates, T *data) |
| template<typename INTERP > requires is_interpolator<INTERP> | |
| void | map (const std::string &name, const INTERP &_interpolator) |
| template<typename INTERP > requires is_interpolator<INTERP> | |
| void | map (const std::string &name, const std::string &coord_name, const INTERP &_interpolator) |
| void | stage_fe_frame (unsigned int series_number, double time, const std::string &group_name, const std::string &fe_output_name, unsigned int dim, std::size_t n_nodes, std::vector< double > node_data, std::vector< std::pair< std::string, std::vector< double > > > data_sets) |
| Stage the node coordinates and nodal values of one finite-element frame. | |
| DiFfRG::hdf5::File & | get_file () |
| Open the file for setup work performed before any frame is written. | |
| void | flush (const double time) |
| void | run_staged_frame (double time) |
| Execute and clear whatever is staged, without the per-frame scalar bookkeeping. | |
| void | set_writer (HDF5FrameWriter *writer) |
| Route staged frames through a writer thread instead of writing them inline. | |
| void | drain () |
| void | mark_finished (bool crashed) |
Record how the run ended: sets the root finished attribute to 1, and crashed to whether it ended by throwing. | |
| void | open_file () |
| void | close_file () |
| FrameTimings | take_frame_timings () |
Static Public Member Functions | |
| static void | write_series_record (DiFfRG::hdf5::Group &group, const int series_number) |
Private Member Functions | |
| template<typename T > | |
| void | stage_map (const std::string &name, const std::string &coord_name, const DiFfRG::hdf5::Dims &dims, std::vector< T > payload) |
| Stage one map series: the group, its series record, its data and its coordinate link. | |
| template<typename COORD > | |
| void | check_coordinates (const std::string &coord_name, const COORD &coordinates) |
Private Attributes | |
| const std::string | top_folder |
| const std::string | output_name |
| bool | opened |
| std::map< std::string, ScalarInfo > | scalar_infos |
| std::set< std::string > | created_map_groups |
| HDF5Frame | staged |
| HDF5FrameWriter * | writer = nullptr |
| std::list< std::string > | written_scalars |
| std::vector< std::pair< std::string, size_t > > | written_map_series |
| std::map< std::string, size_t > | map_series_numbers |
| std::map< std::string, std::string > | coord_identifiers |
| std::list< std::string > | initial_scalars |
| DiFfRG::hdf5::File | h5_file |
| std::filesystem::path | path |
| FrameTimings | frame_timings |
Detailed Description
A class to output data to a CSV file.
In every time step, the user can add values to the output, which will be written to the file when flush is called. Every timestep has to contain the same values, but the order in which they are added can change.
Constructor & Destructor Documentation
◆ HDF5Output() [1/2]
| DiFfRG::HDF5Output::HDF5Output | ( | const std::string | top_folder, |
| const std::string | output_name, | ||
| const std::string & | configuration_json = "{}" ) |
Construct a new Csv Output object.
- Parameters
-
top_folder The top folder to store the output in. output_name The name of the output file. config The ConfigTree object containing the parameters.
◆ HDF5Output() [2/2]
|
inline |
◆ ~HDF5Output()
| DiFfRG::HDF5Output::~HDF5Output | ( | ) |
Member Function Documentation
◆ check_coordinates()
|
inlineprivate |
◆ close_file()
| void DiFfRG::HDF5Output::close_file | ( | ) |
◆ drain()
| void DiFfRG::HDF5Output::drain | ( | ) |
Wait for this sink's queued frames to reach disk and surface any writer error.
◆ flush()
| void DiFfRG::HDF5Output::flush | ( | const double | time | ) |
◆ get_file()
| DiFfRG::hdf5::File & DiFfRG::HDF5Output::get_file | ( | ) |
Open the file for setup work performed before any frame is written.
Not for per-frame writes – those go through scalar()/map()/stage_fe_frame() and are executed together when the frame is flushed. Callers must close_file() when done, so the lock is not held into the run.
◆ map() [1/4]
requires is_coordinates<COORD>
|
inline |
◆ map() [2/4]
requires is_coordinates<COORD>
|
inline |
◆ map() [3/4]
requires is_interpolator<INTERP>
|
inline |
◆ map() [4/4]
requires is_interpolator<INTERP>
|
inline |
◆ mark_finished()
| void DiFfRG::HDF5Output::mark_finished | ( | bool | crashed | ) |
Record how the run ended: sets the root finished attribute to 1, and crashed to whether it ended by throwing.
Call once, after the last frame. Files start at finished = 0, so a run that never gets here – SIGKILL, OOM, a node eviction – stays marked unfinished. A run that threw still reaches this and is marked finished, with crashed = 1: its output was flushed and closed properly, it just stopped early.
◆ open_file()
| void DiFfRG::HDF5Output::open_file | ( | ) |
◆ run_staged_frame()
| void DiFfRG::HDF5Output::run_staged_frame | ( | double | time | ) |
Execute and clear whatever is staged, without the per-frame scalar bookkeeping.
flush() is the normal entry point. This exists for the standalone FEOutput case, where nobody flushes the HDF5Output at all and the staged field data would otherwise be discarded at destruction.
◆ scalar() [1/2]
|
inline |
◆ scalar() [2/2]
|
inline |
Add a value to the output.
Validates and copies here, on the calling thread, so that a rejected value still fails at the call site with the context that produced it – but performs no HDF5 call. The write itself is staged and happens when the frame is flushed.
- Parameters
-
name The name of the value. value The value to add.
◆ set_writer()
|
inline |
Route staged frames through a writer thread instead of writing them inline.
Not owned. Every HDF5Output of one run must share the same writer, because HDF5 is not thread safe here and two writers would call into it concurrently. Passing nullptr (the default) keeps everything on the calling thread.
◆ stage_fe_frame()
| void DiFfRG::HDF5Output::stage_fe_frame | ( | unsigned int | series_number, |
| double | time, | ||
| const std::string & | group_name, | ||
| const std::string & | fe_output_name, | ||
| unsigned int | dim, | ||
| std::size_t | n_nodes, | ||
| std::vector< double > | node_data, | ||
| std::vector< std::pair< std::string, std::vector< double > > > | data_sets ) |
Stage the node coordinates and nodal values of one finite-element frame.
Called by FEOutput, which owns the DataOut and the filtering, but not the file. The arrays are moved in; nothing here touches HDF5.
◆ stage_map()
|
inlineprivate |
Stage one map series: the group, its series record, its data and its coordinate link.
Shared by the raw-pointer and interpolator overloads, which differ only in how they produce the dense payload and how the coordinate dataset gets its name.
◆ take_frame_timings()
|
inline |
Timing buckets accumulated since the last call, and reset by it.
◆ write_series_record()
|
inlinestatic |
Append the series number, as text, to a per-series-group dataset. Runs on the writer.
Member Data Documentation
◆ coord_identifiers
|
private |
◆ created_map_groups
|
private |
Map names whose parent group has been created (or staged for creation).
◆ frame_timings
|
private |
◆ h5_file
|
private |
Only ever open for setup work (see get_file()); frames use their own context.
◆ initial_scalars
|
private |
◆ map_series_numbers
|
private |
◆ opened
|
private |
◆ output_name
|
private |
◆ path
|
private |
◆ scalar_infos
|
private |
◆ staged
|
private |
Writes accumulated for the frame in progress; executed by flush().
◆ top_folder
|
private |
◆ writer
|
private |
Not owned; shared with every other HDF5Output of the same run.
◆ written_map_series
|
private |
(name, series) of every map written this frame. Carries the series number rather than re-deriving it as map_series_numbers[name] - 1 in flush(): a name written twice in one frame would otherwise stamp attributes onto the same group twice and fail in H5Acreate2, pointing at the flush instead of at the duplicate write.
◆ written_scalars
|
private |
The documentation for this class was generated from the following file:
- /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/data/hdf5_output.hh
Generated by