Loading...
Searching...
No Matches
seriesWriter Class Reference

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

#include <foamVtkSeriesWriter.H>

Public Member Functions

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

Static Public Member Functions

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

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 73 of file foamVtkSeriesWriter.H.

Constructor & Destructor Documentation

◆ seriesWriter() [1/3]

seriesWriter ( )
inlinenoexcept

Construct an empty series (.series ending).

Definition at line 23 of file foamVtkSeriesWriterI.H.

References Foam::noexcept.

Referenced by operator=(), operator=(), seriesWriter(), and seriesWriter().

Here is the caller graph for this function:

◆ seriesWriter() [2/3]

seriesWriter ( const seriesWriter & )
default

Copy construct.

References seriesWriter().

Here is the call graph for this function:

◆ seriesWriter() [3/3]

seriesWriter ( seriesWriter && )
default

Move construct.

References seriesWriter().

Here is the call graph for this function:

◆ ~seriesWriter()

~seriesWriter ( )
default

Destructor.

Member Function Documentation

◆ operator=() [1/2]

seriesWriter & operator= ( const seriesWriter & )
default

Copy assignment.

References seriesWriter().

Here is the call graph for this function:

◆ operator=() [2/2]

seriesWriter & operator= ( seriesWriter && )
default

Move assignment.

References seriesWriter().

Here is the call graph for this function:

◆ base()

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.

References outputName().

Referenced by write().

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

◆ suffix()

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.

◆ print() [1/3]

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.

References os().

Referenced by print(), and sort().

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.

References base().

Referenced by write().

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

◆ print() [2/3]

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

References os().

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

References append(), clear(), json(), Foam::noexcept, and size().

Here is the call graph for this function:

◆ empty()

bool empty ( ) const
inlinenoexcept

True if there are no data sets.

Definition at line 31 of file foamVtkSeriesWriterI.H.

References Foam::noexcept.

◆ size()

Foam::label size ( ) const
inlinenoexcept

The number of data sets.

Definition at line 37 of file foamVtkSeriesWriterI.H.

References Foam::noexcept.

Referenced by write().

Here is the caller graph for this function:

◆ json() [1/2]

bool json ( ) const
inlinenoexcept

Preferred extension is "json" instead of "series".

Definition at line 43 of file foamVtkSeriesWriterI.H.

References Foam::noexcept.

Referenced by write().

Here is the caller graph for this function:

◆ json() [2/2]

bool json ( bool on)
inlinenoexcept

Toggle the preferred extension to "json" on/off. Return the old json state.

Definition at line 49 of file foamVtkSeriesWriterI.H.

◆ clear()

void clear ( )
inline

Clear entries.

Definition at line 57 of file foamVtkSeriesWriterI.H.

Referenced by write().

Here is the caller graph for this function:

◆ append() [1/4]

bool append ( const fileNameInstant & inst)
inline

Append the specified file instant.

Definition at line 64 of file foamVtkSeriesWriterI.H.

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

Referenced by 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 71 of file foamVtkSeriesWriterI.H.

◆ append() [3/4]

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

Append the specified file instant.

Definition at line 80 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 91 of file foamVtkSeriesWriterI.H.

◆ load()

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

Clear contents and reload by parsing the specified file.

Returns
the number of entries
Parameters
seriesNameBase 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

References load().

Referenced by load().

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

◆ scan()

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' ... -->
* 
Returns
the number of entries
Parameters
seriesNameBase name of the series to scan, without the ".series" ending
restartTimeIgnore entries with a time greater-equal to the specified restart time

References scan().

Referenced by scan().

Here is the call graph for this function:
Here is the caller 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

References removeNewer().

Referenced by removeNewer().

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

◆ sort()

void sort ( )

Sort by time value and by file name.

References os(), print(), and sort().

Referenced by sort().

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

◆ print() [3/3]

void print ( Ostream & os) const
inline

Print file series as (JSON format).

Definition at line 104 of file foamVtkSeriesWriterI.H.

References os(), and print().

Here is the call graph for this function:

◆ write() [3/3]

void write ( const fileName & seriesName) const

Write file series as (JSON format) to disk.

References write().

Here is the call graph for this function:

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