# [cig-commits] r13269 - short/3D/PyLith/trunk/tests/2d/tri3

brad at geodynamics.org brad at geodynamics.org
Thu Nov 6 21:47:46 PST 2008

```Author: brad
Date: 2008-11-06 21:47:46 -0800 (Thu, 06 Nov 2008)
New Revision: 13269

Modified:
short/3D/PyLith/trunk/tests/2d/tri3/TestAxialPlaneStrain.py
Log:
More work on tests/2d/tri3.

Modified: short/3D/PyLith/trunk/tests/2d/tri3/TestAxialPlaneStrain.py
===================================================================
--- short/3D/PyLith/trunk/tests/2d/tri3/TestAxialPlaneStrain.py	2008-11-07 03:29:17 UTC (rev 13268)
+++ short/3D/PyLith/trunk/tests/2d/tri3/TestAxialPlaneStrain.py	2008-11-07 05:47:46 UTC (rev 13269)
@@ -116,6 +116,56 @@
"""
Check solution (displacement) field.
"""
+    if self.reader is None:
+      return
+
+    data = self.reader.read("axialplanestrain_t0000000.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
+    vertices = data['vertices']
+    (nvertices, spaceDim) = vertices.shape
+    self.assertEqual(nverticesE, nvertices)
+    self.assertEqual(spaceDimE, spaceDim)
+
+    # Check displacement solution
+    tolerance = 1.0e-5
+    dispE = numpy.zeros( (nvertices, spaceDim), dtype=numpy.float64)
+    dispE[:,1] = -0.004 * vertices[:,1]
+
+    disp = data['vertex_fields']['displacements']
+
+    # Check x displacements
+    diff = numpy.abs(disp[:,0] - dispE[:,0])
+    okay = diff < tolerance
+    if numpy.sum(okay) != nvertices:
+      print "Displacement field: ",disp
+      self.assertEqual(nvertices, numpy.sum(okay))
+
+    # Check y displacements
+    mask = dispE[:,1] > 0.0
+    diff = mask * numpy.abs(1.0 - disp[:,1] / dispE[:,1]) + \
+        ~mask * numpy.abs(disp[:,1] - dispE[:,1])
+    okay = diff < tolerance
+    if numpy.sum(okay) != nvertices:
+      print "Displacement field: ",disp
+      self.assertEqual(nvertices, numpy.sum(okay))
+
+    # Check z displacements
+    diff = numpy.abs(disp[:,2] - dispE[:,2])
+    okay = diff < tolerance
+    if numpy.sum(okay) != nvertices:
+      print "Displacement field: ",disp
+      self.assertEqual(nvertices, numpy.sum(okay))
+
return

```

More information about the CIG-COMMITS mailing list