esys.escript.datamanager Package

Classes

class esys.escript.datamanager.DataManager(formats=[0], work_dir='.', restart_prefix='restart', do_restart=True)

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
__init__(formats=[0], work_dir='.', restart_prefix='restart', do_restart=True)

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

RESTART = 0
SILO = 1
VISIT = 2
VTK = 3
addData(**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()

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).

getCycle()

Returns the export cycle (=number of times export() has been called).

Returns:

the current export cycle number

Return type:

int

getDomain()

Returns the domain as recovered from restart files.

Returns:

the domain loaded from restart files

Return type:

Domain

Raises:

ValueError – if no restart data is available

getValue(value_name)

Returns an ‘escript.Data’ object or other value that has been loaded from restart files.

Parameters:

value_name (str) – name of the value to retrieve

Returns:

the requested data object or value

Return type:

Data or other type depending on what was stored

Raises:

ValueError – if no restart data is available

hasData()

Returns True if the manager holds data for restart.

Returns:

True if restart data is available, False otherwise

Return type:

bool

setCheckpointFrequency(freq)

Sets the number of calls to export() before new restart files are generated.

Parameters:

freq (int) – checkpoint frequency (1 = every export, 2 = every other, etc.)

setDomain(domain)

Sets the domain without adding data.

Parameters:

domain (Domain) – the escript domain to set

Raises:

ValueError – if a different domain has already been set

setMeshLabels(x, y, z='')

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

Parameters:
  • x (str) – label for the x-axis

  • y (str) – label for the y-axis

  • z (str) – label for the z-axis (optional for 2D)

setMeshUnits(x, y, z='')

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

Parameters:
  • x (str) – unit for the x-axis

  • y (str) – unit for the y-axis

  • z (str) – unit for the z-axis (optional for 2D)

setMetadataSchemaString(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.

setTime(time)

Sets the simulation timestamp.

Parameters:

time (float) – the current simulation time

Functions

Others

Packages