Package esys :: Package escript :: Module datamanager :: Class DataManager
[hide private]
[frames] | no frames]

Class DataManager

object --+
         |
        DataManager

Escript data import/export manager.

Example:

dm=DataManager(formats=[DataManager.RESTART,DataManager.VTK])
if dm.hasData():
    dom = dm.getDomain()
    time = dm.getValue("time")
    dt = dm.getValue("dt")
    T = dm.getValue("T")
    u = dm.getValue("u")
else:
    T = ...
    u = ...
dm.addData(time=time,dt=dt,T=T,u=u) # add data and variables
dm.setTime(time)                    # set the simulation timestamp
dm.export()                         # write out data
Instance Methods [hide private]
 
__clearData(self)
 
__createDataset(self)
 
__getDumpFilename(self, data_name, dir_name)
 
__getStampFilename(self, dir_name)
 
__initVisit(self, simFile, comment='')
Initialises the VisIt interface if available.
 
__init__(self, formats=[0], work_dir='.', restart_prefix='restart', do_restart=True)
Initialises the data manager.
 
__loadState(self)
 
__removeDirectory(self, path)
 
__saveState(self)
 
addData(self, **data)
Adds 'escript.Data' objects and other data to be exported to this manager.
 
export(self)
Executes the actual data export.
 
getCycle(self)
Returns the export cycle (=number of times export() has been called)
 
getDomain(self)
Returns the domain as recovered from restart files.
 
getValue(self, value_name)
Returns an 'escript.Data' object or other value that has been loaded from restart files.
 
hasData(self)
Returns True if the manager holds data for restart
 
setCheckpointFrequency(self, freq)
Sets the number of calls to export() before new restart files are generated.
 
setDomain(self, domain)
Sets the domain without adding data.
 
setMeshLabels(self, x, y, z='')
Sets labels for the mesh axes.
 
setMeshUnits(self, x, y, z='')
Sets units for the mesh axes.
 
setMetadataSchemaString(self, schema, metadata='')
Sets metadata namespaces and the corresponding metadata.
 
setTime(self, time)
Sets the simulation timestamp.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  RESTART = 0
  SILO = 1
  VISIT = 2
  VTK = 3
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__initVisit(self, simFile, comment='')

 
Initialises the VisIt interface if available.
Parameters:
  • simFile - Name of the sim file to be generated which can be loaded into a VisIt client
  • comment - A short description of this simulation

__init__(self, formats=[0], work_dir='.', restart_prefix='restart', do_restart=True)
(Constructor)

 
Initialises the data manager. If do_restart is True and a restart directory is found the contained data is loaded (hasData() returns True) otherwise restart directories are removed (hasData() returns False). Values are only written to disk when export() is called.
Parameters:
  • formats - A list of export file formats to use. Allowed values are RESTART, SILO, VISIT, VTK.
  • work_dir - top-level directory where files are exported to
  • restart_prefix - prefix for restart directories. Will be used to load restart files (if do_restart is True) and store new restart files (if RESTART is used)
  • do_restart - whether to attempt to load restart files
Overrides: object.__init__

addData(self, **data)

 
Adds 'escript.Data' objects and other data to be exported to this manager.

Note: This method does not make copies of Data objects so any modifications will be carried over until export() is called.

export(self)

 
Executes the actual data export. Depending on the formats parameter used in the constructor all data added by addData() is written to disk (RESTART,SILO,VTK) or made available through the VisIt simulation interface (VISIT).

setMeshLabels(self, x, y, z='')

 
Sets labels for the mesh axes. These are currently only used by the Silo exporter.

setMeshUnits(self, x, y, z='')

 
Sets units for the mesh axes. These are currently only used by the Silo exporter.

setMetadataSchemaString(self, schema, metadata='')

 
Sets metadata namespaces and the corresponding metadata. Only used for the VTK file format at the moment.
Parameters:
  • schema - A dictionary that maps namespace prefixes to namespace names, e.g. {'gml':'http://www.opengis.net/gml'}
  • metadata - The actual metadata string which will be enclosed in '<MetaData>' tags.