NAME
FieldWriter - storage of fields on files
INCLUDE
include "FieldWriter.h"
SYNTAX
class FieldWriter
{
private:
String name_of_dataset;
// data output files
Os fieldfile;
Os gridfile;
Format_type field_format;
Format_type grid_format;
// index files
Os field_ixfile;
Os grid_ixfile;
// map file:
Os simres_map;
// provides information about existing dataset
FieldReader reader;
// files open/closed flag
bool files_open;
FileMode next_openmode_ix,next_openmode_dat;
void writeGridHeader
(
const Grid& grid,
const int gridnum,
const int checknum
);
void updateGridIndex (const int gridnum, const long address);
void writeFieldHeader
(
Field& field,
const int fieldnum,
const int gridnum,
const String& header,
const real time,
const String& description,
const int component,
const int maxcomponent
);
void updateFieldIndex (const int fieldnum, const long address);
void open(); // opens output files
void close(); // closes output files
// list of all datasets managed by all FieldWriter objects:
static StringList dataset_names;
bool datasetIsManaged (const String& dataset_name);
void newDataset (const String& dataset_name);
public:
FieldWriter ();
FieldWriter (const String& dataset_name,const bool append = false);
~FieldWriter();
// it is possible to switch to another dataset:
void setDatasetName (const String& dataset_name,
const bool append = false);
void setStorageMode (Format_type field_format, Format_type grid_format);
int writeField // returns assigned field number in data set
(
Field& field,
const String& header,
const real time,
const String& description,
const int component = 1,
const int maxcomponent = 1
);
int writeField // version without description
(
Field& field,
const String& header,
const real time = DUMMY,
const int component = 1,
const int maxcomponent = 1
);
int writeField // version without header or description
(
Field& field,
const real time = DUMMY,
const int component = 1,
const int maxcomponent = 1
);
};
DESCRIPTION
This class is a low-level tool mainly used from classes SimRes
File or SaveSimRes.
The storage format is binary or ASCII. In binary mode we try to
use the hardware-independent xdr format if possible (on some sys
tems, problems might arise with xdr and then the FieldReader and
FieldWriter classes can be compiled using a straight (binary) C
file - see the .cpp file for how you can steer the compilation in
case there are problems with the xdr format in Is_xdr and
Os_xdr.)
MEMBER FUNCTIONS
setDatasetName - Sets the name of the dataset. When a dataset is
already open, it will be closed and the FieldWriter object will
connect to the new dataset instead. If the new dataset is already
existing, the append flag determines whether is will be overwrit
ten or appended to.
setStorageMode - Sets the storage mode for the grids and fields.
writeField - Stores a specified field to the dataset. A header
and a time stamp must be specified. An optional description can
also be given. The component number and the total number of com
ponents (maxcomponent) must be specified when storing components
of a vector field, otherwise the default values can be used.
EXAMPLES
See the information given in FieldReader.h.
SEE ALSO
Visualisering av skalar- og vektor-felt by Fred Ivar Larsen,
1997. (Thesis for the Cand.Scient. degree)
"Visualizing Scalar and Vector Fields in Diffpack Hans Petter
Langtangen / Fred Ivar Larsen
DEVELOPED BY
SINTEF Applied Mathematics, Oslo, Norway, and University of Oslo,
Dept. of Mathematics, Norway
AUTHOR
Fred Ivar Larsen, UiO