seriesWriter Class Reference

Provides a means of accumulating and generating VTK file series. More...

Public Member Functions

 seriesWriter ()=default
 Construct an empty series. More...
 
 seriesWriter (const seriesWriter &)=default
 Copy construct. More...
 
 seriesWriter (seriesWriter &&)=default
 Move construct. More...
 
seriesWriteroperator= (const seriesWriter &)=default
 Copy assignment. More...
 
seriesWriteroperator= (seriesWriter &&)=default
 Move assignment. More...
 
 ~seriesWriter ()=default
 Destructor. More...
 
bool empty () const noexcept
 True if there are no data sets. More...
 
label size () const noexcept
 The number of data sets. More...
 
void clear ()
 Clear entries. More...
 
bool append (const fileNameInstant &inst)
 Append the specified file instant. More...
 
bool append (fileNameInstant &&inst)
 Append the specified file instant. More...
 
bool append (scalar timeValue, const fileName &file)
 Append the specified file instant. More...
 
bool append (scalar timeValue, fileName &&file)
 Append the specified file instant. More...
 
label load (const fileName &seriesName, const bool checkFiles=false, const scalar restartTime=ROOTVGREAT)
 Clear contents and reload by parsing the specified file. More...
 
label scan (const fileName &seriesName, const scalar restartTime=ROOTVGREAT)
 Clear contents and scan directory for files. More...
 
bool removeNewer (const scalar timeValue)
 Remove entries that are greater_equal the time value. More...
 
void sort ()
 Sort by time value and by file name. More...
 
void print (Ostream &os) const
 Print file series as (JSON format) More...
 
void write (const fileName &seriesName) const
 Write file series as (JSON format) to disk. More...
 

Static Public Member Functions

static fileName base (const fileName &outputName, char sep='_')
 Extract the base name for a file series. More...
 
static word suffix (const fileName &file, char sep='_')
 Extract the time-varying ending of files. More...
 
static Ostreamprint (Ostream &os, const fileName &seriesName, const UList< instant > &series, const char sep='_')
 Print file series (JSON format) for specified time instances. More...
 
static void write (const fileName &base, const UList< instant > &series, const char sep='_')
 Write file series (JSON format) to disk, for specified instances. More...
 
static Ostreamprint (Ostream &os, const UList< fileNameInstant > &series)
 Print file series (JSON format) for specified time instances. More...
 
static void write (const fileName &seriesName, const UList< fileNameInstant > &series)
 Write file series (JSON format) to disk, for specified instances. More...
 

Detailed Description

Provides a means of accumulating and generating VTK file series.

The VTK file series format is a simple JSON format with the following type of content:

{
  "file-series-version" : "1.0",
  "files": [
    { "name" : "file1.vtk", "time" : 10 },
    { "name" : "file2.vtk", "time" : 20 },
    { "name" : "file3.vtk", "time" : 30 },
  ]
}

The append() operations include various sanity checks. Entries with an empty name are ignored. If an entry with an identical name already exists, its place will be overwritten with the new time value.

Source files

Definition at line 75 of file foamVtkSeriesWriter.H.

Constructor & Destructor Documentation

◆ seriesWriter() [1/3]

seriesWriter ( )
default

Construct an empty series.

◆ seriesWriter() [2/3]

seriesWriter ( const seriesWriter )
default

Copy construct.

◆ seriesWriter() [3/3]

seriesWriter ( seriesWriter &&  )
default

Move construct.

◆ ~seriesWriter()

~seriesWriter ( )
default

Destructor.

Member Function Documentation

◆ operator=() [1/2]

seriesWriter& operator= ( const seriesWriter )
default

Copy assignment.

◆ operator=() [2/2]

seriesWriter& operator= ( seriesWriter &&  )
default

Move assignment.

◆ base()

Foam::fileName base ( const fileName outputName,
char  sep = '_' 
)
static

Extract the base name for a file series.

Parameters
outputNameThe name of the data output file Eg, "somefile_0001.vtk" would extract to "somefile.vtk"
sepThe separator used between file stem and suffix.

Definition at line 91 of file foamVtkSeriesWriter.C.

References Foam::dot(), and outputName().

Referenced by vtkCloud::write(), and vtkWrite::write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ suffix()

Foam::word suffix ( const fileName file,
char  sep = '_' 
)
static

Extract the time-varying ending of files.

Parameters
fileThe name of the file Eg, "somefile_0001.vtk" would extract to "0001"
sepThe separator used between file stem and suffix.

Definition at line 121 of file foamVtkSeriesWriter.C.

References Foam::dot().

Here is the call graph for this function:

◆ print() [1/3]

Foam::Ostream & print ( Ostream os,
const fileName seriesName,
const UList< instant > &  series,
const char  sep = '_' 
)
static

Print file series (JSON format) for specified time instances.

Parameters
osThe output stream
baseThe name for the series (eg, "path/file.vtk")
seriesThe list of suffix/value entries
sepThe separator used between file stem and suffix.

Definition at line 151 of file foamVtkSeriesWriter.C.

References fileName::ext(), fileName::nameLessExt(), Foam::nl, os(), and UList< T >::size().

Referenced by seriesWriter::print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write() [1/3]

void write ( const fileName base,
const UList< instant > &  series,
const char  sep = '_' 
)
static

Write file series (JSON format) to disk, for specified instances.

Parameters
baseThe name for the series (eg, "path/file.vtk")
seriesThe list of suffix/value entries
sepThe separator used between file stem and suffix.

Definition at line 233 of file foamVtkSeriesWriter.C.

References fileName::hasExt(), Foam::mkDir(), Foam::New(), fileName::path(), and Foam::BitOps::print().

Referenced by seriesWriter::write(), vtkCloud::write(), and vtkWrite::write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print() [2/3]

Foam::Ostream & print ( Ostream os,
const UList< fileNameInstant > &  series 
)
static

Print file series (JSON format) for specified time instances.

Since the VTK file series does not currently (OCT-2018) support sub-directories, these will be stripped on output.

Parameters
osThe output stream
seriesThe list of filename/value entries

Definition at line 198 of file foamVtkSeriesWriter.C.

References Foam::nl, os(), and UList< T >::size().

Here is the call graph for this function:

◆ write() [2/3]

void write ( const fileName seriesName,
const UList< fileNameInstant > &  series 
)
static

Write file series (JSON format) to disk, for specified instances.

Parameters
seriesNameThe name for the series (eg, "path/file.vtk")
seriesThe list of filename/value entries

Definition at line 254 of file foamVtkSeriesWriter.C.

References fileName::hasExt(), Foam::mkDir(), Foam::New(), fileName::path(), and Foam::BitOps::print().

Here is the call graph for this function:

◆ empty()

bool empty ( ) const
inlinenoexcept

True if there are no data sets.

Definition at line 30 of file foamVtkSeriesWriterI.H.

Referenced by vtkCloud::write(), and vtkWrite::write().

Here is the caller graph for this function:

◆ size()

Foam::label size ( ) const
inlinenoexcept

The number of data sets.

Definition at line 36 of file foamVtkSeriesWriterI.H.

◆ clear()

void clear ( )
inline

Clear entries.

Definition at line 42 of file foamVtkSeriesWriterI.H.

◆ append() [1/4]

bool append ( const fileNameInstant inst)
inline

Append the specified file instant.

Definition at line 49 of file foamVtkSeriesWriterI.H.

References Instant< T >::name(), and Instant< T >::value().

Referenced by vtkCloud::write(), and vtkWrite::write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ append() [2/4]

bool append ( fileNameInstant &&  inst)
inline

Append the specified file instant.

Definition at line 56 of file foamVtkSeriesWriterI.H.

◆ append() [3/4]

bool append ( scalar  timeValue,
const fileName file 
)
inline

Append the specified file instant.

Definition at line 66 of file foamVtkSeriesWriterI.H.

References fileName::name().

Here is the call graph for this function:

◆ append() [4/4]

bool append ( scalar  timeValue,
fileName &&  file 
)
inline

Append the specified file instant.

Definition at line 77 of file foamVtkSeriesWriterI.H.

References fileName::removePath().

Here is the call graph for this function:

◆ load()

Foam::label load ( const fileName seriesName,
const bool  checkFiles = false,
const scalar  restartTime = ROOTVGREAT 
)

Clear contents and reload by parsing the specified file.

Parameters
seriesNamethe base name of the series to scan, without the ".series" ending.
checkFilesverify that the files also exist
restartTimeignore entries with a time greater/equal to the specified restart time.
Returns
the number of entries

Definition at line 366 of file foamVtkSeriesWriter.C.

References token::BEGIN_BLOCK, token::BEGIN_SQR, clear(), token::COMMA, token::END_BLOCK, token::END_SQR, fileName::ext(), Foam::getToken(), Foam::getValueToken(), fileName::hasExt(), HashSet< Key, Hash >::insert(), Foam::isFile(), token::isNumber(), token::isPunctuation(), token::isString(), Foam::glTF::key(), Foam::lessThan(), Instant< T >::name(), token::number(), fileName::path(), token::pToken(), Foam::readDir(), token::stringToken(), and Instant< T >::value().

Referenced by vtkCloud::write(), and vtkWrite::write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scan()

Foam::label scan ( const fileName seriesName,
const scalar  restartTime = ROOTVGREAT 
)

Clear contents and scan directory for files.

The expected xml header content is a comment with the following:

   <!-- ... time='3.14159' ... -->
Parameters
seriesNamethe base name of the series to scan, without the ".series" ending.
restartTimeignore entries with a time greater/equal to the specified restart time.
Returns
the number of entries

Definition at line 584 of file foamVtkSeriesWriter.C.

References append(), clear(), fileName::ext(), fileName::hasExt(), Foam::Info, Foam::isDir(), Foam::lessThan(), fileName::nameLessExt(), Foam::nl, path(), fileName::path(), Foam::readDir(), fileName::removeExt(), Foam::sort(), string::starts_with(), and Foam::subsetList().

Here is the call graph for this function:

◆ removeNewer()

bool removeNewer ( const scalar  timeValue)

Remove entries that are greater_equal the time value.

Returns
True if the contents changed

Definition at line 715 of file foamVtkSeriesWriter.C.

References Foam::lessThan(), Instant< T >::name(), Foam::name(), and Instant< T >::value().

Here is the call graph for this function:

◆ sort()

void sort ( )

Sort by time value and by file name.

Definition at line 745 of file foamVtkSeriesWriter.C.

References Foam::sort().

Here is the call graph for this function:

◆ print() [3/3]

void print ( Ostream os) const
inline

Print file series as (JSON format)

Definition at line 89 of file foamVtkSeriesWriterI.H.

References os(), and seriesWriter::print().

Here is the call graph for this function:

◆ write() [3/3]

void write ( const fileName seriesName) const
inline

Write file series as (JSON format) to disk.

Definition at line 95 of file foamVtkSeriesWriterI.H.

References seriesWriter::write().

Here is the call graph for this function:

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