dnami_io

This section gives an overview over the different I/O funtions of the dnami library.

The dnami I/O functions

The dnami_io file provides a set of functions to perform I/O operations.

src.src_py.dnami_io.dtMax(tree, a)

When running at constant CFL this function looks for the most constraining time step

Parameters:
  • tree – The dnami tree data structure

  • a – The array from which the most constraining time step is to be found, usually a field of point-by-point pre-computed dt’s derived from a preset CFL value

Returns:

The largest usable timestep which satisfies the CFL constraint everywhere in the domain

src.src_py.dnami_io.globalMax(tree, a, s)

Finds the global max of the passed array among all MPI processes.

Parameters:
  • tree – The dnami tree data structure

  • a – The array from which the max should be obtained

  • s – A character string which will be printed together with the max value

Returns:

This function returns nothing but prints the global max value of “a” with string tag “s” to the terminal

src.src_py.dnami_io.globalMinMax(tree, a, s)

Finds the global min and max of the passed array among all MPI processes.

Parameters:
  • tree – The dnami tree data structure

  • a – The array from which the min and max should be obtained

  • s – A character string which will be printed together with the min and max

Returns:

This function returns nothing but prints the global min/max values of “a” with string tag “s” to the terminal

src.src_py.dnami_io.hello_world(tree)

This function prints information about the case (e.g. grid size, number of processors, etc)

Parameters:

tree – the dnami tree

Returns:

This function returns nothing

src.src_py.dnami_io.read_data(tree, fields, fname='data.bin')

Reads the data file in order to read back in a custom data field. By default, it looks for the file ‘data.bin’ where the compute.py is located but a custom path can be used.

Parameters:
  • tree – The dnami tree data structure

  • fields – List of fields to fill using the ‘data.bin’ file

  • fname – The filename of the restart file

Returns:

This function returns the updated dNami tree

src.src_py.dnami_io.read_restart(tree, fname='restart.bin')

Reads the restart file in order to restart the simulation. By default, it looks for the file ‘restart.bin’ where the compute.py is located but a custom path can be used.

Parameters:
  • tree – The dnami tree data structure

  • fname – The filename of the restart file

Returns:

This function returns the updated dNami tree

src.src_py.dnami_io.set_dt(tree, dt)

Set the timestep value to use.

Parameters:
  • tree – The dnami tree data structure

  • dt – The dt value to be used

Returns:

This function returns nothing

src.src_py.dnami_io.write_data(field, n, t, tree, fpath='./out/', fname='output')

Write out a custom field that is not included in the restart file.

Parameters:
  • field – list of fields to write out e.g. [‘divV’, ‘p’] where the strings are the names of the predefined stored variables

  • n – The iteration count at which the data is written

  • t – The physical time of iteration n

  • tree – The dnami tree data structure

  • fpath – The output directory

  • fname – The output filename to which the iteration stamp n will be added

src.src_py.dnami_io.write_grid(tree, fpath='./out/')

This functions writes the axes to file in ‘./out’

Parameters:

tree – the dnami tree

Returns:

This function returns nothing

src.src_py.dnami_io.write_restart(n, t, flag, tree, fpath='./restarts/')

Writes the state of the solved variables (defined in the rhs.py) at timestep n and time ti to a binary file in order to restart for post-processing purposes. Can also be used to restart the simulation later.

Parameters:
  • n – The number of iterations the simulation was running

  • t – The timestep

  • flag – If set to 0 all boundary shells will be written (if any) in addition to the core to files in the fpath folder and the file names will be stamped with the iteration number. If set to 1 the core domain is written to ‘./out/liv/restart.bin’ (and overwritten) for users wanting to use the “live view” plotting tools which may be usefull when designing a new problem

  • fpath – The output directory of the restart file, the default is ‘./restarts/’