# esys.escript.datamanager Package

## Classes

- `DataManager`

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

  Bases: `object`

  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)

  `getDomain`()

    Returns the domain as recovered from restart files.

  `getValue`(value_name)

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

  `hasData`()

    Returns True if the manager holds data for restart

  `setCheckpointFrequency`(freq)

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

  `setDomain`(domain)

    Sets the domain without adding data.

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

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

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

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

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

## Functions

## Others

## Packages