[cig-commits] r7090 - in short/3D/PyLith/trunk: . libsrc/faults modulesrc/faults pylith/faults unittests/libtests/faults unittests/pytests/faults

brad at geodynamics.org brad at geodynamics.org
Thu Jun 7 09:28:20 PDT 2007


Author: brad
Date: 2007-06-07 09:28:19 -0700 (Thu, 07 Jun 2007)
New Revision: 7090

Added:
   short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.cc
   short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.hh
   short/3D/PyLith/trunk/unittests/pytests/faults/TestEqKinSrc.py
Removed:
   short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.icc
Modified:
   short/3D/PyLith/trunk/TODO
   short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.hh
   short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src
   short/3D/PyLith/trunk/pylith/faults/EqKinSrc.py
   short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am
   short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.cc
   short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.hh
   short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py
Log:
Implemented C++ and Python unit tests for EqKinSrc object. Implemented bindings for EqKinSrc object. Fixed bugs exposed by Python unit tests.

Modified: short/3D/PyLith/trunk/TODO
===================================================================
--- short/3D/PyLith/trunk/TODO	2007-06-07 15:37:04 UTC (rev 7089)
+++ short/3D/PyLith/trunk/TODO	2007-06-07 16:28:19 UTC (rev 7090)
@@ -26,19 +26,9 @@
 
    b. Implement integrator for faults
 
-     i. EqKinSrc
+     i. FaultCohesiveKin
        (1) C++ unit tests
          constructor
-         slipfn()
-         initialize()
-         slip()
-       (2) Python unit tests
-         constructor
-         initialize()
-
-     ii. FaultCohesiveKin
-       (1) C++ unit tests
-         constructor
          eqsrc()
          initialize()
          integrateResidual()

Modified: short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.hh	2007-06-07 15:37:04 UTC (rev 7089)
+++ short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.hh	2007-06-07 16:28:19 UTC (rev 7090)
@@ -104,8 +104,6 @@
 
 }; // class EqKinSrc
 
-#include "EqKinSrc.icc" // inline methods
-
 #endif // pylith_faults_eqkinsrc_hh
 
 

Deleted: short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.icc	2007-06-07 15:37:04 UTC (rev 7089)
+++ short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.icc	2007-06-07 16:28:19 UTC (rev 7090)
@@ -1,18 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-//                           Brad T. Aagaard
-//                        U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#if !defined(pylith_faults_eqkinsrc_hh)
-#error "EqKinSrc.icc can only be included from EqKinSrc.hh"
-#endif
-
-
-// End of file 

Modified: short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src	2007-06-07 15:37:04 UTC (rev 7089)
+++ short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src	2007-06-07 16:28:19 UTC (rev 7090)
@@ -14,6 +14,7 @@
 #include "pylith/faults/Fault.hh"
 #include "pylith/faults/FaultCohesive.hh"
 #include "pylith/faults/FaultCohesiveKin.hh"
+#include "pylith/faults/EqKinSrc.hh"
 #include "pylith/faults/SlipTimeFn.hh"
 #include "pylith/faults/BruneSlipFn.hh"
 
@@ -50,6 +51,19 @@
   Fault_destructor_cpp(obj)
   return
 
+cdef void EqKinSrc_destructor(void* obj):
+  """
+  Destroy EqKinSrc object.
+  """
+  # create shim for destructor
+  #embed{ void EqKinSrc_destructor_cpp(void* objVptr)
+  pylith::faults::EqKinSrc* src = (pylith::faults::EqKinSrc*) objVptr;
+  delete src;
+  #}embed
+  EqKinSrc_destructor_cpp(obj)
+  return
+
+
 cdef void SlipTimeFn_destructor(void* obj):
   """
   Destroy SlipTimeFn object.
@@ -260,6 +274,74 @@
 
 
 # ----------------------------------------------------------------------
+cdef class EqKinSrc:
+
+  cdef void* thisptr # Pointer to C++ object
+  cdef readonly object handle # PyCObject holding pointer to C++ object
+  cdef readonly object name # Identifier for object base type
+
+  def __init__(self):
+    """
+    Constructor.
+    """
+    # create shim for constructor
+    #embed{ void* EqKinSrc_constructor()
+    void* result = 0;
+    try {
+      result = (void*)(new pylith::faults::EqKinSrc);
+      assert(0 != result);
+    } catch (const std::exception& err) {
+      PyErr_SetString(PyExc_RuntimeError,
+                      const_cast<char*>(err.what()));
+    } catch (...) {
+      PyErr_SetString(PyExc_RuntimeError,
+                      "Caught unknown C++ exception.");
+    } // try/catch
+    return result;
+    #}embed
+
+    self.name = "pylith_faults_EqKinSrc"
+    self.thisptr = EqKinSrc_constructor()
+    self.handle = self._createHandle()
+    return
+
+
+  def _createHandle(self):
+    """
+    Wrap pointer to C++ object in PyCObject.
+    """
+    return PyCObject_FromVoidPtr(self.thisptr, EqKinSrc_destructor)
+
+
+  property slipfn:
+    def __set__(self, value):
+      """
+      Set slip time function.
+      """
+      # create shim for method 'slipfn'
+      #embed{ void EqKinSrc_slipfn_set(void* objVptr, void* fnVptr)
+      try {
+        assert(0 != objVptr);
+        assert(0 != fnVptr);
+        pylith::faults::SlipTimeFn* fn =
+          (pylith::faults::SlipTimeFn*) fnVptr;
+        ((pylith::faults::EqKinSrc*) objVptr)->slipfn(fn);
+      } catch (const std::exception& err) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        const_cast<char*>(err.what()));
+      } catch (...) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        "Caught unknown C++ exception.");
+      } // try/catch
+      #}embed
+      if not value.name == "pylith_faults_SlipTimeFn":
+        raise TypeError, \
+              "Argument must be extension module type " \
+              "'pylith_faults_SlipTimeFn'."
+      EqKinSrc_slipfn_set(self.thisptr, ptrFromHandle(value))
+
+
+# ----------------------------------------------------------------------
 cdef class SlipTimeFn:
 
   cdef void* thisptr # Pointer to C++ object

Modified: short/3D/PyLith/trunk/pylith/faults/EqKinSrc.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/EqKinSrc.py	2007-06-07 15:37:04 UTC (rev 7089)
+++ short/3D/PyLith/trunk/pylith/faults/EqKinSrc.py	2007-06-07 16:28:19 UTC (rev 7090)
@@ -50,9 +50,9 @@
     import pyre.inventory
 
     from BruneSlipFn import BruneSlipFn
-    slipFn = pyre.inventory.facility("slip_function", family="slip_time_fn",
+    slipfn = pyre.inventory.facility("slip_function", family="slip_time_fn",
                                      factory=BruneSlipFn)
-    slipFn.meta['tip'] = "Slip time history function."
+    slipfn.meta['tip'] = "Slip time history function."
 
 
   # PUBLIC METHODS /////////////////////////////////////////////////////
@@ -62,6 +62,8 @@
     Constructor.
     """
     Component.__init__(self, name, facility="eqkinsrc")
+    import pylith.faults.faults as bindings
+    self.cppHandle = bindings.EqKinSrc()
     return
 
 
@@ -69,7 +71,9 @@
     """
     Initialize.
     """
-    self.slipFn.initialize()
+    assert(None != self.cppHandle)
+    self.cppHandle.slipfn = self.slipfn.cppHandle
+    self.slipfn.initialize()
     return
 
 
@@ -80,7 +84,7 @@
     Setup members using inventory.
     """
     Component._configure(self)
-    slipFn = self.inventory.slipFn
+    slipfn = self.inventory.slipfn
     return
 
   

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am	2007-06-07 15:37:04 UTC (rev 7089)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am	2007-06-07 16:28:19 UTC (rev 7090)
@@ -22,6 +22,7 @@
 # Primary source files
 testfaults_SOURCES = \
 	TestBruneSlipFn.cc \
+	TestEqKinSrc.cc \
 	TestFault.cc \
 	TestFaultCohesive.cc \
 	TestFaultCohesiveKin.cc \
@@ -29,6 +30,7 @@
 
 noinst_HEADERS = \
 	TestBruneSlipFn.hh \
+	TestEqKinSrc.hh \
 	TestFault.hh \
 	TestFaultCohesive.hh \
 	TestFaultCohesiveKin.hh

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.cc	2007-06-07 15:37:04 UTC (rev 7089)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.cc	2007-06-07 16:28:19 UTC (rev 7090)
@@ -328,7 +328,7 @@
 } // testSlipTH
 
 // ----------------------------------------------------------------------
-// Test initialize() in 1-D.
+// Test initialize().
 void
 pylith::faults::TestBruneSlipFn::_testInitialize(const _TestBruneSlipFn::DataStruct& data)
 { // _testInitialize

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.hh	2007-06-07 15:37:04 UTC (rev 7089)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.hh	2007-06-07 16:28:19 UTC (rev 7090)
@@ -21,7 +21,7 @@
 #if !defined(pylith_faults_testbruneslipfn_hh)
 #define pylith_faults_testbruneslipfn_hh
 
-#include "TestFaultCohesive.hh"
+#include <cppunit/extensions/HelperMacros.h>
 
 /// Namespace for pylith package
 namespace pylith {
@@ -35,11 +35,12 @@
 } // pylith
 
 /// C++ unit testing for BruneSlipFn
-class pylith::faults::TestBruneSlipFn : public TestFaultCohesive
+class pylith::faults::TestBruneSlipFn : public CppUnit::TestFixture
 { // class TestBruneSlipFn
 
   // CPPUNIT TEST SUITE /////////////////////////////////////////////////
   CPPUNIT_TEST_SUITE( TestBruneSlipFn );
+
   CPPUNIT_TEST( testConstructor );
   CPPUNIT_TEST( testDbFinalSlip );
   CPPUNIT_TEST( testDbSlipTime );
@@ -49,6 +50,7 @@
   CPPUNIT_TEST( testInitialize3D );
   CPPUNIT_TEST( testSlip );
   CPPUNIT_TEST( testSlipTH );
+
   CPPUNIT_TEST_SUITE_END();
 
   // PUBLIC METHODS /////////////////////////////////////////////////////

Added: short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.cc	2007-06-07 15:37:04 UTC (rev 7089)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.cc	2007-06-07 16:28:19 UTC (rev 7090)
@@ -0,0 +1,229 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestEqKinSrc.hh" // Implementation of class methods
+
+#include "pylith/faults/EqKinSrc.hh" // USES EqKinSrc
+
+#include "pylith/faults/BruneSlipFn.hh" // USES BruneSlipFn
+#include "pylith/faults/CohesiveTopology.hh" // USES CohesiveTopology
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
+
+#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
+#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
+#include "spatialdata/spatialdb/SimpleIOAscii.hh" // USES SimpleIOAscii
+
+#include <stdexcept> // TEMPORARY
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::faults::TestEqKinSrc );
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::faults::TestEqKinSrc::testConstructor(void)
+{ // testConstructor
+  EqKinSrc eqsrc;
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test slipFn().
+void
+pylith::faults::TestEqKinSrc::testSlipFn(void)
+{ // testSlipFn
+  BruneSlipFn slipfn;
+
+  EqKinSrc eqsrc;
+  eqsrc.slipfn(&slipfn);
+  CPPUNIT_ASSERT(&slipfn == eqsrc._slipfn);
+} // testSlipFn
+
+// ----------------------------------------------------------------------
+// Test initialize(). Use 2-D mesh with Brune slip function to test
+// initialize().
+void
+pylith::faults::TestEqKinSrc::testInitialize(void)
+{ // testInitialize
+  const char* meshFilename = "data/tri3.mesh";
+  const char* faultLabel = "fault";
+  const int faultId = 2;
+  const char* finalSlipFilename = "data/tri3_finalslip.spatialdb";
+  const char* slipTimeFilename = "data/tri3_sliptime.spatialdb";
+  const char* peakRateFilename = "data/tri3_peakrate.spatialdb";
+  const int constraintPts[] = { 3, 4 };
+  const double finalSlipE[] = { 2.3, 0.1, 
+				2.4, 0.2};
+  const double slipTimeE[] = { 1.2, 1.3 };
+  const double peakRateE[] = { 1.4, 1.5 };
+  const int numConstraintPts = 2;
+
+  typedef std::set<Mesh::point_type>::const_iterator vert_iterator;  
+
+  // Setup mesh
+  ALE::Obj<Mesh> mesh;
+  meshio::MeshIOAscii meshIO;
+  meshIO.filename(meshFilename);
+  meshIO.debug(false);
+  meshIO.interpolate(false);
+  meshIO.read(&mesh);
+  CPPUNIT_ASSERT(!mesh.isNull());
+  const int spaceDim = mesh->getDimension();
+  spatialdata::geocoords::CSCart cs;
+  cs.setSpaceDim(spaceDim);
+
+  // Create fault mesh
+  ALE::Obj<Mesh> faultMesh;
+  const bool useLagrangeConstraints = true;
+  CohesiveTopology::create(&faultMesh, mesh, 
+			   mesh->getIntSection(faultLabel),
+			   faultId);
+  CPPUNIT_ASSERT(!faultMesh.isNull());
+
+  // Create set of constraint vertices
+  std::set<Mesh::point_type> eqsrcVertices;
+  for (int i=0; i < numConstraintPts; ++i)
+    eqsrcVertices.insert(constraintPts[i]);
+  CPPUNIT_ASSERT_EQUAL(numConstraintPts, int(eqsrcVertices.size()));
+  
+  // Setup databases
+  spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
+  spatialdata::spatialdb::SimpleIOAscii ioFinalSlip;
+  ioFinalSlip.filename(finalSlipFilename);
+  dbFinalSlip.ioHandler(&ioFinalSlip);
+  
+  spatialdata::spatialdb::SimpleDB dbSlipTime("slip time");
+  spatialdata::spatialdb::SimpleIOAscii ioSlipTime;
+  ioSlipTime.filename(slipTimeFilename);
+  dbSlipTime.ioHandler(&ioSlipTime);
+  
+  spatialdata::spatialdb::SimpleDB dbPeakRate("peak rate");
+  spatialdata::spatialdb::SimpleIOAscii ioPeakRate;
+  ioPeakRate.filename(peakRateFilename);
+  dbPeakRate.ioHandler(&ioPeakRate);
+
+  // setup EqKinSrc
+  BruneSlipFn slipFn;
+  slipFn.dbFinalSlip(&dbFinalSlip);
+  slipFn.dbSlipTime(&dbSlipTime);
+  slipFn.dbPeakRate(&dbPeakRate);
+  
+  EqKinSrc eqsrc;
+  eqsrc.slipfn(&slipFn);
+  eqsrc.initialize(mesh, faultMesh, eqsrcVertices, &cs);
+
+  // Don't have access to details of slip time function, so we can't
+  // check parameters. Have to rely on test of slip() for verification
+  // of results.
+} // testInitialize
+
+// ----------------------------------------------------------------------
+// Test slip().
+void
+pylith::faults::TestEqKinSrc::testSlip(void)
+{ // testSlip
+  const char* meshFilename = "data/tri3.mesh";
+  const char* faultLabel = "fault";
+  const int faultId = 2;
+  const char* finalSlipFilename = "data/tri3_finalslip.spatialdb";
+  const char* slipTimeFilename = "data/tri3_sliptime.spatialdb";
+  const char* peakRateFilename = "data/tri3_peakrate.spatialdb";
+  const int constraintPts[] = { 3, 4 };
+  const double finalSlipE[] = { 2.3, 0.1, 
+				2.4, 0.2};
+  const double slipTimeE[] = { 1.2, 1.3 };
+  const double peakRateE[] = { 1.4, 1.5 };
+  const int numConstraintPts = 2;
+
+  ALE::Obj<Mesh> mesh;
+  meshio::MeshIOAscii meshIO;
+  meshIO.filename(meshFilename);
+  meshIO.debug(false);
+  meshIO.interpolate(false);
+  meshIO.read(&mesh);
+  CPPUNIT_ASSERT(!mesh.isNull());
+  const int spaceDim = mesh->getDimension();
+  spatialdata::geocoords::CSCart cs;
+  cs.setSpaceDim(spaceDim);
+
+  // Create fault mesh
+  ALE::Obj<Mesh> faultMesh;
+  const bool useLagrangeConstraints = true;
+  CohesiveTopology::create(&faultMesh, mesh, 
+			   mesh->getIntSection(faultLabel),
+			   faultId);
+  CPPUNIT_ASSERT(!faultMesh.isNull());
+
+  // Create set of constraint vertices
+  std::set<Mesh::point_type> eqsrcVertices;
+  for (int i=0; i < numConstraintPts; ++i)
+    eqsrcVertices.insert(constraintPts[i]);
+  CPPUNIT_ASSERT_EQUAL(numConstraintPts, int(eqsrcVertices.size()));
+  
+  // Setup databases
+  spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
+  spatialdata::spatialdb::SimpleIOAscii ioFinalSlip;
+  ioFinalSlip.filename(finalSlipFilename);
+  dbFinalSlip.ioHandler(&ioFinalSlip);
+  
+  spatialdata::spatialdb::SimpleDB dbSlipTime("slip time");
+  spatialdata::spatialdb::SimpleIOAscii ioSlipTime;
+  ioSlipTime.filename(slipTimeFilename);
+  dbSlipTime.ioHandler(&ioSlipTime);
+  
+  spatialdata::spatialdb::SimpleDB dbPeakRate("peak rate");
+  spatialdata::spatialdb::SimpleIOAscii ioPeakRate;
+  ioPeakRate.filename(peakRateFilename);
+  dbPeakRate.ioHandler(&ioPeakRate);
+
+  // setup EqKinSrc
+  BruneSlipFn slipFn;
+  slipFn.dbFinalSlip(&dbFinalSlip);
+  slipFn.dbSlipTime(&dbSlipTime);
+  slipFn.dbPeakRate(&dbPeakRate);
+  
+  EqKinSrc eqsrc;
+  eqsrc.slipfn(&slipFn);
+  eqsrc.initialize(mesh, faultMesh, eqsrcVertices, &cs);
+  
+  const double t = 2.134;
+  const ALE::Obj<real_section_type>& slip = eqsrc.slip(t, eqsrcVertices);
+  CPPUNIT_ASSERT(!slip.isNull());
+
+  int iPoint = 0;
+  const double tolerance = 1.0e-06;
+  typedef std::set<Mesh::point_type>::const_iterator vert_iterator;  
+  const vert_iterator vBegin = eqsrcVertices.begin();
+  const vert_iterator vEnd = eqsrcVertices.end();
+  for (vert_iterator v_iter=vBegin; v_iter != vEnd; ++v_iter, ++iPoint) {
+    double slipMag = 0.0;
+    for (int iDim=0; iDim < spaceDim; ++iDim)
+      slipMag += pow(finalSlipE[iPoint*spaceDim+iDim], 2);
+    slipMag = sqrt(slipMag);
+    const double tau = slipMag / (exp(1.0) * peakRateE[iPoint]);
+    const double t0 = slipTimeE[iPoint];
+    const double slipNorm = 1.0 - exp(-(t-t0)/tau) * (1.0 + (t-t0)/tau);
+
+    const int fiberDim = slip->getFiberDimension(*v_iter);
+    CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
+    const real_section_type::value_type* vals = 
+      slip->restrictPoint(*v_iter);
+    for (int iDim=0; iDim < fiberDim; ++iDim) {
+      const double slipE = finalSlipE[iPoint*spaceDim+iDim] * slipNorm;
+      CPPUNIT_ASSERT_DOUBLES_EQUAL(slipE, vals[iDim], tolerance);
+    } // for
+  } // for
+} // testSlip
+
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.hh	2007-06-07 15:37:04 UTC (rev 7089)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.hh	2007-06-07 16:28:19 UTC (rev 7090)
@@ -0,0 +1,73 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/faults/TestEqKinSrc.hh
+ *
+ * @brief C++ TestEqKinSrc object
+ *
+ * C++ unit testing for EqKinSrc.
+ */
+
+#if !defined(pylith_faults_testeqkinsrc_hh)
+#define pylith_faults_testeqkinsrc_hh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+/// Namespace for pylith package
+namespace pylith {
+  namespace faults {
+    class TestEqKinSrc;
+
+    namespace _TestEqKinSrc {
+      struct DataStruct;
+    } // _BruneSlipTimeFn
+  } // faults
+} // pylith
+
+/// C++ unit testing for EqKinSrc
+class pylith::faults::TestEqKinSrc : public CppUnit::TestFixture
+{ // class TestEqKinSrc
+
+  // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+  CPPUNIT_TEST_SUITE( TestEqKinSrc );
+
+  CPPUNIT_TEST( testConstructor );
+  CPPUNIT_TEST( testSlipFn );
+  CPPUNIT_TEST( testInitialize );
+  CPPUNIT_TEST( testSlip );
+
+  CPPUNIT_TEST_SUITE_END();
+
+  // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+  /// Test constructor.
+  void testConstructor(void);
+
+  /// Test slipFn().
+  void testSlipFn(void);
+
+  /// Test initialize(). Use 2-D mesh with Brune slip function to test
+  /// initialize().
+  void testInitialize(void);
+
+  /// Test slip(). Use 2-D mesh with Brune slip function to test
+  /// slip().
+  void testSlip(void);
+
+}; // class TestEqKinSrc
+
+#endif // pylith_faults_testeqkinsrc_hh
+
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/pytests/faults/TestEqKinSrc.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/TestEqKinSrc.py	2007-06-07 15:37:04 UTC (rev 7089)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/TestEqKinSrc.py	2007-06-07 16:28:19 UTC (rev 7090)
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/faults/TestEqKinSrc.py
+
+## @brief Unit testing of EqKinSrc object.
+
+import unittest
+
+from pylith.faults.EqKinSrc import EqKinSrc
+
+# ----------------------------------------------------------------------
+class TestEqKinSrc(unittest.TestCase):
+  """
+  Unit testing of EqKinSrc object.
+  """
+
+  def test_constructor(self):
+    """
+    Test constructor.
+    """
+    eqsrc = EqKinSrc()
+    self.failIfEqual(None, eqsrc.cppHandle)
+    return
+
+
+  def test_initialize(self):
+    """
+    Test initialize().
+    """
+    from spatialdata.spatialdb.SimpleDB import SimpleDB
+    from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
+
+    ioFinalSlip = SimpleIOAscii()
+    ioFinalSlip.filename = "finalslip.spatialdb"
+    dbFinalSlip = SimpleDB()
+    dbFinalSlip.iohandler = ioFinalSlip
+    dbFinalSlip.label = "final slip"
+    
+    ioSlipTime = SimpleIOAscii()
+    ioSlipTime.filename = "sliptime.spatialdb"
+    dbSlipTime = SimpleDB()
+    dbSlipTime.iohandler = ioSlipTime
+    dbSlipTime.label = "slip time"
+    
+    ioPeakRate = SimpleIOAscii()
+    ioPeakRate.filename = "peakrate.spatialdb"
+    dbPeakRate = SimpleDB()
+    dbPeakRate.iohandler = ioPeakRate
+    dbPeakRate.label = "peak rate"
+    
+    from pylith.faults.BruneSlipFn import BruneSlipFn
+    slipfn = BruneSlipFn()
+    slipfn.slip = dbFinalSlip
+    slipfn.slipTime = dbSlipTime
+    slipfn.slipRate = dbPeakRate
+
+    eqsrc = EqKinSrc()
+    eqsrc.slipfn = slipfn
+    eqsrc.initialize()
+    return
+
+
+# End of file 

Modified: short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py	2007-06-07 15:37:04 UTC (rev 7089)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py	2007-06-07 16:28:19 UTC (rev 7090)
@@ -59,6 +59,9 @@
     from TestBruneSlipFn import TestBruneSlipFn
     suite.addTest(unittest.makeSuite(TestBruneSlipFn))
 
+    from TestEqKinSrc import TestEqKinSrc
+    suite.addTest(unittest.makeSuite(TestEqKinSrc))
+
     from TestFault import TestFault
     suite.addTest(unittest.makeSuite(TestFault))
 



More information about the cig-commits mailing list