|
Rheolef
7.1
an efficient C++ finite element environment
|
rheostream Here, utilities for stream input and output are suitable are reviewed. Two classes are provided, together with a set of useful functions.
The irheostream is suitable for a sequential memory envinement: for a distributed memory and parallel computation case, see the diststream class. Indeed, the irheostream is used as a base class for the idiststream one.
File decompresion is assumed using gzip and a recursive search in a directory list is provided for input.
orheostream foo("NAME", "suffix");
is like
ofstream foo("NAME.suffix").
However, if NAME does not end with .suffix, then .suffix is automatically added. By default, compression is performed on the fly with gzip, adding an additional .gz suffix. The flush action is nicely handled in compression mode:
foo.flush();
This feature allows intermediate results to be available during long computations. The compression can be deactivated while opening a file by an optional argument:
orheostream foo("NAME", "suffix", io::nogz);
An existing compressed file can be reopen in append mode: new results will be appended at the end of an existing file:
orheostream foo("NAME", "suffix", io::app);
Conversely,
irheostream foo("NAME","suffix");
is like
ifstream foo("NAME.suffix").
However, we look at a search path environment variable RHEOPATH in order to find NAME while suffix is assumed. Moreover, gzip compressed files, ending with the .gz suffix is assumed, and decompression is done.
The following code:
irheostream is("results", "data");
will recursively look for a results[.data[.gz]] file in the rectory mentioned by the RHEOPATH environment variable.
For instance, if you insert in our ".cshrc" something like:
setenv RHEOPATH ".:/home/dupont:/usr/local/math/demo"
the process will study the current directory ., then, if neither square.data.gz nor square.data exits, it scan all subdirectory of the current directory. Then, if file is not founded, it start recusively in /home/dupond and then in /usr/local/math/demo.
File decompression is performed by using the gzip command, and data are pipe-lined directly in memory.
If the file start with . as ./square or with a / as /home/oscar/square, no search occurs and RHEOPATH environment variable is not used.
Also, if the environment variable RHEOPATH is not set, the default value is the current directory ..
For output stream:
orheostream os("newresults", "data");
file compression is assumed, and "newresults.data.gz" will be created.
File loading and storing are mentioned by a message, either:
! load "./results.data.gz"
or:
! file "./newresults.data.gz" created.
on the clog stream. By adding the following:
clog << noverbose;
you turn off these messages.
This documentation has been generated from file util/lib/rheostream.h