OVF2VTK: Tool for conversion of OOMMF to VTK files¶
- authors:
Hans Fangohr, Richard Boardman
What’s new?¶
September 2020: this package is not maintained any longer. The functionality to convert OMF and OVF files from OOMMF to VTK files is now provided by the discretisedfield Python package. In particular, see https://discretisedfield.readthedocs.io/en/latest/ipynb/12-tutorial-ovf2vtk.html
If you work with OMF and OVF files (from OOMMF, Ubermag, or Mumax3, say), then you may be interested in the discretisedfield package and documentation more generally as it allows modification, analysis and plotting of such field objects in Python and Jupyter notebooks.
The logo of the Condensed Matter and Materials Physics conference 2009 has been created using OVF2VTK.
0.1.23 (20 February 2009) (requires numpy)
new switch “–posscale”
new switch “–datascale”
Taking name of data set from omf file (nice for plotting demag fields etc)
Bugfix: 0.1.21 needed numpy and Numeric to work. This version only needs numpy.
0.1.21 (12 April 2006) (requires numpy)
For this release, we have made the transition from Numeric to numpy for fast vector and matrix processing.
0.1.17 (14 July 2005) (requires Numeric)
First release.
Introduction¶
ovf2vtk – data conversion from OOMMF’s omf/ovf file format to VTK.
This program
reads ovf files keeping vector data from the OOMMF simulation package,
extracts the data,
optionally adds derived observables (mainly curl and divergence) and
saves the input data and any derived entities into VTK files.
Supported file formats are:
Input files: ovf files(v1.0), rectangular mesh only, data can be ascii, binary4 or binary 8
Output files: VTK File Formats Standard 2.0. (This depends on PyVTK.), binary and ascii
Software_Requirements¶
Download¶
Snapshots of releases (rpm>, source files, windows installer)
Installation¶
Unix/Linux¶
make sure you have the Software_Requirements libraries (Python, Numeric,PyVTK) installed.
Either:
Install the rpm file by running
“rpm -U ovf2vtk-0.x.x-x.noarch.rpm”.
This is the recommended option as it allows easy de-installation of the package (using “rpm -e ovf2vtk”).
Or
Install ovf2vtk from source:
untar the distribution file: “tar xfvz ovf2vtk-0.x.x.tar.gz”
cd into the new directory: “cd ovf2vtk”
install files: “python setup.py install”
If you can’t write to the site-packages directory on your machine (due to missing permissions), you can install the packages somewhere else using the
--rootswitch (python setup.py install --root /home/myhome/local).If you do this, you need to let Python know that it should search for packages in that directory. This is achieved by setting the PYTHONPATH, for example:
export PYTHONPATH=$PYTHONPATH:/home/myhome/local/usr/lib/python2.4/site-packages
before you call the executable (which you should find in “/home/myhome/local/usr/bin/”).
Windows¶
If you don’t have Python installed, the easiest way is to
download and install the Enthought Python distribution. This will do several things:
install Python
install numpy
add the python interpreter to the search path (usually in C:Python25) [This might only happen if you install Enthought Python as the administrator].
add the ‘script directory’ to the search path (usually in C:Python25Scripts) [This might only happen if you install Enthought Python as the administrator]
This will also install MayaVi which you might want to use to display the vtk files.
After you have installed Enthought Python, you should be able to open a Command Prompt and start the Python interpreter by typing “python”. You should see something like this:
C:>python Enthought Edition build 1057 Python 2.3.3 (#51, FGeb 16 2004, ...) ...
Press CTRL-Z and Return to exit this.
Install PyVTK
This involves to download the source, unpack it, change directory into the source directory, execute “python.exe setup.py install”.
Download the ovf2vtk windows installer and double click on it.
If you have Python installed already, make sure you have numpy, PyVTK and run the Windows installer for ovf2vtk.
MacOS X¶
Make sure you have python on the system (Fink can provide this.
Install pyvtk (Fink provides this package)
Install numpy (can use Fink)
Install ovf2vtk from the source file (see installation instructions for Unix/Linux)
Enthought Python is now also available for Mac OS X, so in principle this can be used to provide python and numpy. It should be possible to install Pyvtk and ovf2vtk after having installed Enthought Python (but this is untested).
Uninstalling ovf2vtk¶
Linux: if you have installed the rpm, just run “rpm -e ovf2vtk”
Windows: go to add/remove software, select ovf2vtk
If you have installed from source (all platforms):
remove the ovf2vtk directory below ‘site-packages’ of your python distribution
remove the ‘ovf2vtk’ and ‘winovf2vtk.py’ files from whereever they have been placed:
on windows usually c:Python25Scripts
on linux ‘/usr/local/bin’, or ‘/usr/bin’
on Mac OS (with Fink): /sw/bin
Usage¶
ovf2vtk is a command line driven program:
linux/unix/Mac OS: open a shell
windows: open a command prompt
It should be possible to call the program by typing “ovf2vtk” or (on windows) “winovf2vtk.py” in that shell. Just pressing return should produce an output starting like this:
---------------------------------------------------------------------------- ovf2vtk: convert OOMMF vector-field file into vtk-vector field file SYNTAX: ovf2vtk [OPTIONS] infile outfile ...
run
ovf2tvk --helpto see all options. (On windows, runwinovf2vtk.py --help)
Example¶
Download this omf file and save it to a local directory
Convert the data into a vtk file by issueing this command:
ovf2vtk --add all cantedvortex.omf cantedvortex.vtk
On windows, run:
winovf2vtk.py --add all cantedvortex.omf cantedvortex.vtk
This should produce a file with name “cantedvortex.vtk”.
This example file is included in the “Demo” subdirectory in the source file distribution.
Visualisation¶
Okay, with ovf2vtk we can convert omf and ovf files produced with OOMMF into vtk files. What do I do with these vtk files to nicely present the data?
You have several options:
You can use the vtk library and write you own program to read and display the vtk files. (This is unsuitable for most users as it requires detailed knowledge of vtk.)
You can use one of the high level graphical interfaces that can be used to display vtk files (more easily). Some of the packages that read and display vtk files are:
-
Here is a MayaVi file cantedvortex.mv (that contains the information how to display the vtk file, and can be loaded by MayaVi).
Here is a screenshot taken in MayaVi (full size png):
Paraview (http://www.paraview.org/)
-
License¶
OVF2VTK is released under the GNU GPL (see http://www.fsf.org).
The software is free (and open source, distributed under GPL).
FAQ¶
How can I process more than one file?¶
OVF2VTK can only process one file at the time. However, the required functionality is usually provided by the operating system/tools.
Using the bash shell (i.e. on Linux, Mac OS X, Cygwin bash terminal on Windows), this for-loop:
for filename in *.omf; do ovf2vtk --add all $filename ${filename%.omf}.vtk; done
will go through all files with ending .omf in the current directory, and call ovf2vtk to convert them to vtk files. The slightly cryptic ${filename%.omf}.vtk will remove .omf from the filename that is stored in the variable $filename, and append .vtk.
OVF2VTK cannot read my ovf files¶
If you get the following error (this will be followed by more Traceback information, so look at the first few lines of the error message), you are likely to be trying to read the new OVF2.0 file format (instead of the pre-2010 ovf1.0 format):
$ ovf2vtk --add all sandwich-Oxs_TimeDriver-Magnetization-00-0001097.omf test.vtk
----------------------------------------------------------------------
ovf2vtk --- converting ovf files to vtk files
Hans Fangohr, Richard Boardman, University of Southampton
----------------------------------------------------------------------
The first item in a binary file is meant to be 123456789012345.0
but it is not. Instead, I read 31198.0488937 .
Cowardly stopping here.
In the long run, we will try to extend ovf2vtk so that it can read the new ovf2.0 file format. Until then, you can convert any ovf2.0 formatted data file (with name ‘oldfile’) into ovf1.0 formatted file (with name ‘newfile’) using this command:
oommf.tcl avf2ovf -format b8 oldfile newfile
It appears that one can also use the ‘b4’ switch rather than ‘b8’ to reduce diskspace usage (using only 4 byte per floating point number rather than 8).
Feedback & Bugs¶
Please report any bugs, feedback and improvements to Hans Fangohr <fangohr@soton.ac.uk>
$Revision: 853cfd938810 $