[cig-commits] r20611 - in short/3D/PyLith/branches/v1.7-trunk: pylith/apps tests_auto/eqinfo

brad at geodynamics.org brad at geodynamics.org
Mon Aug 20 16:21:58 PDT 2012


Author: brad
Date: 2012-08-20 16:21:58 -0700 (Mon, 20 Aug 2012)
New Revision: 20611

Added:
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfo.py
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfoLine.py
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfoQuad4.py
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfoTri3.py
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/line.cfg
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/line_two.h5
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/mat_elastic.spatialdb
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/quad4.cfg
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/quad4_one.h5
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/quad4_two.h5
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/testeqinfo.py
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/tri3.cfg
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/tri3_one.h5
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/tri3_two.h5
Removed:
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/eqinfoapp.cfg
Modified:
   short/3D/PyLith/branches/v1.7-trunk/pylith/apps/EqInfoApp.py
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/Makefile.am
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/generate.py
   short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/line_one.h5
Log:
Added tests for pylith_eqinfo.

Modified: short/3D/PyLith/branches/v1.7-trunk/pylith/apps/EqInfoApp.py
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/pylith/apps/EqInfoApp.py	2012-08-20 22:07:15 UTC (rev 20610)
+++ short/3D/PyLith/branches/v1.7-trunk/pylith/apps/EqInfoApp.py	2012-08-20 23:21:58 UTC (rev 20611)
@@ -24,6 +24,7 @@
 
 import h5py
 import numpy
+import math
 import os
 
 # ======================================================================
@@ -50,7 +51,7 @@
 
 
   def recalculate(self):
-    self.avgslip = self.potency / self.ruparea
+    self.avgslip = self.potency / (self.ruparea + 1.0e-30)
     self.mommag = 2.0/3.0*numpy.log10(self.moment) - 10.7
     return
 
@@ -75,8 +76,14 @@
 
 
   def _writeArray(self, name, fout):
-
-    g = ("%14.6e" % v for v in self.__getattribute__(name))
+    vals = self.__getattribute__(name)
+    for i in xrange(len(vals)):
+      if math.isnan(vals[i]) or math.isinf(vals[i]):
+        if vals[i] > 0:
+          vals[i] = 1.0e+30
+        else:
+          vals[i] = -1.0e+30
+    g = ("%14.6e" % v for v in vals)
     astr = ", ".join(g)
     fout.write("%s.%s = [%s]\n" % (self.fault, name, astr))
     return
@@ -162,7 +169,7 @@
       raise ValueError("No faults specified")
 
     nsnapshots = len(self.snapshots)
-    statsFaults = [RuptureStats(nsnapshots)]*nfaults
+    statsFaults = [None]*nfaults
     
     ifault = 0
     for fault in self.faults:
@@ -177,7 +184,9 @@
       cellsArea = self._calcCellArea(cells, vertices)
       cellsShearMod = self._getShearModulus(cells, vertices)
 
-      stats = statsFaults[ifault]
+
+      stats = RuptureStats(nsnapshots)
+      statsFaults[ifault] = stats
       stats.fault = fault
       
       isnapshot = 0
@@ -186,15 +195,15 @@
         istep = self._findTimeStep(snapshot, timestamps)
         slip = h5['vertex_fields/slip'][istep,:,:]
         
-        slipMag = self._vectorMag(slip)
-        cellsSlipMag = self._ptsToCells(slipMag, cells)
+        cellsSlip = self._ptsToCells(slip, cells)
+        cellsSlipMag = self._vectorMag(cellsSlip)
         mask = cellsSlipMag > 0.0
 
         ruparea = numpy.sum(cellsArea[mask])
         potency = numpy.sum(cellsSlipMag*cellsArea)
         moment = numpy.sum(cellsSlipMag*cellsArea*cellsShearMod)
 
-        stats.update(isnapshot, timestamp=snapshot, ruparea=ruparea, potency=potency, moment=moment)
+        stats.update(isnapshot, timestamp=timestamps[istep], ruparea=ruparea, potency=potency, moment=moment)
         
         isnapshot += 1
       h5.close()
@@ -202,6 +211,12 @@
       
     statsTotal = RuptureStats(nsnapshots)
     statsTotal.fault = "all"
+    isnapshot = 0
+    for snapshot in self.snapshots:
+      istep = self._findTimeStep(snapshot, timestamps)
+      statsTotal.timestamp[isnapshot] = timestamps[istep]
+      isnapshot += 1
+
     ruparea = statsTotal.ruparea
     potency = statsTotal.potency
     moment = statsTotal.moment
@@ -253,7 +268,9 @@
     elif ncorners == 4:
       v01 = vertices[cells[:,1]] - vertices[cells[:,0]]
       v02 = vertices[cells[:,2]] - vertices[cells[:,0]]
-      area = self._vectorMag(numpy.cross(v01, v02))
+      v03 = vertices[cells[:,3]] - vertices[cells[:,0]]
+      area = 0.5*self._vectorMag(numpy.cross(v01, v02)) + \
+          0.5*self._vectorMag(numpy.cross(v02, v03))
     else:
       raise ValueError("Unknown case for number of cell corners (%d)." % ncorners)
     return area

Modified: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/Makefile.am
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/Makefile.am	2012-08-20 22:07:15 UTC (rev 20610)
+++ short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/Makefile.am	2012-08-20 23:21:58 UTC (rev 20611)
@@ -16,22 +16,41 @@
 # ----------------------------------------------------------------------
 #
 
+if ENABLE_HDF5
 TESTS = testeqinfo.py
+endif
 
 dist_check_SCRIPTS = testeqinfo.py
 
 dist_noinst_PYTHON = \
-	TestLine.py 
+	TestEqInfo.py \
+	TestEqInfoLine.py \
+	TestEqInfoTri3.py \
+	TestEqInfoQuad4.py
 
-noinst_DATA = line_one.h5
+dist_noinst_DATA = \
+	mat_elastic.spatialdb \
+	line.cfg \
+	line_one.h5 \
+	line_two.h5 \
+	tri3.cfg \
+	tri3_one.h5 \
+	tri3_two.h5 \
+	quad4.cfg \
+	quad4_one.h5 \
+	quad4_two.h5
 
-noinst_TMP = stats_line.py
+noinst_TMP = \
+	stats_line.py \
+	stats_tri3.py \
+	stats_quad4.py
 
+
 TESTS_ENVIRONMENT = $(PYTHON)
 
 
 # 'export' the input files by performing a mock install
-export_datadir = $(top_builddir)/tests_auto/petsc
+export_datadir = $(top_builddir)/tests_auto/eqinfo
 export-data: $(dist_noinst_PYTHON) $(dist_noinst_DATA)
 	for f in $(dist_noinst_PYTHON) $(dist_noinst_DATA); do $(install_sh_DATA) $(srcdir)/$$f $(export_datadir); done
 

Added: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfo.py
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfo.py	                        (rev 0)
+++ short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfo.py	2012-08-20 23:21:58 UTC (rev 20611)
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard, U.S. Geological Survey
+# Charles A. Williams, GNS Science
+# Matthew G. Knepley, University of Chicago
+#
+# This code was developed as part of the Computational Infrastructure
+# for Geodynamics (http://geodynamics.org).
+#
+# Copyright (c) 2010-2012 University of California, Davis
+#
+# See COPYING for license information.
+#
+# ----------------------------------------------------------------------
+#
+
+## @file tests_auto/eqinfo/TestEqInfo.py
+##
+## @brief Generic tests for pylith_eqinfo.
+
+import unittest
+import numpy
+
+class TestEqInfo(unittest.TestCase):
+  """
+  Generic tests for pylith_eqinfo.
+  """
+
+  def _check(self, statsE, stats):
+    """
+    Check earthquake stats.
+    """
+    tol = 1.0e-6
+    attrs = ["timestamp",
+             "ruparea",
+             "potency",
+             "moment",
+             "avgslip",
+             "mommag",
+             ]
+
+    statsE.avgslip = statsE.potency / (statsE.ruparea + 1.0e-30)
+    statsE.mommag = 2.0/3.0*numpy.log10(statsE.moment) - 10.7
+
+    for attr in attrs:
+      valuesE = statsE.__getattribute__(attr)
+      values = stats.__getattribute__(attr)
+      msg = "Mismatch in number of snapshots for attribute '%s', %d != %d." % (attr, len(valuesE), len(values))
+      self.assertEqual(len(valuesE), len(values), msg=msg)
+      
+      for (valueE, value) in zip(valuesE, values):
+        msg = "Mismatch in value for attribute '%s', %g != %g." % (attr, valueE, value)
+        if valueE != 0.0:
+          self.assertAlmostEqual(valueE, value, msg=msg, delta=abs(tol*valueE))
+        else:
+          self.assertAlmostEqual(valueE, value, msg=msg, delta=tol)
+        
+    return
+
+
+# End of file

Added: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfoLine.py
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfoLine.py	                        (rev 0)
+++ short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfoLine.py	2012-08-20 23:21:58 UTC (rev 20611)
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard, U.S. Geological Survey
+# Charles A. Williams, GNS Science
+# Matthew G. Knepley, University of Chicago
+#
+# This code was developed as part of the Computational Infrastructure
+# for Geodynamics (http://geodynamics.org).
+#
+# Copyright (c) 2010-2012 University of California, Davis
+#
+# See COPYING for license information.
+#
+# ----------------------------------------------------------------------
+#
+
+## @file tests_auto/eqinfo/TestEqInfoLine.py
+##
+## @brief Test suite for testing pylith_eqinfo with 1-D fault meshes.
+
+import numpy
+
+from TestEqInfo import TestEqInfo
+
+
+# Local version of EqInfoApp
+from pylith.apps.EqInfoApp import EqInfoApp
+class LineApp(EqInfoApp):
+  def __init__(self):
+    EqInfoApp.__init__(self, name="line")
+    return
+
+
+# Helper function to run pylith_eqinfo.
+def run_eqinfo():
+  """
+  Run pylith_eqinfo.
+  """
+  if not "done" in dir(run_eqinfo):
+    app = LineApp()
+    app.run()
+    run_eqinfo.done = True
+  return
+
+
+class TestEqInfoLine(TestEqInfo):
+  """
+  Test suite for testing pylith_eqinfo with 1-D fault meshes.
+  """
+
+  def setUp(self):
+    """
+    Setup for test.
+    """
+    run_eqinfo()
+    return
+
+
+  def test_stats(self):
+    """
+    Check fault stats.
+    """
+    import stats_line
+    
+    timestamp = numpy.array([0.0, 1.0], dtype=numpy.float64)
+
+    oneE = stats_line.RuptureStats()
+    oneE.timestamp = timestamp
+    oneE.ruparea = numpy.array([2.5, 1.5], dtype=numpy.float64)
+    oneE.potency = numpy.array([0.7*1.0+0.9*1.5, 0.4*1.5], dtype=numpy.float64)
+    oneE.moment = oneE.potency*1.0e+10
+    
+    twoE = stats_line.RuptureStats()
+    twoE.timestamp = timestamp
+    area0 = (1.5**2+1.0**2)**0.5
+    area1 = (1.0**2+1.0**2)**0.5
+    twoE.ruparea = numpy.array([area0+area1, area0], dtype=numpy.float64)
+    twoE.potency = numpy.array([0.9*area0+0.7*area1, 0.3*area0], dtype=numpy.float64)
+    twoE.moment = twoE.potency*1.0e+10
+
+    allE = stats_line.RuptureStats()
+    allE.timestamp = timestamp
+    allE.ruparea = oneE.ruparea + twoE.ruparea
+    allE.potency = oneE.potency + twoE.potency
+    allE.moment = oneE.moment + twoE.moment
+    
+    self._check(oneE, stats_line.one)
+    self._check(twoE, stats_line.two)
+    self._check(allE, stats_line.all)
+    return
+
+
+# End of file 

Added: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfoQuad4.py
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfoQuad4.py	                        (rev 0)
+++ short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfoQuad4.py	2012-08-20 23:21:58 UTC (rev 20611)
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard, U.S. Geological Survey
+# Charles A. Williams, GNS Science
+# Matthew G. Knepley, University of Chicago
+#
+# This code was developed as part of the Computational Infrastructure
+# for Geodynamics (http://geodynamics.org).
+#
+# Copyright (c) 2010-2012 University of California, Davis
+#
+# See COPYING for license information.
+#
+# ----------------------------------------------------------------------
+#
+
+## @file tests_auto/eqinfo/TestEqInfoQuad4.py
+##
+## @brief Test suite for testing pylith_eqinfo with quad4 fault meshes.
+
+import numpy
+
+from TestEqInfo import TestEqInfo
+
+
+# Local version of EqInfoApp
+from pylith.apps.EqInfoApp import EqInfoApp
+class Quad4App(EqInfoApp):
+  def __init__(self):
+    EqInfoApp.__init__(self, name="quad4")
+    return
+
+
+# Helper function to run pylith_eqinfo.
+def run_eqinfo():
+  """
+  Run pylith_eqinfo.
+  """
+  if not "done" in dir(run_eqinfo):
+    app = Quad4App()
+    app.run()
+    run_eqinfo.done = True
+  return
+
+
+class TestEqInfoQuad4(TestEqInfo):
+  """
+  Test suite for testing pylith_eqinfo with quad4 meshes.
+  """
+
+  def setUp(self):
+    """
+    Setup for test.
+    """
+    run_eqinfo()
+    return
+
+
+  def test_stats(self):
+    """
+    Check fault stats.
+    """
+    import stats_quad4
+    
+    timestamp = numpy.array([5.0], dtype=numpy.float64)
+
+    area0 = 1.5*1.75
+    area1 = 1.35*1.5
+    slip0 = (1.0**2+1.2**2)**0.5
+    slip1 = (1.4**2+1.6**2)**0.5
+    oneE = stats_quad4.RuptureStats()
+    oneE.timestamp = timestamp
+    oneE.ruparea = numpy.array([area0 + area1], dtype=numpy.float64)
+    oneE.potency = numpy.array([slip0*area0 + slip1*area1], dtype=numpy.float64)
+    oneE.moment = numpy.array([slip0*area0*1.0e+10 + area1*slip1*2.0e+10], dtype=numpy.float64)
+    
+    area0 = 1.5*1.75
+    area1 = 1.35*1.5
+    slip0 = (1.0**2+1.2**2)**0.5
+    slip1 = (1.4**2+1.6**2)**0.5
+    twoE = stats_quad4.RuptureStats()
+    twoE.timestamp = timestamp
+    twoE.ruparea = numpy.array([area0 + area1], dtype=numpy.float64)
+    twoE.potency = numpy.array([slip0*area0 + slip1*area1], dtype=numpy.float64)
+    twoE.moment = numpy.array([slip0*area0*1.0e+10 + area1*slip1*2.0e+10], dtype=numpy.float64)
+
+    allE = stats_quad4.RuptureStats()
+    allE.timestamp = timestamp
+    allE.ruparea = oneE.ruparea + twoE.ruparea
+    allE.potency = oneE.potency + twoE.potency
+    allE.moment = oneE.moment + twoE.moment
+    
+    self._check(oneE, stats_quad4.one)
+    self._check(twoE, stats_quad4.two)
+    self._check(allE, stats_quad4.all)
+    return
+
+
+# End of file 

Added: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfoTri3.py
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfoTri3.py	                        (rev 0)
+++ short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/TestEqInfoTri3.py	2012-08-20 23:21:58 UTC (rev 20611)
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard, U.S. Geological Survey
+# Charles A. Williams, GNS Science
+# Matthew G. Knepley, University of Chicago
+#
+# This code was developed as part of the Computational Infrastructure
+# for Geodynamics (http://geodynamics.org).
+#
+# Copyright (c) 2010-2012 University of California, Davis
+#
+# See COPYING for license information.
+#
+# ----------------------------------------------------------------------
+#
+
+## @file tests_auto/eqinfo/TestEqInfoTri3.py
+##
+## @brief Test suite for testing pylith_eqinfo with tri3 fault meshes.
+
+import numpy
+
+from TestEqInfo import TestEqInfo
+
+
+# Local version of EqInfoApp
+from pylith.apps.EqInfoApp import EqInfoApp
+class Tri3App(EqInfoApp):
+  def __init__(self):
+    EqInfoApp.__init__(self, name="tri3")
+    return
+
+
+# Helper function to run pylith_eqinfo.
+def run_eqinfo():
+  """
+  Run pylith_eqinfo.
+  """
+  if not "done" in dir(run_eqinfo):
+    app = Tri3App()
+    app.run()
+    run_eqinfo.done = True
+  return
+
+
+class TestEqInfoTri3(TestEqInfo):
+  """
+  Test suite for testing pylith_eqinfo with tri3 meshes.
+  """
+
+  def setUp(self):
+    """
+    Setup for test.
+    """
+    run_eqinfo()
+    return
+
+
+  def test_stats(self):
+    """
+    Check fault stats.
+    """
+    import stats_tri3
+    
+    timestamp = numpy.array([0.0, 1.0], dtype=numpy.float64)
+
+    oneE = stats_tri3.RuptureStats()
+    oneE.timestamp = timestamp
+    oneE.ruparea = numpy.array([1.5+2.0, 1.5+2.0], dtype=numpy.float64)
+    slip0 = (0.2**2+0.5**2)**0.5
+    slip1 = (0.5**2+0.4**2)**0.5
+    oneE.potency = numpy.array([slip0*1.5+slip1*2.0, 0.1*1.5+0.2*2.0], dtype=numpy.float64)
+    oneE.moment = numpy.array([slip0*1.5*1.0e+10+slip1*2.0*2.0e+10, 
+                               0.1*1.5*1.0e+10+0.2*2.0*2.0e+10], dtype=numpy.float64)
+    
+    twoE = stats_tri3.RuptureStats()
+    twoE.timestamp = timestamp
+    twoE.ruparea = numpy.array([1.5, 0.0], dtype=numpy.float64)
+    twoE.potency = numpy.array([0.1*1.5, 0.0], dtype=numpy.float64)
+    twoE.moment = numpy.array([0.1*1.5*1.0e+10, 0.0], dtype=numpy.float64)
+
+    allE = stats_tri3.RuptureStats()
+    allE.timestamp = timestamp
+    allE.ruparea = oneE.ruparea + twoE.ruparea
+    allE.potency = oneE.potency + twoE.potency
+    allE.moment = oneE.moment + twoE.moment
+    
+    self._check(oneE, stats_tri3.one)
+    self._check(twoE, stats_tri3.two)
+    self._check(allE, stats_tri3.all)
+    return
+
+
+# End of file 

Deleted: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/eqinfoapp.cfg
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/eqinfoapp.cfg	2012-08-20 22:07:15 UTC (rev 20610)
+++ short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/eqinfoapp.cfg	2012-08-20 23:21:58 UTC (rev 20611)
@@ -1,15 +0,0 @@
-[eqinfoapp]
-faults = [one]
-filename_pattern = line_%s.h5
-snapshots = [0.01, 0.99]
-snapshot_units = 1.0*s
-
-output_filename = stats_line.py
-
-db_properties = spatialdata.spatialdb.UniformDB
-db_properties.label = Elastic properties
-db_properties.values = [vs, density]
-db_properties.data = [2.0e+3, 2.5e+3]
-
-coordsys.space_dim = 2
-

Modified: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/generate.py
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/generate.py	2012-08-20 22:07:15 UTC (rev 20610)
+++ short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/generate.py	2012-08-20 23:21:58 UTC (rev 20611)
@@ -47,9 +47,9 @@
 
 
 # ----------------------------------------------------------------------
-class TestDataLineA(TestData):
+class DataLinea(TestData):
   """
-  Test data for fault as line.
+  Test data for fault one with line cells.
   """
   
   def __init__(self):
@@ -75,14 +75,195 @@
     self.filename = "line_one.h5"
 
 
+# ----------------------------------------------------------------------
+class DataLineb(TestData):
+  """
+  Test data for fault two with line cells.
+  """
+  
+  def __init__(self):
+    TestData.__init__(self)
+    self.vertices = numpy.array([[-1.5, 0.0],
+                                 [ 0.0, 1.0],
+                                 [+1.0, 0.0]], 
+                                dtype=numpy.float64)
+    self.cells = numpy.array([[1, 2],
+                              [0, 1]], 
+                             dtype=numpy.int32)
+    self.slip = numpy.array([
+        # t=0
+        [[0.6, 0.0],
+         [1.2, 0.0],
+         [0.2, 0.0]],
+        # t=1
+        [[0.6, 0.0],
+         [0.0, 0.0],
+         [0.0, 0.0]]],
+                            dtype=numpy.float64)
+    self.time = numpy.array([0.0, 1.0])
+    self.filename = "line_two.h5"
+
+
+# ----------------------------------------------------------------------
+class DataTri3a(TestData):
+  """
+  Test data for fault one with tri3 cells.
+  """
+  
+  def __init__(self):
+    TestData.__init__(self)
+    self.vertices = numpy.array([[-1.5,  0.0,  0.0],
+                                 [ 0.0,  0.0,  0.0],
+                                 [ 0.0, +2.0,  0.0],
+                                 [ 0.0,  0.0, +2.0]], 
+                                dtype=numpy.float64)
+    self.cells = numpy.array([[0, 1, 3],
+                              [1, 2, 3]], 
+                             dtype=numpy.int32)
+    self.slip = numpy.array([
+        # t=0
+        [[0.0, 0.5, 0.0],
+         [0.6, 0.4, 0.0],
+         [0.9, 0.2, 0.0],
+         [0.0, 0.6, 0.0]],
+        # t=1
+        [[0.0, 0.3, 0.0],
+         [0.0, 0.0, 0.0],
+         [0.6, 0.0, 0.0],
+         [0.0, 0.0, 0.0]]],
+                            dtype=numpy.float64)
+    self.time = numpy.array([0.0, 1.0])
+    self.filename = "tri3_one.h5"
+
+
+# ----------------------------------------------------------------------
+class DataTri3b(TestData):
+  """
+  Test data for fault two with line cells.
+  """
+  
+  def __init__(self):
+    TestData.__init__(self)
+    self.vertices = numpy.array([[-1.5,  0.0,  0.0],
+                                 [ 0.0,  0.0,  0.0],
+                                 [ 0.0,  0.0, +2.0],
+                                 [ 0.0,  2.0,  0.0]], 
+                                dtype=numpy.float64)
+    self.cells = numpy.array([[0, 1, 3],
+                              [1, 2, 3]], 
+                             dtype=numpy.int32)
+    self.slip = numpy.array([
+        # t=0
+        [[0.3, 0.0, 0.0],
+         [0.0, 0.0, 0.0],
+         [0.0, 0.0, 0.0],
+         [0.0, 0.0, 0.0]],
+        # t=1
+        [[0.0, 0.0, 0.0],
+         [0.0, 0.0, 0.0],
+         [0.0, 0.0, 0.0],
+         [0.0, 0.0, 0.0]]],
+                            dtype=numpy.float64)
+    self.time = numpy.array([0.0, 1.0])
+    self.filename = "tri3_two.h5"
+
+
+# ----------------------------------------------------------------------
+class DataQuad4a(TestData):
+  """
+  Test data for fault one with quad4 cells.
+  """
+  
+  def __init__(self):
+    TestData.__init__(self)
+    self.vertices = numpy.array([[-1.5,  0.0,  0.0], # 0
+                                 [ 0.0,  0.0,  0.0], # 1
+                                 [ 0.0, +1.2,  0.0], # 2
+                                 [-1.5,  0.0, +2.0], # 3
+                                 [ 0.0,  0.0, +1.5], # 4
+                                 [ 0.0, +1.5, +1.5]], # 5
+                                dtype=numpy.float64)
+    self.cells = numpy.array([[0, 1, 4, 3],
+                              [1, 2, 5, 4]], 
+                             dtype=numpy.int32)
+    self.slip = numpy.array([
+        # t=0
+        [[0.1, 1.3, 0.0],
+         [0.2, 1.2, 0.0],
+         [0.3, 1.1, 0.0],
+         [0.4, 1.4, 0.0],
+         [0.5, 1.5, 0.0],
+         [0.6, 1.6, 0.0]],
+        # t=1
+        [[0.2, 0.4, 0.0], # 0
+         [0.6, 0.8, 0.0], # 1
+         [1.0, 1.2, 0.0], # 2
+         [1.4, 1.6, 0.0], # 3
+         [1.8, 2.0, 0.0], # 4
+         [2.2, 2.4, 0.0]]], # 5
+                            dtype=numpy.float64)
+    self.time = numpy.array([0.0, 5.0])
+    self.filename = "quad4_one.h5"
+
+
+# ----------------------------------------------------------------------
+class DataQuad4b(TestData):
+  """
+  Test data for fault two with quad4 cells.
+  """
+  
+  def __init__(self):
+    TestData.__init__(self)
+    self.vertices = numpy.array([[-1.5,  0.0,  0.0],
+                                 [ 0.0,  0.0,  0.0],
+                                 [+1.2,  0.0,  0.0],
+                                 [-1.5,  0.0, +2.0],
+                                 [ 0.0,  0.0, +1.5],
+                                 [+1.5,  0.0, +1.5]], 
+                                dtype=numpy.float64)
+    self.cells = numpy.array([[0, 1, 4, 3],
+                              [1, 2, 5, 4]], 
+                             dtype=numpy.int32)
+    self.slip = numpy.array([
+        # t=0
+        [[0.1, 1.3, 0.0],
+         [0.2, 1.2, 0.0],
+         [0.3, 1.1, 0.0],
+         [0.4, 1.4, 0.0],
+         [0.5, 1.5, 0.0],
+         [0.6, 1.6, 0.0]],
+        # t=1
+        [[-0.2, -0.4, 0.0],
+         [-0.6, -0.8, 0.0],
+         [-1.0, -1.2, 0.0],
+         [-1.4, -1.6, 0.0],
+         [-1.8, -2.0, 0.0],
+         [-2.2, -2.4, 0.0]]],
+                            dtype=numpy.float64)
+    self.time = numpy.array([0.0, 5.0])
+    self.filename = "quad4_two.h5"
+
+
 # ======================================================================
-data = TestDataLineA()
+# Line mesh
+data = DataLinea()
 data.write()
 
-#data = TestDataTri()
-#data.write()
+data = DataLineb()
+data.write()
 
-#data = TestDataQuad()
-#data.write()
+# Tri mesh
+data = DataTri3a()
+data.write()
 
+data = DataTri3b()
+data.write()
+
+# Quad mesh
+data = DataQuad4a()
+data.write()
+
+data = DataQuad4b()
+data.write()
+
 # End of file 

Added: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/line.cfg
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/line.cfg	                        (rev 0)
+++ short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/line.cfg	2012-08-20 23:21:58 UTC (rev 20611)
@@ -0,0 +1,15 @@
+[line]
+faults = [one, two]
+filename_pattern = line_%s.h5
+snapshots = [0.01, 0.99]
+snapshot_units = 1.0*s
+
+output_filename = stats_line.py
+
+db_properties = spatialdata.spatialdb.UniformDB
+db_properties.label = Elastic properties
+db_properties.values = [vs, density]
+db_properties.data = [2.0e+3, 2.5e+3]
+
+coordsys.space_dim = 2
+

Modified: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/line_one.h5
===================================================================
(Binary files differ)

Added: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/line_two.h5
===================================================================
(Binary files differ)


Property changes on: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/line_two.h5
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/mat_elastic.spatialdb
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/mat_elastic.spatialdb	                        (rev 0)
+++ short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/mat_elastic.spatialdb	2012-08-20 23:21:58 UTC (rev 20611)
@@ -0,0 +1,28 @@
+// -*- C++ -*- (tell Emacs to use C++ mode for syntax highlighting)
+//
+// This spatial database specifies the distribution of material
+// properties. In this case, the material properties are uniform.
+//
+#SPATIAL.ascii 1
+SimpleDB {
+  num-values = 3 // number of material property values
+  value-names =  density vs vp // names of the material property values
+  value-units =  kg/m**3  m/s  m/s // units
+  num-locs = 3 // number of locations
+  data-dim = 2
+  space-dim = 3
+  cs-data = cartesian {
+    to-meters = 1.0
+    space-dim = 3
+  }
+}
+// Columns are
+// (1) x coordinate (m)
+// (2) y coordinate (m)
+// (3) z coordinate (m)
+// (4) density (kg/m^3)
+// (5) vs (m/s)
+// (6) vp (m/s)
+-0.5   0.0   0.5   2500.0  2000.0  5291.502622129181
+-0.5  +0.5  +0.0   2500.0  2000.0  5291.502622129181
+ 0.0  +0.5  +0.5   5000.0  2000.0  5291.502622129181

Added: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/quad4.cfg
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/quad4.cfg	                        (rev 0)
+++ short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/quad4.cfg	2012-08-20 23:21:58 UTC (rev 20611)
@@ -0,0 +1,11 @@
+[quad4]
+faults = [one, two]
+filename_pattern = quad4_%s.h5
+
+output_filename = stats_quad4.py
+
+db_properties.label = Elastic properties
+db_properties.iohandler.filename = mat_elastic.spatialdb
+
+coordsys.space_dim = 3
+

Added: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/quad4_one.h5
===================================================================
(Binary files differ)


Property changes on: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/quad4_one.h5
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/quad4_two.h5
===================================================================
(Binary files differ)


Property changes on: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/quad4_two.h5
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/testeqinfo.py
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/testeqinfo.py	                        (rev 0)
+++ short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/testeqinfo.py	2012-08-20 23:21:58 UTC (rev 20611)
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard, U.S. Geological Survey
+# Charles A. Williams, GNS Science
+# Matthew G. Knepley, University of Chicago
+#
+# This code was developed as part of the Computational Infrastructure
+# for Geodynamics (http://geodynamics.org).
+#
+# Copyright (c) 2010-2012 University of California, Davis
+#
+# See COPYING for license information.
+#
+# ======================================================================
+#
+
+__requires__ = "PyLith"
+
+import unittest
+
+def suite():
+  """
+  Create test suite.
+  """
+  suite = unittest.TestSuite()
+
+  from TestEqInfoLine import TestEqInfoLine
+  suite.addTest(unittest.makeSuite(TestEqInfoLine))
+
+  from TestEqInfoTri3 import TestEqInfoTri3
+  suite.addTest(unittest.makeSuite(TestEqInfoTri3))
+
+  from TestEqInfoQuad4 import TestEqInfoQuad4
+  suite.addTest(unittest.makeSuite(TestEqInfoQuad4))
+
+  return suite
+
+
+def main():
+  """
+  Run test suite.
+  """
+  import sys
+  sys.path.append(".")
+
+  unittest.TextTestRunner(verbosity=2).run(suite())
+  return
+
+
+# ----------------------------------------------------------------------
+if __name__ == '__main__':
+  main()
+
+  
+# End of file 


Property changes on: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/testeqinfo.py
___________________________________________________________________
Name: svn:executable
   + *

Added: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/tri3.cfg
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/tri3.cfg	                        (rev 0)
+++ short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/tri3.cfg	2012-08-20 23:21:58 UTC (rev 20611)
@@ -0,0 +1,13 @@
+[tri3]
+faults = [one, two]
+filename_pattern = tri3_%s.h5
+snapshots = [0.0, 1.0]
+snapshot_units = 1.0*s
+
+output_filename = stats_tri3.py
+
+db_properties.label = Elastic properties
+db_properties.iohandler.filename = mat_elastic.spatialdb
+
+coordsys.space_dim = 3
+

Added: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/tri3_one.h5
===================================================================
(Binary files differ)


Property changes on: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/tri3_one.h5
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/tri3_two.h5
===================================================================
(Binary files differ)


Property changes on: short/3D/PyLith/branches/v1.7-trunk/tests_auto/eqinfo/tri3_two.h5
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream



More information about the CIG-COMMITS mailing list