fpmas 1.6
Public Member Functions | List of all members
fpmas::io::DynamicFileOutput Class Reference

#include <output.h>

Inheritance diagram for fpmas::io::DynamicFileOutput:
Inheritance graph
[legend]
Collaboration diagram for fpmas::io::DynamicFileOutput:
Collaboration graph
[legend]

Public Member Functions

 DynamicFileOutput (std::string fileformat, api::communication::MpiCommunicator &comm, api::runtime::Runtime &runtime, std::ios::openmode mode=std::ios::out)
 
std::ofstream & get () override
 
- Public Member Functions inherited from fpmas::api::io::OutputStream
virtual std::ostream & get ()=0
 
std::ostream & operator<< (std::ostream &(*func)(std::ostream &))
 

Detailed Description

An fpmas::api::io::OutputStream implementation that dynamically open files depending on the current time step.

The generic get() method is always used to access the underlying file output. However the returned file effectively depends on the current runtime state.

For example, if the specified file format is "file.%t.csv", calling get() when runtime.currentDate() is 0 while open and return a reference to the file "file.0.csv", while calling the same method at time step 3 will open and return a reference to the file "file.3.csv".

In addition, the file format can contain 'r', that will eventually be replaced by the current process rank.

Constructor & Destructor Documentation

◆ DynamicFileOutput()

fpmas::io::DynamicFileOutput::DynamicFileOutput ( std::string  fileformat,
api::communication::MpiCommunicator comm,
api::runtime::Runtime runtime,
std::ios::openmode  mode = std::ios::out 
)
inline

DynamicFileOutput constructor.

Parameters
fileformatAbstract file format, used to generate file names. Each time get() is called, file_format is formatted using fpmas::utils::format(std::string, int, fpmas::api::scheduler::TimeStep) to produce a file name.
commMPI communicator (used only to get the current process rank)
runtimeruntime used to get the current time step
modefile open mode (see https://en.cppreference.com/w/cpp/io/ios_base/openmode)

Member Function Documentation

◆ get()

std::ofstream & fpmas::io::DynamicFileOutput::get ( )
inlineoverridevirtual

Return a reference to the current file output, depending on the current runtime state.

Returns
file output

Implements fpmas::api::io::OutputStream.


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