The Open FUSION Toolkit 1.0.0-8905cc5
Modeling tools for plasma and fusion research and engineering
|
User and program I/O in the Open FUSION Toolkit (OFT) is supported by the use of native FORTRAN input/output routines as well as the HDF5 library. General input and output operations fall into one of three catagories:
OFT includes subroutines and supporting infrastructure to export plot files for the VisIt visualization package. During a run subroutines are used to output the plotting mesh hdf5_mesh, add time steps hdf5_create_timestep, and output solution fields ex. hdf5_spdata. Mesh and field information created during these calls are stored in *.h5
files in the run directory along with a text file dump.dat
which contains metadata describing the fields. After a run has completed the script build_xdmf.py
can be used to build XML descriptor files which can be read by VisIt to produce visualization.
Plotting fields are represented using a Lagrange representation for the fields. A "plotting" mesh is generated by hdf5_mesh, which is produced by tessellating the high order node points into a collection of linear tetrahedra. Fields can be output using the routines hdf5_spdata and hdf5_vpdata for scalar and vector data respectively.
Restart files are handled in a different manner than plotting files, as it is desirable to save fields in their native format. A single common restart file is created for the entire mesh and written to using calls to the parallel HDF5 library. Fields are saved by first converting the native vector representation to a restart structure using vector_slice_push and then writing the data using hdf5_rst_write. Additional scalar values may also be added to the restart files using the hdf5_rst_write_scalar subroutine.
To read in fields from a restart file a similar process is used. The restart structure must first be created using a call to vector_slice_push with the destination vector. A call to hdf5_rst_read may then be used to read the field from the desired data file. The field is the retrieved from the restart structure using vector_slice_pop. Additional scalar values may also be read using hdf5_rst_read_scalar.
Small I/O should be conducted using the native READ/WRITE routines provided within FORTRAN. If formatted time series or similar data is being output, as with history files in xMHD, OFT includes a Python module oft_io
to aide in structured output. This module parses FORTRAN binary files with a specific structure to facilitate plotting and transfer to MATLAB. In order to use this library files must be structured with a set of header lines, followed by a sequence of data lines. An example is provided below.
For the example above the header lines will contain the following. Binary data starts after the --- BEGIN DATA ---
marker and can be read using the oft_io
python module.
# OFT binary output # Description: Example history file # Created: XX:XX:XX on X-XX-20XX # # Comments: # Test comment nfields: 4 fields: ts time tflux tcurr field_types: i4 r4 r4 r4 field_sizes: 1 1 1 1 descriptions: - ts: Time step index - time: Simulation time [s] - tflux: Toroidal flux [Wb] - tcurr: Toroidal current [A*mu0] --- BEGIN DATA ---