Skip to main content

simulation_writer

SimulationWriter

The SimulationWriter is the writer object for a single simulation. It inherits all reading methods from :class:`Simulation`.

SimulationWriter (
uid: str,
path: str,
comm: mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>
)
Parameters:
  • uid : <class 'str'>

    The identifier of the simulation

  • path : <class 'str'>

    The (parent) database path

  • comm : <class 'mpi4py.MPI.Comm'>

    An MPI communicator (Default: `MPI.COMM_WORLD`)

Variables:
  • step : : int

initialize

initialize (self) -> bamboost.simulation_writer.SimulationWriter

Create a new file for this simlation. This deletes an existing h5 file of the simulation and creates an empty new one

Parameters:
  • self : Any

add_metadata

add_metadata (self) -> None

Add metadata to h5 file.

Parameters:
  • self : Any

Returns:
    None

add_parameters

add_parameters (self, parameters: dict) -> None

Add parameters to simulation.

Parameters:
  • self : Any

  • parameters : <class 'dict'>

    Dictionary with parameters.

Returns:
    None

add_mesh

add_mesh (
self,
coordinates: numpy.ndarray,
connectivity: numpy.ndarray,
mesh_name: str = None
) -> None

Add the mesh to file. Currently only 2d meshes.

Parameters:
  • self : Any

  • coordinates : <class 'numpy.ndarray'>

    Coordinates as array (nb_nodes, dim)

  • connectivity : <class 'numpy.ndarray'>

    Connectivity matrix (nb_cells, nb nodes per cell)

  • mesh_name : <class 'str'>

    name for mesh (default = `mesh`)

Returns:
    None

add_field

add_field (
self,
name: str,
vector: <built-in function array>,
time: float = None,
mesh: str = None,
dtype: str = None
) -> None

Add a dataset to the file. The data is stored at `data/`.

Parameters:
  • self : Any

  • name : <class 'str'>

    Name for the dataset

  • vector : <built-in function array>

    Dataset

  • time : <class 'float'>

    Optional. time

  • mesh : <class 'str'>

    Optional. Linked mesh for this data

  • dtype : <class 'str'>

    Optional. Numpy style datatype, see h5py documentation, defaults to the dtype of

Returns:
    None

add_global_field

add_global_field (self, name: str, value: Union[float, int], dtype: str = None) -> None

Add a gobal field. These are stored at `globals/` as an array in a single dataset.

Parameters:
  • self : Any

  • name : <class 'str'>

    Name for the data

  • value : typing.Union[float, int]

    Data

  • dtype : <class 'str'>

Returns:
    None

add_additional

add_additional (self, name: str, file: str) -> None

Add an additional file stored elsewhere or in database directory.

Parameters:
  • self : Any

  • name : <class 'str'>

    Name of data

  • file : <class 'str'>

    filename of file

Returns:
    None

finish_step

finish_step (self) -> None

Finish step. Adds 1 to the step counter.

Parameters:
  • self : Any

Returns:
    None

finish_sim

finish_sim (self, status: str = 'Finished') -> None

None

Parameters:
  • self : Any

  • status : <class 'str'>

Returns:
    None

register_git_attributes

register_git_attributes (self, repo_path: str = './') -> None

Register git information for given repo.

Parameters:
  • self : Any

  • repo_path : <class 'str'>

    path to git repository

Returns:
    None

copy_executable

copy_executable (self, script_path: str) -> None

WILL BE REMOVED. USE COPY_FILE. Copy an executable to directory for reproducability.

Parameters:
  • self : Any

  • script_path : <class 'str'>

    path to script

Returns:
    None

copy_file

copy_file (self, source: Union[str, list], destination: str = '') -> None

Copy a file to the datafolder.

Parameters:
  • self : Any

  • source : typing.Union[str, list]

    path to file, or list of files

  • destination : <class 'str'>

    destination (will create intermediatory directories)

Returns:
    None