SPH
Public Member Functions | Static Public Member Functions | List of all members
OutputFile Class Reference

Helper file generating file names for output files. More...

#include <Output.h>

Public Member Functions

 OutputFile ()=default
 
 OutputFile (const Path &pathMask, const Size firstDumpIdx=0)
 Creates a new filename generator using provided path mask. More...
 
Path getNextPath (const Statistics &stats) const
 Returns path to the next output file. More...
 
bool hasWildcard () const
 Returns true if the file mask contains (at least one) wildcard. More...
 
Path getMask () const
 Returns the file mask as given in constructor. More...
 

Static Public Member Functions

static Optional< SizegetDumpIdx (const Path &path)
 Extracts the dump index from given path generated by OutputFile. More...
 
static Optional< OutputFilegetMaskFromPath (const Path &path, const Size firstDumpIdx=0)
 Attemps to get the OutputFile from one of the path generated from it. More...
 

Detailed Description

Helper file generating file names for output files.

This class only operates with paths and path masks. It does not perform any I/O operations to check for files, nor it creates any files, similarly to class Path.

Definition at line 21 of file Output.h.

Constructor & Destructor Documentation

◆ OutputFile() [1/2]

OutputFile::OutputFile ( )
default

◆ OutputFile() [2/2]

NAMESPACE_SPH_BEGIN OutputFile::OutputFile ( const Path pathMask,
const Size  firstDumpIdx = 0 
)

Creates a new filename generator using provided path mask.

If the input mask is a regular path, all calls to getNextPath will simply return the input path. Note that output generated using such OutputFile will override the previous one. To avoid this, the pathMask can contain following wildcards:

  • 'd' - replaced by the dump number, starting from arbitrary index, incremented every dump.
  • 't' - replaced by current simulation time (with _ instead of decimal separator).
Parameters
pathMaskPath possibly containing wildcards, used to determine the actual path for the dump.
firstDumpIdxIndex of the first dump. Can be non-zero if the simulation is resumed from previously generated snapshot, in order to continue in the sequence.

Definition at line 22 of file Output.cpp.

Member Function Documentation

◆ getDumpIdx()

Optional< Size > OutputFile::getDumpIdx ( const Path path)
static

Extracts the dump index from given path generated by OutputFile.

This is mainly useful when continuing simulation from previously saved snapshot, to determine the next index of dump.

Returns
Extracted index if the path contains it or NOTHING otherwise.

Definition at line 49 of file Output.cpp.

◆ getMask()

Path OutputFile::getMask ( ) const

Returns the file mask as given in constructor.

Definition at line 94 of file Output.cpp.

◆ getMaskFromPath()

Optional< OutputFile > OutputFile::getMaskFromPath ( const Path path,
const Size  firstDumpIdx = 0 
)
static

Attemps to get the OutputFile from one of the path generated from it.

The dump index of the returned object is set to 0. Note that this function currently does not work for masks containing the time wildcard.

Returns
Output file on success, otherwise NOTHING.
Todo:
could be deduplicated a bit

Definition at line 72 of file Output.cpp.

◆ getNextPath()

Path OutputFile::getNextPath ( const Statistics stats) const

Returns path to the next output file.

This increments the internal counter. Function is const so that it can be used in const functions. No file is created by this.

Todo:
replace decimal dot as docs say

Definition at line 28 of file Output.cpp.

◆ hasWildcard()

bool OutputFile::hasWildcard ( ) const

Returns true if the file mask contains (at least one) wildcard.

If not, getNextPath will always return the same path.

Definition at line 89 of file Output.cpp.


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