Diffpack Documentation


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

SaveSimRes Class Reference

convenient interface to visualization in a simulator. More...

#include <SaveSimRes.h>

Inheritance diagram for SaveSimRes::

HandleId List of all members.

Public Methods

 SaveSimRes ()
 ~SaveSimRes ()
void forcePlotting (bool onoff)
void beVerbose (bool onoff)
void open (const String &dataset_name, bool hide_map_files=true)
void setStorageMode (Format_type field_format, Format_type grid_format)
bool noPlot4thisTimeLevel (const TimePrm *tip=NULL)
void dump (FieldFV &f, const TimePrm *tip=NULL, const char *additional_comment=NULL, const char *fieldname=NULL)
void dump (FieldsFV &f, const TimePrm *tip=NULL, const char *additional_comment=NULL, const char *fieldname=NULL)
void dump (FieldFE &f, const TimePrm *tip=NULL, const char *additional_comment=NULL, const char *fieldname=NULL)
void dump (FieldsFE &f, const TimePrm *tip=NULL, const char *additional_comment=NULL, const char *fieldname=NULL)
void dump (FieldPiWisConst &f, const TimePrm *tip=NULL, const char *additional_comment=NULL, const char *fieldname=NULL)
void dump (FieldsPiWisConst &f, const TimePrm *tip=NULL, const char *additional_comment=NULL, const char *fieldname=NULL)
void dump (FieldLattice &f, const TimePrm *tip=NULL, const char *additional_comment=NULL, const char *fieldname=NULL)
void dump (FieldsLattice &f, const TimePrm *tip=NULL, const char *additional_comment=NULL, const char *fieldname=NULL)
void dump (FieldWithPtValues &f, const TimePrm *tip=NULL, const char *additional_comment=NULL, const char *fieldname=NULL)
void dump (FieldsWithPtValues &f, const TimePrm *tip=NULL, const char *additional_comment=NULL, const char *fieldname=NULL)
void dumpMaterials (const GridFE &grid)
void lineCurves (Field &f, const TimePrm *tip=NULL, const char *comment=NULL, const char *curvename_comment=NULL, const char *fieldname=NULL)
bool linesDefined () const
bool line1Defined () const
bool line2Defined () const
bool line3Defined () const
void lineCurve (FieldFV &f, const String &from, const String &to, const TimePrm *tip)
void lineCurve (FieldFE &f, const String &from, const String &to, const TimePrm *tip)
void curve (FieldFE &f, const TimePrm *tip=NULL, const char *additional_comment=NULL, const char *curvename_comment=NULL)
void initTimeSeriesPlot (Field &f, const char *additional_comment=NULL, const char *curvename_comment=NULL, const char *fieldname=NULL)
void add2TimeSeriesPlot (Field &f, const TimePrm &tip)
void finishTimeSeriesPlot ()
void define (MenuSystem &menu, int level=MAIN)
void scan (MenuSystem &menu, int nsd, bool menu_prefix_in_dataset_name=false, bool hide_map_files=true)
bool ok () const

Static Public Methods

void defineStatic (MenuSystem &menu, int level=MAIN)

Public Attributes

SimResFile resfile
CurvePlotFile cplotfile
SetOfNo(real) time_points_for_plot
VecSimplest(CurvePlottimeseries_curve
GridScatPt timeseries_points
Ptv(real) line1_start
Ptv(real) line1_stop
Ptv(real) line2_start
Ptv(real) line2_stop
Ptv(real) line3_start
Ptv(real) line3_stop
int line1_resol
int line2_resol
int line3_resol

Protected Methods

void checkFieldname (const String &name)
void bigdata (int size)

Protected Attributes

bool force_plotting
bool dump_all_time_levels
bool verbose_dump

Detailed Description

convenient interface to visualization in a simulator.

NAME: SaveSimRes - convenient interface to visualization in a simulator

DESCRIPTION:

The class offers a simplified and flexible interface to tools for storing fields and curve data on file for later visualization. Instead of using "CurvePlotFile" and "SimResFile" objects directly, the programmer of a simulator is encouraged to use class "SaveSimRes" because of significantly less programming effort. Various storage/plotting features that will be developed in the future will also be automatically available from class "SaveSimRes" (direct use of "CurvePlot"/"CurvePlotFile" or "SimResFile" will most probably involve modifications of the simulator to take advantage of new features).

We assume that there is a simulator class "Sim". To use "SaveSimRes", class "Sim" should have a handle to a "SaveSimRes" object. One such object can be shared by several simulator in a simulator environment.

The "SaveSimRes" class has a menu part that enables the user to control the frequency of data storage, define cross section lines for curve plot of fields and define spatial points where the field values can be plotted as functions of time.

Through the "SaveSimRes" object, the simulator class has access to a "CurvePlotFile" object (which makes it easy to define curves, in terms of "CurvePlot" objects linked to the "CurvePlotFile" manager, everywhere in the simulator) and a "SimResFile" object (which makes it easy to manipulate data in the SimRes format).


Constructor & Destructor Documentation

SaveSimRes::SaveSimRes ( )
 

There is one constructor without arguments. For complete initialization, the data files ("cplotfile" and "resfile") must be opened. This is performed by the "open" function. However, "scan" automatically calls "open" (i.e. "scan" initializes the object completely in accordance with the Diffpack standard). All the "dump", "lineCurves" functions etc also call "open" if necessary so the user of the class does not need to worry about initialization. (As usual in Diffpack, we recommend that simulators use the menu system and call "SaveSimRes scan", but this is not required.)

SaveSimRes::~SaveSimRes ( )
 


Member Function Documentation

void SaveSimRes::add2TimeSeriesPlot ( Field & f,
const TimePrm & tip )
 

dumps the field values at various spatial points (at the current time level).

void SaveSimRes::beVerbose ( bool onoff ) [inline]
 

sets the local verbose mode on and off (not to be confused with the global variable "verbose"!). In verbose mode, a message is written to the screen each time field data are dumped to file (or more precisely, to the "SimResFile resfile" data member). The verbose mode can also be set on the menu.

void SaveSimRes::bigdata ( int size ) [protected]
 

void SaveSimRes::checkFieldname ( const String & name ) [protected]
 

void SaveSimRes::curve ( FieldFE & f,
const TimePrm * tip = NULL,
const char * additional_comment = NULL,
const char * curvename_comment = NULL )
 

dumps a field in curve plot format, that is, to a "CurvePlot" object. The field can then easily be plotted by simple curve plotting programs. The general use of this function is limited. However, it is convenient when making animation of 2D fields using "gnuplot". We refer to the "ConvDiffFEM saveResults()" and "WaveEq::saveResults()" functions for examples on how "curve" is used to make field animations in "gnuplot". Note that the examples we refer to may generate a very large number of files. We recommend not to call "curve" unless you really need the old-fashioned "gnuplot" movie feature... The "curve" function calls "SimRes2gnuplot makeCurvePlot", which performs the plotting by dumping the field values at the nodal poinst. The function will only work for fields over isoparametric elements.

void SaveSimRes::define ( MenuSystem & menu,
int level = MAIN ) [inline]
 

void SaveSimRes::defineStatic ( MenuSystem & menu,
int level = MAIN ) [static]
 

void SaveSimRes::dump ( FieldsWithPtValues & f,
const TimePrm * tip = NULL,
const char * additional_comment = NULL,
const char * fieldname = NULL )
 

See documentation of one of the overloaded functions.

void SaveSimRes::dump ( FieldWithPtValues & f,
const TimePrm * tip = NULL,
const char * additional_comment = NULL,
const char * fieldname = NULL )
 

See documentation of one of the overloaded functions.

void SaveSimRes::dump ( FieldsLattice & f,
const TimePrm * tip = NULL,
const char * additional_comment = NULL,
const char * fieldname = NULL )
 

See documentation of one of the overloaded functions.

void SaveSimRes::dump ( FieldLattice & f,
const TimePrm * tip = NULL,
const char * additional_comment = NULL,
const char * fieldname = NULL )
 

See documentation of one of the overloaded functions.

void SaveSimRes::dump ( FieldsPiWisConst & f,
const TimePrm * tip = NULL,
const char * additional_comment = NULL,
const char * fieldname = NULL )
 

See documentation of one of the overloaded functions.

void SaveSimRes::dump ( FieldPiWisConst & f,
const TimePrm * tip = NULL,
const char * additional_comment = NULL,
const char * fieldname = NULL )
 

See documentation of one of the overloaded functions.

void SaveSimRes::dump ( FieldsFE & f,
const TimePrm * tip = NULL,
const char * additional_comment = NULL,
const char * fieldname = NULL )
 

See documentation of one of the overloaded functions.

void SaveSimRes::dump ( FieldFE & f,
const TimePrm * tip = NULL,
const char * additional_comment = NULL,
const char * fieldname = NULL )
 

See documentation of one of the overloaded functions.

void SaveSimRes::dump ( FieldsFV & f,
const TimePrm * tip = NULL,
const char * additional_comment = NULL,
const char * fieldname = NULL )
 

See documentation of one of the overloaded functions.

void SaveSimRes::dump ( FieldFV & f,
const TimePrm * tip = NULL,
const char * additional_comment = NULL,
const char * fieldname = NULL )
 

dumps fields to file (represented by the "SimResFile" data member) using the SimRes format. Various overloaded versions support dumping of various field types. In time dependent problems, the user gives a "TimePrm" object as argument, and fields are dumped only if the current time level is found in the "time_points_for_plot" set. This set is usually initialized on the menu. The syntax follows "SetOfNo scan", hence it is trivial to list time points as well as compact loops of time points. If the user has not initialized the time points for plot on the menu, "dump" will always dump the field. In stationary problems, the "TimePrm" object can be omitted, and the field will be dumped anyway. An additional comment, e.g. including numerical parameters from the simulation, can also be given if desired. The "fieldname" parameter is optional. By default, the "dump" functions apply the fieldname given by the "getFieldname" function in class "Field". Sometimes one wants to distinguish fields dumped from the same field object and then the "fieldname" argument is advantageous (an example is various realizations or intermediate estimated solutions in stochastic simulations - these have the same name and the same time parameter, but may be plotted separately, or distinguished, from other fields produced by the same object).

Notice that "SaveSimRes" applies class "SimResFile" which again applies class "FieldWriter" for storage of fields. In class "FieldWriter" all fields are written using an "Os" object. This "Os" object can use an "Os_xdr" (xdr formatted file) or an "Os_ofstream" (standard C++ file) for storing grids and fields (this is determined in "FieldWriter.cpp" and "FieldReader.cpp"). The "FieldReader" object that reads the grids and fields written by "FieldWriter" will automatically detect the right file type and format. If the "Os_xdr" tool is used for writing in "FieldWriter", binary data will be in xdr format and the files can be exchanged between different hardware platforms. (When the dumped fields are filtered to specific plotting program dependent formats, the filter program is responsible for choosing the xdr format or the local host binary format).

void SaveSimRes::dumpMaterials ( const GridFE & grid )
 

plot a piecewise constant field over the different materials in the domain. The value of the field in a material equals the number of the material.

void SaveSimRes::finishTimeSeriesPlot ( )
 

to be called after all the time series are made by the "add2TimeSeriesPlot" function. Usually, "initTimeSeriesPlot" is called before a time integration loop is started. Inside the loop, one calls "add2TimeSeriesPlot" and after the loop one calls the "finishTimeSeriesPlot" function.

void SaveSimRes::forcePlotting ( bool onoff ) [inline]
 

force dumping of fields and curves even if the user has indicated on the menu that no dumping should be performed at the current time level. The function is often called prior to dumping of data for animation. To let the user given time points govern the dumping of data, call "forcePlotting" with "false" as argument.

void SaveSimRes::initTimeSeriesPlot ( Field & f,
const char * additional_comment = NULL,
const char * curvename_comment = NULL,
const char * fieldname = NULL )
 

initializes dumping of curves for time series of a single field at various spatial points. See the functions above for documentation of the arguments. For later plotting of the time series using regular expressions to specify the curves (f.ex. when applying tools like "Gnuplot" or "Xmgr") one must know the plot title, curvename and the comment made by "initTimeSeriesPlot". The title is ``Time series at selected points'', the curvenames (recall that there is one curve for each spatial point) are on the form XYZ where X is the name of the field (given by "f" or explicitly by the "fieldname" argument), Y is the spatial point where the field is evaluated and Z is the optional curvename comment that can be given as argument to the function.

bool SaveSimRes::line1Defined ( ) const
 

bool SaveSimRes::line2Defined ( ) const
 

bool SaveSimRes::line3Defined ( ) const
 

void SaveSimRes::lineCurve ( FieldFE & f,
const String & from,
const String & to,
const TimePrm * tip )
 

See documentation of one of the overloaded functions.

void SaveSimRes::lineCurve ( FieldFV & f,
const String & from,
const String & to,
const TimePrm * tip )
 

has the same functionality as "lineCurves" except that the programmer defines the curve by giving its start ("from" string) and end ("to" string) points. The field is plotted along this single curve only.

void SaveSimRes::lineCurves ( Field & f,
const TimePrm * tip = NULL,
const char * comment = NULL,
const char * curvename_comment = NULL,
const char * fieldname = NULL )
 

calculates the variation of a field along three curves and dumps the curve data to file (the "CurvePlot"/"CurvePlotFile" data memebers). The definition of the three curves is given on the menu. One, two or all three curves can be undefined if desired. The default state is that all curves are undefined (in which case "lineCurves" has no effect). The evaluation of the field along the curves is performed by the Diffpack function "makeCurvePlotAlongLine". In time dependent problems, the user gives a "TimePrm" object as argument. In stationary problems, this object can be omitted. An optional "fieldname" argument can be used (see documentation of "dump"). For later plotting of the curves using regular expressions to specify the curves (f.ex. when applying tools like "Gnuplot" or "Xmgr") one must know the plot title, curvename and the comment made by "lineCurves". The title is ``Cross Section Plot, X to Y'', where X is the starting point and Y is end point (X and Y are available as the "line*_start" and "line*_stop" point in "SaveSimRes"), the curvename is on the form X(Y)Z where X is the fieldname (given by "f" or explicitly by the "fieldname" argument), Y denotes a coordinate along the curve and is on the form "s1" for the first line, "s2" for the second line and so on, while Z is the optional curvename comment that can be given as argument to the function. The comment is on the form "line1: X", where X is the user supplied function (for the other line curves "line1" is of course substituted by "line2", "line3").

bool SaveSimRes::linesDefined ( ) const
 

bool SaveSimRes::noPlot4thisTimeLevel ( const TimePrm * tip = NULL )
 

returns a false value if plots are going to be made at this time level. The "time_points_for_plot" set, usually read by "scan" from a menu, determines the time levels for which fields and curves are dumped. The "dump", "lineCurves" etc. functions calls "noPlot4thisTimeLevel" prior to any attempt to dump the data. In a simulator class, which is usually a subclass of "SaveSimRes", the programmer can easily use "noPlot4thisTimeLevel" to test if plots should be dumped or not. Look at the source code for a complete documentation of the function. Roughly speaking, "noPlot4thisTimeLevel" returns false in stationary problems or if the current time level is found in "time_points_for_plot".

bool SaveSimRes::ok ( ) const
 

returns a true value if the data files used by the class are opened (more precisely, only the filenames must be given). "ok" will return a true value after "scan" is performed. If "ok" is false, fields and curves can still be dumped, because all the storage functions first set the object in an ok state.

void SaveSimRes::open ( const String & dataset_name,
bool hide_map_files = true )
 

opens the output files (or more precisely, sets the stem of the filenames that are to be used for output). The function "scan" automatically calls "open" and uses the casename as a stem for output files. Also the "dump", lineCurves" etc functions call "open" if necessary so the user does not need to call "open" unless another stem for the filenames is desired.

When storing data in multiple executions under the menu system, it is advantageous to have a filestem specific for each execution (using f.ex. "casename"). In these cases we recommend to either call "SaveSimRes scan" in the "scan" function of the simulator class (which then leads to using casename as stem in the generated files) or to call "SaveSimRes open" explicitly for each execution in the loop. (The latter approach enables construction of filenames that reflect some important parameters of the current multiple loop execution.)

To see the current dataset name, call "resfile.getDatasetName()".

The final argument, "hide_map_files", is true if one desires (or not) a dot as the first character in the name of the map files generated by "CurvePlotFile" (by default the map file has name ".casename.curve.map" - with "hide_map_files" false, the name becomes "casename.curve.map").

void SaveSimRes::scan ( MenuSystem & menu,
int nsd,
bool menu_prefix_in_dataset_name = false,
bool hide_map_files = true )
 

standard Diffpack function for reading the menu answers and initializing the object. See also documentation of the "open" function. The third argument, "menu_prefix_in_dataset_name", can be used to control the storage of the dumped data when several "SaveSimRes" objects are used (e.g. when solving systems of PDEs by combining several existing simulator classes). By default, "scan" calls "open" with "casename" as dataset name. When the "menu_prefix_in_dataset_name" argument is true, the "open" call in "scan" constructs a dataset name consisting of "casename" and the menu prefix. Then different "SaveSimRes" objects will dump data to different files. To see the current dataset name, call "resfile.getDatasetName()". The final argument, "hide_map_files", is true if one desires a dot as the first character in the name of the map files generated by "CurvePlotFile" (by default the map file has name "casename.curve.map", with "hide_map_files" true, the name becomes ".casename.curve.map").

void SaveSimRes::setStorageMode ( Format_type field_format,
Format_type grid_format )
 

enables the user to set the file storage mode (ASCII or BINARY) for fields and grids.


Member Data Documentation

CurvePlotFile SaveSimRes::cplotfile
 

bool SaveSimRes::dump_all_time_levels [protected]
 

bool SaveSimRes::force_plotting [protected]
 

int SaveSimRes::line1_resol
 

Ptv(real) SaveSimRes::line1_start
 

Ptv(real) SaveSimRes::line1_stop
 

int SaveSimRes::line2_resol
 

Ptv(real) SaveSimRes::line2_start
 

Ptv(real) SaveSimRes::line2_stop
 

int SaveSimRes::line3_resol
 

Ptv(real) SaveSimRes::line3_start
 

Ptv(real) SaveSimRes::line3_stop
 

SimResFile SaveSimRes::resfile
 

SetOfNo(real) SaveSimRes::time_points_for_plot
 

VecSimplest(CurvePlot) SaveSimRes::timeseries_curve
 

GridScatPt SaveSimRes::timeseries_points
 

bool SaveSimRes::verbose_dump [protected]
 


The documentation for this class was generated from the following file:
Copyright © 2003 inuTech GmbH. All rights reserved.