NGen
Loading...
Searching...
No Matches
utils::PerNexusCsvOutputMgr Class Reference

Subtype that manages/writes per-nexus data files in CSV format. More...

#include <PerNexusCsvOutputMgr.hpp>

+ Inheritance diagram for utils::PerNexusCsvOutputMgr:
+ Collaboration diagram for utils::PerNexusCsvOutputMgr:

Public Member Functions

 PerNexusCsvOutputMgr (const std::vector< std::string > &nexus_ids, const std::string &output_root)
 Construct instance set for managing/writing nexus data files.
 
void close () override
 Close this instance, closing all nexus_outfiles streams.
 
void commit_writes () override
 Commit writes by flushing output file ofstreams to filesystem.
 
bool is_closed () override
 A test of whether this instance is closed.
 
void receive_data_entry (const std::string &formulation_id, const std::string &nexus_id, const time_marker &data_time_marker, double flow_data_at_t) override
 Receive a data entry for this nexus, specifying details including the formulation id.
 
virtual void receive_data_entry (const std::string &nexus_id, const time_marker &data_time_marker, const double flow_data_at_t)
 Receive a data entry for this nexus, specifying details but using the default formulation id (however that is determined).
 

Protected Member Functions

const std::string get_default_formulation_id ()
 Get some a formulation id value.
 

Private Attributes

std::unordered_map< std::string, std::ofstream > nexus_outfiles
 
bool closed = false
 

Detailed Description

Subtype that manages/writes per-nexus data files in CSV format.

Constructor & Destructor Documentation

◆ PerNexusCsvOutputMgr()

utils::PerNexusCsvOutputMgr::PerNexusCsvOutputMgr ( const std::vector< std::string > & nexus_ids,
const std::string & output_root )

Construct instance set for managing/writing nexus data files.

Parameters
nexus_idsNexus ids for which this instance manages data (in particular, local nexuses when using MPI).
output_rootThe output root for written files (as a string).

References nexus_outfiles.

Member Function Documentation

◆ close()

void utils::PerNexusCsvOutputMgr::close ( )
overridevirtual

Close this instance, closing all nexus_outfiles streams.

Once a manager is closed, it will not be able to receive new data. Subsequent calls to receive_data_entry functions will result in an exception.

However, because of the way this type is implemented, all data received before the call to close should get flushed to disk as part of closing the files.

If this instance is already closed, the function will simply return.

Implements utils::NexusOutputsMgr.

◆ commit_writes()

void utils::PerNexusCsvOutputMgr::commit_writes ( )
overridevirtual

Commit writes by flushing output file ofstreams to filesystem.

Note that this function will do nothing and immediately return if the instance has already been closed with close.

Implements utils::NexusOutputsMgr.

◆ get_default_formulation_id()

const std::string utils::NexusOutputsMgr::get_default_formulation_id ( )
inlineprotectedinherited

Get some a formulation id value.

Returns
The value for the default formulation id.

Referenced by utils::NexusOutputsMgr::receive_data_entry().

◆ is_closed()

bool utils::PerNexusCsvOutputMgr::is_closed ( )
overridevirtual

A test of whether this instance is closed.

Returns
Whether this instance is closed.
See also
close

Implements utils::NexusOutputsMgr.

◆ receive_data_entry() [1/2]

virtual void utils::NexusOutputsMgr::receive_data_entry ( const std::string & nexus_id,
const time_marker & data_time_marker,
const double flow_data_at_t )
inlinevirtualinherited

Receive a data entry for this nexus, specifying details but using the default formulation id (however that is determined).

Parameters
nexus_idThe id for the nexus to which this data applies.
data_time_markerA marker for the current simulation time for the data.
flow_data_at_tThe nexus flow contribution at this time index (the main data to write).
See also
get_default_formulation_id

References utils::NexusOutputsMgr::get_default_formulation_id(), and utils::NexusOutputsMgr::receive_data_entry().

◆ receive_data_entry() [2/2]

void utils::PerNexusCsvOutputMgr::receive_data_entry ( const std::string & formulation_id,
const std::string & nexus_id,
const time_marker & data_time_marker,
double flow_data_at_t )
overridevirtual

Receive a data entry for this nexus, specifying details including the formulation id.

If this instance is closed (is_closed) an exception will be raised.

Parameters
formulation_idThe id of the formulation involved in producing this data.
nexus_idThe id for the nexus to which this data applies.
data_time_markerA marker for the current simulation time for the data.
flow_data_at_tThe nexus flow contribution at this time index (the main data to write).
See also
close
is_closed

Implements utils::NexusOutputsMgr.

References utils::time_marker::sim_time_index, and utils::time_marker::time_stamp.

Member Data Documentation

◆ closed

bool utils::PerNexusCsvOutputMgr::closed = false
private

◆ nexus_outfiles

std::unordered_map<std::string, std::ofstream> utils::PerNexusCsvOutputMgr::nexus_outfiles
private

Referenced by PerNexusCsvOutputMgr().


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