[cig-commits] r13228 - in short/3D/PyLith/trunk/pylith: . utils
brad at geodynamics.org
brad at geodynamics.org
Sun Nov 2 15:44:10 PST 2008
Author: brad
Date: 2008-11-02 15:44:10 -0800 (Sun, 02 Nov 2008)
New Revision: 13228
Added:
short/3D/PyLith/trunk/pylith/utils/VTKDataReader.py
Modified:
short/3D/PyLith/trunk/pylith/Makefile.am
Log:
Added VTKDataReader for using tvtk to read VTK data files to check output.
Modified: short/3D/PyLith/trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/pylith/Makefile.am 2008-11-02 23:42:35 UTC (rev 13227)
+++ short/3D/PyLith/trunk/pylith/Makefile.am 2008-11-02 23:44:10 UTC (rev 13228)
@@ -120,6 +120,7 @@
utils/EmptyBin.py \
utils/EventLogger.py \
utils/PetscManager.py \
+ utils/VTKDataReader.py \
utils/importing.py \
utils/profiling.py \
utils/testarray.py
Added: short/3D/PyLith/trunk/pylith/utils/VTKDataReader.py
===================================================================
--- short/3D/PyLith/trunk/pylith/utils/VTKDataReader.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/utils/VTKDataReader.py 2008-11-02 23:44:10 UTC (rev 13228)
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file utils/VTKDataReader.py
+##
+## @brief Object for reading VTK data file.
+
+def has_vtk():
+ if not "flag" in dir(has_vtk):
+ try:
+ from enthought.tvtk.api import tvtk
+ has_vtk.flag = True
+ except ImportError:
+ print "WARNING: Cannot find Mayavi VTK interface to check output."
+ print " Tests limited to running PyLith without errors."
+ print " Install MayaVi2 " \
+ "(https://svn.enthought.com/enthought/wiki/MayaVi)"
+ print " in order to enable verification of output."
+ has_vtk.flag = False
+ return has_vtk.flag
+
+
+class VTKDataReader(object):
+ """
+ Object for reading VTK data file.
+ """
+
+ def __init__(self):
+ return
+
+
+ def read(self, filename):
+ from enthought.tvtk.api import tvtk
+ reader = tvtk.UnstructuredGridReader()
+ reader.file_name = "axialplanestrain-statevars-elastic_info.vtk"
+ err = reader.update()
+ data = reader.get_output()
+ cells = data.get_cells().to_array()
+
+
+ data = {'vertices': None,
+ 'cells': None,
+ 'vertex_fields': None,
+ 'cell_fields': None,
+ }
+ return data
+
+
+# End of file
More information about the CIG-COMMITS
mailing list