[cig-commits] r13243 - in short/3D/PyLith/trunk: pylith/utils tests/2d/tri3
brad at geodynamics.org
brad at geodynamics.org
Mon Nov 3 20:21:08 PST 2008
Author: brad
Date: 2008-11-03 20:21:07 -0800 (Mon, 03 Nov 2008)
New Revision: 13243
Modified:
short/3D/PyLith/trunk/pylith/utils/VTKDataReader.py
short/3D/PyLith/trunk/tests/2d/tri3/TestAxialPlaneStrain.py
Log:
More work on setting up full scale testing.
Modified: short/3D/PyLith/trunk/pylith/utils/VTKDataReader.py
===================================================================
--- short/3D/PyLith/trunk/pylith/utils/VTKDataReader.py 2008-11-04 02:36:41 UTC (rev 13242)
+++ short/3D/PyLith/trunk/pylith/utils/VTKDataReader.py 2008-11-04 04:21:07 UTC (rev 13243)
@@ -14,6 +14,8 @@
##
## @brief Object for reading VTK data file.
+import numpy
+
def has_vtk():
if not "flag" in dir(has_vtk):
try:
@@ -44,15 +46,42 @@
reader.file_name = "axialplanestrain-statevars-elastic_info.vtk"
err = reader.update()
data = reader.get_output()
+
+
+ data = {'vertices': self._getVertices(data),
+ 'cells': self._getCells(data),
+ 'vertex_fields': self._getVertexFields(data),
+ 'cell_fields': self._getCellFields(data),
+ }
+ return data
+
+
+ def _getVertices(self, data):
+ vertices = data.points.to_array()
+ return vertices
+
+
+ def _getCells(self, data):
cells = data.get_cells().to_array()
+ cellTypes = data.cell_types_array.to_array()
+ ncells = data.number_of_cells
+ id = cellTypes[0]
+ if numpy.sum(cellTypes-id) != 0:
+ raise ValueError("Expecting cells to all be the same type.")
+ if id == 5:
+ ncorners = 3
+ else:
+ raise ValueError("Unknown VTK cell type '%d'." % id)
+ cells = cells.reshape( (ncells, 1+ncorners) )[:,1:1+ncorners]
+ return cells
- data = {'vertices': None,
- 'cells': None,
- 'vertex_fields': None,
- 'cell_fields': None,
- }
- return data
+ def _getVertexFields(self, data):
+ return
+ def _getCellFields(self, data):
+ return
+
+
# End of file
Modified: short/3D/PyLith/trunk/tests/2d/tri3/TestAxialPlaneStrain.py
===================================================================
--- short/3D/PyLith/trunk/tests/2d/tri3/TestAxialPlaneStrain.py 2008-11-04 02:36:41 UTC (rev 13242)
+++ short/3D/PyLith/trunk/tests/2d/tri3/TestAxialPlaneStrain.py 2008-11-04 04:21:07 UTC (rev 13243)
@@ -65,6 +65,23 @@
return
data = self.reader.read("axialplanestrain-statevars-elastic_info.vtk")
+
+ # Check cells
+ ncellsE = 84
+ ncornersE = 3
+ (ncells, ncorners) = data['cells'].shape
+ self.assertEqual(ncellsE, ncells)
+ self.assertEqual(ncornersE, ncorners)
+
+ # Check vertices
+ nverticesE = 54
+ spaceDimE = 3
+ (nvertices, spaceDim) = data['vertices'].shape
+ self.assertEqual(nverticesE, nvertices)
+ self.assertEqual(spaceDimE, spaceDim)
+
+ # Check displacement solution
+
return
More information about the CIG-COMMITS
mailing list