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

brad at geodynamics.org brad at geodynamics.org
Fri May 30 22:09:21 PDT 2008


Author: brad
Date: 2008-05-30 22:09:21 -0700 (Fri, 30 May 2008)
New Revision: 12066

Added:
   short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc
   short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.hh
   short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.icc
   short/3D/PyLith/trunk/pylith/faults/ConstRateSlipFn.py
   short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.cc
   short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.hh
   short/3D/PyLith/trunk/unittests/libtests/faults/data/line2_sliprate.spatialdb
   short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4_sliprate.spatialdb
   short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3_sliprate.spatialdb
   short/3D/PyLith/trunk/unittests/pytests/faults/TestConstRateSlipFn.py
Modified:
   short/3D/PyLith/trunk/libsrc/Makefile.am
   short/3D/PyLith/trunk/libsrc/faults/Makefile.am
   short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src
   short/3D/PyLith/trunk/pylith/Makefile.am
   short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am
   short/3D/PyLith/trunk/unittests/libtests/faults/data/Makefile.am
   short/3D/PyLith/trunk/unittests/pytests/faults/Makefile.am
   short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py
Log:
Added constant rate slip time function (including Python and C++ unit tests).

Modified: short/3D/PyLith/trunk/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/Makefile.am	2008-05-31 02:10:02 UTC (rev 12065)
+++ short/3D/PyLith/trunk/libsrc/Makefile.am	2008-05-31 05:09:21 UTC (rev 12066)
@@ -28,6 +28,7 @@
 	bc/DirichletPoints.cc \
 	bc/Neumann.cc \
 	faults/BruneSlipFn.cc \
+	faults/ConstRateSlipFn.cc \
 	faults/CohesiveTopology.cc \
 	faults/EqKinSrc.cc \
 	faults/Fault.cc \

Added: short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc	                        (rev 0)
+++ short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc	2008-05-31 05:09:21 UTC (rev 12066)
@@ -0,0 +1,283 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "ConstRateSlipFn.hh" // implementation of object methods
+
+#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
+#include "pylith/utils/array.hh" // USES double_array
+
+#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
+#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
+
+#include <assert.h> // USES assert()
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
+
+namespace pylith {
+  namespace faults {
+    namespace _ConstRateSlipFn {
+      const int offsetSlipTime = 0;
+    } // _ConstRateSlipFn
+  } // faults
+} // pylith
+
+// ----------------------------------------------------------------------
+// Default constructor.
+pylith::faults::ConstRateSlipFn::ConstRateSlipFn(void) :
+  _dbSlipRate(0),
+  _dbSlipTime(0),
+  _spaceDim(0)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor.
+pylith::faults::ConstRateSlipFn::~ConstRateSlipFn(void)
+{ // destructor
+  _dbSlipRate = 0;
+  _dbSlipTime = 0;
+} // destructor
+
+// ----------------------------------------------------------------------
+// Initialize slip time function.
+void
+pylith::faults::ConstRateSlipFn::initialize(
+				 const ALE::Obj<Mesh>& faultMesh,
+				 const spatialdata::geocoords::CoordSys* cs,
+				 const double originTime)
+{ // initialize
+  assert(!faultMesh.isNull());
+  assert(0 != cs);
+  assert(0 != _dbSlipRate);
+  assert(0 != _dbSlipTime);
+
+  _spaceDim = cs->spaceDim();
+  const int spaceDim = _spaceDim;
+  const int indexSlipRate = 0;
+  const int indexSlipTime = spaceDim + _ConstRateSlipFn::offsetSlipTime;
+
+  // Get vertices in fault mesh
+  const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
+  const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+
+  const int fiberDim = spaceDim + 1;
+  _parameters = new real_section_type(faultMesh->comm(), faultMesh->debug());
+  _parameters->addSpace(); // slip rate
+  _parameters->addSpace(); // slip time
+  assert(2 == _parameters->getNumSpaces());
+  _parameters->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(), vertices->end()), *std::max_element(vertices->begin(), vertices->end())+1));
+  _parameters->setFiberDimension(vertices, fiberDim);
+  _parameters->setFiberDimension(vertices, spaceDim, 0); // final slip
+  _parameters->setFiberDimension(vertices, 1, 1); // slip time
+  faultMesh->allocate(_parameters);
+  assert(!_parameters.isNull());
+
+  // Open databases and set query values
+  _dbSlipRate->open();
+  switch (spaceDim)
+    { // switch
+    case 1 : {
+      const char* slipValues[] = {"fault-opening"};
+      _dbSlipRate->queryVals(slipValues, 1);
+      break;
+    } // case 1
+    case 2 : {
+      const char* slipValues[] = {"left-lateral-slip", "fault-opening"};
+      _dbSlipRate->queryVals(slipValues, 2);
+      break;
+    } // case 2
+    case 3 : {
+      const char* slipValues[] = {"left-lateral-slip", "reverse-slip", 
+				  "fault-opening"};
+      _dbSlipRate->queryVals(slipValues, 3);
+      break;
+    } // case 3
+    default :
+      assert(0);
+    } // switch
+
+  _dbSlipTime->open();
+  const char* slipTimeValues[] = {"slip-time"};
+  _dbSlipTime->queryVals(slipTimeValues, 1);
+
+  // Get coordinates of vertices
+  const ALE::Obj<real_section_type>& coordinates = 
+    faultMesh->getRealSection("coordinates");
+  assert(!coordinates.isNull());
+
+  double_array paramsVertex(fiberDim);
+
+  for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+       v_iter != verticesEnd;
+       ++v_iter) {
+
+    // Get coordinates of vertex
+    const real_section_type::value_type* coordsVertex = 
+      coordinates->restrictPoint(*v_iter);
+    assert(0 != coordsVertex);
+    
+    int err = _dbSlipRate->query(&paramsVertex[indexSlipRate], spaceDim, 
+				 coordsVertex, spaceDim, cs);
+    if (err) {
+      std::ostringstream msg;
+      msg << "Could not slip rate at (";
+      for (int i=0; i < spaceDim; ++i)
+	msg << "  " << coordsVertex[i];
+      msg << ") using spatial database " << _dbSlipRate->label() << ".";
+      throw std::runtime_error(msg.str());
+    } // if
+
+    err = _dbSlipTime->query(&paramsVertex[indexSlipTime], 1, 
+			     coordsVertex, spaceDim, cs);
+    if (err) {
+      std::ostringstream msg;
+      msg << "Could not find slip initiation time at (";
+      for (int i=0; i < spaceDim; ++i)
+	msg << "  " << coordsVertex[i];
+      msg << ") using spatial database " << _dbSlipTime->label() << ".";
+      throw std::runtime_error(msg.str());
+    } // if
+    // add origin time to rupture time
+    paramsVertex[indexSlipTime] += originTime;
+
+    _parameters->updatePoint(*v_iter, &paramsVertex[0]);
+  } // for
+
+  // Close databases
+  _dbSlipRate->close();
+  _dbSlipTime->close();
+
+  // Allocate slip field
+  _slip = new real_section_type(faultMesh->comm(), faultMesh->debug());
+  _slip->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(), vertices->end()), *std::max_element(vertices->begin(), vertices->end())+1));
+  _slip->setFiberDimension(vertices, spaceDim);
+  faultMesh->allocate(_slip);
+  assert(!_slip.isNull());
+} // initialize
+
+// ----------------------------------------------------------------------
+// Get slip on fault surface at time t.
+const ALE::Obj<pylith::real_section_type>&
+pylith::faults::ConstRateSlipFn::slip(const double t,
+				  const ALE::Obj<Mesh>& faultMesh)
+{ // slip
+  assert(!_parameters.isNull());
+  assert(!_slip.isNull());
+  assert(!faultMesh.isNull());
+
+  const int spaceDim = _spaceDim;
+  const int indexSlipRate = 0;
+  const int indexSlipTime = spaceDim + _ConstRateSlipFn::offsetSlipTime;
+
+  double_array slipValues(spaceDim);
+  
+  // Get vertices in fault mesh
+  const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
+  const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+  const int numVertices = vertices->size();
+
+  for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+       v_iter != verticesEnd;
+       ++v_iter) {
+    const real_section_type::value_type* paramsVertex = 
+      _parameters->restrictPoint(*v_iter);
+    assert(0 != paramsVertex);
+
+    const double* slipRate = &paramsVertex[indexSlipRate];
+    const double slipTime = paramsVertex[indexSlipTime];
+    
+    const double relTime = t - slipTime;
+    if (relTime > 0)
+      for (int i=0; i < spaceDim; ++i)
+	slipValues[i] = slipRate[i] * relTime;
+    
+    // Update field
+    _slip->updatePoint(*v_iter, &slipValues[0]);
+  } // for
+
+  PetscLogFlops(numVertices * (1+1 + 4*spaceDim));
+
+  return _slip;
+} // slip
+
+// ----------------------------------------------------------------------
+// Get increment of slip on fault surface between time t0 and t1.
+const ALE::Obj<pylith::real_section_type>&
+pylith::faults::ConstRateSlipFn::slipIncr(const double t0,
+				      const double t1,
+				      const ALE::Obj<Mesh>& faultMesh)
+{ // slipIncr
+  assert(!_parameters.isNull());
+  assert(!_slip.isNull());
+  assert(!faultMesh.isNull());
+
+  const int spaceDim = _spaceDim;
+  const int indexSlipRate = 0;
+  const int indexSlipTime = spaceDim + _ConstRateSlipFn::offsetSlipTime;
+
+  double_array slipValues(spaceDim);
+  
+  // Get vertices in fault mesh
+  const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
+  const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+
+  int count = 0;
+  for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+       v_iter != verticesEnd;
+       ++v_iter, ++count) {
+    const real_section_type::value_type* paramsVertex = 
+      _parameters->restrictPoint(*v_iter);
+    assert(0 != paramsVertex);
+
+    const double* slipRate = &paramsVertex[indexSlipRate];
+    const double slipTime = paramsVertex[indexSlipTime];
+
+    const double relTime0 = t0 - slipTime;
+    const double relTime1 = t1 - slipTime;
+    double elapsedTime = 0.0;
+    if (relTime0 > 0)
+      elapsedTime = t1 - t0;
+    else if (relTime1 > 0)
+      elapsedTime = t1 - slipTime;
+    for (int i=0; i < spaceDim; ++i)
+      slipValues[i] = slipRate[i] * elapsedTime;
+    
+    // Update field
+    _slip->updatePoint(*v_iter, &slipValues[0]);
+  } // for
+
+  PetscLogFlops(count * (2 + spaceDim));
+
+  return _slip;
+} // slipIncr
+
+// ----------------------------------------------------------------------
+// Get final slip (slip rate).
+ALE::Obj<pylith::real_section_type>
+pylith::faults::ConstRateSlipFn::finalSlip(void)
+{ // finalSlip
+  // This is actually slip rate.
+  return _parameters->getFibration(0);
+} // finalSlip
+
+// ----------------------------------------------------------------------
+// Get time when slip begins at each point.
+ALE::Obj<pylith::real_section_type>
+pylith::faults::ConstRateSlipFn::slipTime(void)
+{ // slipTime
+  return _parameters->getFibration(2);
+} // slipTime
+
+
+// End of file 

Added: short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.hh	                        (rev 0)
+++ short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.hh	2008-05-31 05:09:21 UTC (rev 12066)
@@ -0,0 +1,143 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file libsrc/faults/ConstRateSlipFn.hh
+ *
+ * @brief C++ implementation of a constant slip rate slip time function.
+ *
+ * Slip time function follows the integral of constant slip rate slip
+ * time function.
+ *
+ * Normalized slip = sliprate * (t - t0)
+ */
+
+#if !defined(pylith_faults_constrateslipfn_hh)
+#define pylith_faults_constrateslipfn_hh
+
+#include "SlipTimeFn.hh"
+
+/// Namespace for pylith package
+namespace pylith {
+  namespace faults {
+    class ConstRateSlipFn;
+    class TestConstRateSlipFn; // unit testing
+  } // faults
+} // pylith
+
+/// Namespace for spatialdata package
+namespace spatialdata {
+  namespace spatialdb {
+    class SpatialDB;
+  } // spatialdb
+} // spatialdata
+
+/// C++ implementation of ConstRate slip time function.
+class pylith::faults::ConstRateSlipFn : public SlipTimeFn
+{ // class ConstRateSlipFn
+  friend class TestConstRateSlipFn; // unit testing
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+  /// Default constructor.
+  ConstRateSlipFn(void);
+
+  /// Destructor.
+  virtual
+  ~ConstRateSlipFn(void);
+
+  /** Set spatial database for slip rate.
+   *
+   * @param db Spatial database
+   */
+  void dbSlipRate(spatialdata::spatialdb::SpatialDB* const db);
+
+  /** Set spatial database for slip initiation time.
+   *
+   * @param db Spatial database
+   */
+  void dbSlipTime(spatialdata::spatialdb::SpatialDB* const db);
+
+  /** Initialize slip time function.
+   *
+   * @param faultMesh Finite-element mesh of fault.
+   * @param cs Coordinate system for mesh.
+   * @param originTime Origin time for earthquake source.
+   */
+  void initialize(const ALE::Obj<Mesh>& faultMesh,
+		  const spatialdata::geocoords::CoordSys* cs,
+		  const double originTime =0.0);
+
+  /** Get slip on fault surface at time t.
+   *
+   * @param t Time t.
+   * @param faultMesh Mesh over fault surface.
+   */
+  const ALE::Obj<real_section_type>& slip(const double t,
+					  const ALE::Obj<Mesh>& faultMesh);
+
+  /** Get slip increment on fault surface between time t0 and t1.
+   *
+   * @param t0 Time t.
+   * @param t1 Time t+dt.
+   * @param faultMesh Mesh over fault surface.
+   */
+  const ALE::Obj<real_section_type>& slipIncr(const double t0,
+					      const double t1,
+					      const ALE::Obj<Mesh>& faultMesh);
+
+  /** Get final slip.
+   *
+   * @returns Final slip.
+   */
+  ALE::Obj<real_section_type> finalSlip(void);
+
+  /** Get time when slip begins at each point.
+   *
+   * @returns Time when slip begins.
+   */
+  ALE::Obj<real_section_type> slipTime(void);
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+  /// Not implemented
+  ConstRateSlipFn(const ConstRateSlipFn& m);
+
+  /// Not implemented
+  const ConstRateSlipFn& operator=(const ConstRateSlipFn& f);
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+  /// Parameters for ConstRate slip time function.
+  /// Final slip (vector), peak slip rate (scalar), slip time (scalar).
+  ALE::Obj<real_section_type> _parameters;
+
+  ALE::Obj<real_section_type> _slip; ///< Slip field on fault surface
+
+  /// Spatial database for final slip
+  spatialdata::spatialdb::SpatialDB* _dbSlipRate;
+
+  /// Spatial database for slip time
+  spatialdata::spatialdb::SpatialDB* _dbSlipTime;
+
+  int _spaceDim; ///< Spatial dimension for slip field.
+
+}; // class ConstRateSlipFn
+
+#include "ConstRateSlipFn.icc" // inline methods
+
+#endif // pylith_faults_constrateslipfn_hh
+
+
+// End of file 

Added: short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.icc	                        (rev 0)
+++ short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.icc	2008-05-31 05:09:21 UTC (rev 12066)
@@ -0,0 +1,35 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#if !defined(pylith_faults_constrateslipfn_hh)
+#error "ConstRateSlipFn.icc can only be included from ConstRateSlipFn.hh"
+#endif
+
+#include <math.h> // USES exp()
+#include <assert.h> // USES assert()
+
+// Set spatial database for slip rate.
+inline
+void
+pylith::faults::ConstRateSlipFn::dbSlipRate(spatialdata::spatialdb::SpatialDB* const db) {
+  _dbSlipRate = db;
+} // dbFinalSlip
+
+// Set spatial database for slip initiation time.
+inline
+void
+pylith::faults::ConstRateSlipFn::dbSlipTime(spatialdata::spatialdb::SpatialDB* const db) {
+  _dbSlipTime = db;
+} // dbSlipTime
+
+
+// End of file 

Modified: short/3D/PyLith/trunk/libsrc/faults/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/Makefile.am	2008-05-31 02:10:02 UTC (rev 12065)
+++ short/3D/PyLith/trunk/libsrc/faults/Makefile.am	2008-05-31 05:09:21 UTC (rev 12066)
@@ -16,6 +16,8 @@
 subpkginclude_HEADERS = \
 	BruneSlipFn.hh \
 	BruneSlipFn.icc \
+	ConstRateSlipFn.hh \
+	ConstRateSlipFn.icc \
 	CohesiveTopology.hh \
 	EqKinSrc.hh \
 	Fault.hh \

Modified: short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src	2008-05-31 02:10:02 UTC (rev 12065)
+++ short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src	2008-05-31 05:09:21 UTC (rev 12066)
@@ -17,6 +17,7 @@
 #include "pylith/faults/EqKinSrc.hh"
 #include "pylith/faults/SlipTimeFn.hh"
 #include "pylith/faults/BruneSlipFn.hh"
+#include "pylith/faults/ConstRateSlipFn.hh"
 
 #include "pylith/utils/array.hh"
 
@@ -1009,4 +1010,98 @@
       BruneSlipFn_dbPeakRate_set(self.thisptr, ptrFromHandle(value))
 
 
+# ----------------------------------------------------------------------
+cdef class ConstRateSlipFn(SlipTimeFn):
+
+  def __init__(self):
+    """
+    Constructor.
+    """
+    # create shim for constructor
+    #embed{ void* ConstRateSlipFn_constructor()
+    void* result = 0;
+    try {
+      result = (void*)(new pylith::faults::ConstRateSlipFn);
+      assert(0 != result);
+    } catch (const std::exception& err) {
+      PyErr_SetString(PyExc_RuntimeError,
+                      const_cast<char*>(err.what()));
+    } catch (const ALE::Exception& err) {
+      PyErr_SetString(PyExc_RuntimeError,
+                      const_cast<char*>(err.msg().c_str()));
+    } catch (...) {
+      PyErr_SetString(PyExc_RuntimeError,
+                      "Caught unknown C++ exception.");
+    } // try/catch
+    return result;
+    #}embed
+
+    SlipTimeFn.__init__(self)
+    self.thisptr = ConstRateSlipFn_constructor()
+    self.handle = self._createHandle()
+    return
+
+
+  property dbSlipRate:
+    def __set__(self, value):
+      """
+      Set database for slip rate.
+      """
+      # create shim for method 'dbSlipRate'
+      #embed{ void ConstRateSlipFn_dbSlipRate_set(void* objVptr, void* dbVptr)
+      try {
+        assert(0 != objVptr);
+        assert(0 != dbVptr);
+        spatialdata::spatialdb::SpatialDB* db =
+          (spatialdata::spatialdb::SpatialDB*) dbVptr;
+        ((pylith::faults::ConstRateSlipFn*) objVptr)->dbSlipRate(db);
+      } catch (const std::exception& err) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        const_cast<char*>(err.what()));
+      } catch (const ALE::Exception& err) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        const_cast<char*>(err.msg().c_str()));
+      } catch (...) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        "Caught unknown C++ exception.");
+      } // try/catch
+      #}embed
+      if not value.name == "spatialdata_spatialdb_SpatialDB":
+        raise TypeError, \
+              "Argument must be extension module type " \
+              "'spatialdata::spatialdb::SpatialDB'."
+      ConstRateSlipFn_dbSlipRate_set(self.thisptr, ptrFromHandle(value))
+
+
+  property dbSlipTime:
+    def __set__(self, value):
+      """
+      Set database for slip initiation time.
+      """
+      # create shim for method 'dbSlipTime'
+      #embed{ void ConstRateSlipFn_dbSlipTime_set(void* objVptr, void* dbVptr)
+      try {
+        assert(0 != objVptr);
+        assert(0 != dbVptr);
+        spatialdata::spatialdb::SpatialDB* db =
+          (spatialdata::spatialdb::SpatialDB*) dbVptr;
+        ((pylith::faults::ConstRateSlipFn*) objVptr)->dbSlipTime(db);
+      } catch (const std::exception& err) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        const_cast<char*>(err.what()));
+      } catch (const ALE::Exception& err) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        const_cast<char*>(err.msg().c_str()));
+      } catch (...) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        "Caught unknown C++ exception.");
+      } // try/catch
+      #}embed
+      if not value.name == "spatialdata_spatialdb_SpatialDB":
+        raise TypeError, \
+              "Argument must be extension module type " \
+              "'spatialdata::spatialdb::SpatialDB'."
+      ConstRateSlipFn_dbSlipTime_set(self.thisptr, ptrFromHandle(value))
+
+
 # End of file 

Modified: short/3D/PyLith/trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/pylith/Makefile.am	2008-05-31 02:10:02 UTC (rev 12065)
+++ short/3D/PyLith/trunk/pylith/Makefile.am	2008-05-31 05:09:21 UTC (rev 12066)
@@ -22,6 +22,7 @@
 	bc/Neumann.py \
 	faults/__init__.py \
 	faults/BruneSlipFn.py \
+	faults/ConstRateSlipFn.py \
 	faults/EqKinSrc.py \
 	faults/Fault.py \
 	faults/FaultCohesive.py \

Added: short/3D/PyLith/trunk/pylith/faults/ConstRateSlipFn.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/ConstRateSlipFn.py	                        (rev 0)
+++ short/3D/PyLith/trunk/pylith/faults/ConstRateSlipFn.py	2008-05-31 05:09:21 UTC (rev 12066)
@@ -0,0 +1,119 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/faults/ConstRateSlipFn.py
+##
+## @brief Python object for a constant slip rate slip time function.
+##
+## Factory: slip_time_fn
+
+from SlipTimeFn import SlipTimeFn
+
+# ConstRateSlipFn class
+class ConstRateSlipFn(SlipTimeFn):
+  """
+  Python object for a constant slip rate slip time function.
+
+  Factory: slip_time_fn
+  """
+
+  # INVENTORY //////////////////////////////////////////////////////////
+
+  class Inventory(SlipTimeFn.Inventory):
+    """
+    Python object for managing ConstRateSlipFn facilities and properties.
+    """
+    
+    ## @class Inventory
+    ## Python object for managing ConstRateSlipFn facilities and properties.
+    ##
+    ## \b Properties
+    ## @li None
+    ##
+    ## \b Facilities
+    ## @li \b slip_rate Spatial database of peak slip rate
+    ## @li \b slip_time Spatial database of slip initiation time
+
+    import pyre.inventory
+
+    from spatialdata.spatialdb.SimpleDB import SimpleDB
+
+    slipTime = pyre.inventory.facility("slip_time", family="spatial_database",
+                                       factory=SimpleDB)
+    slipTime.meta['tip'] = "Spatial database of slip initiation time."
+
+    slipRate = pyre.inventory.facility("slip_rate", family="spatial_database",
+                                       factory=SimpleDB)
+    slipRate.meta['tip'] = "Spatial database of peak slip rate."
+
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="bruneslipfn"):
+    """
+    Constructor.
+    """
+    SlipTimeFn.__init__(self, name)
+    self._loggingPrefix = "CrSF "
+    return
+
+
+  def initialize(self):
+    """
+    Initialize.
+    """
+    logEvent = "%sinit" % self._loggingPrefix
+    self._logger.eventBegin(logEvent)
+
+    self.slipRate.initialize()
+    self.slipTime.initialize()
+    assert(None != self.cppHandle)
+
+    self.cppHandle.dbSlipRate = self.slipRate.cppHandle
+    self.cppHandle.dbSlipTime = self.slipTime.cppHandle
+
+    self._logger.eventEnd(logEvent)
+    return
+
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _configure(self):
+    """
+    Setup members using inventory.
+    """
+    SlipTimeFn._configure(self)
+    self.slipRate = self.inventory.slipRate
+    self.slipTime = self.inventory.slipTime
+    return
+
+
+  def _createCppHandle(self):
+    """
+    Create handle to C++ object.
+    """
+    if None == self.cppHandle:
+      import pylith.faults.faults as bindings
+      self.cppHandle = bindings.ConstRateSlipFn()
+    return
+  
+  
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def slip_time_fn():
+  """
+  Factory associated with ConstRateSlipFn.
+  """
+  return slip_time_fn()
+
+
+# End of file 

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am	2008-05-31 02:10:02 UTC (rev 12065)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am	2008-05-31 05:09:21 UTC (rev 12066)
@@ -22,6 +22,7 @@
 # Primary source files
 testfaults_SOURCES = \
 	TestBruneSlipFn.cc \
+	TestConstRateSlipFn.cc \
 	TestEqKinSrc.cc \
 	TestFault.cc \
 	TestFaultCohesive.cc \
@@ -42,6 +43,7 @@
 
 noinst_HEADERS = \
 	TestBruneSlipFn.hh \
+	TestConstRateSlipFn.hh \
 	TestEqKinSrc.hh \
 	TestFault.hh \
 	TestFaultCohesive.hh \

Added: short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.cc	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.cc	2008-05-31 05:09:21 UTC (rev 12066)
@@ -0,0 +1,405 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestConstRateSlipFn.hh" // Implementation of class methods
+
+#include "pylith/faults/ConstRateSlipFn.hh" // USES ConstRateSlipFn
+
+#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
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::faults::TestConstRateSlipFn );
+
+// ----------------------------------------------------------------------
+namespace pylith {
+  namespace faults {
+    namespace _TestConstRateSlipFn {
+      struct DataStruct {
+	const char* meshFilename;
+	const char* faultLabel;
+	const int faultId;
+	const char* slipRateFilename;
+	const char* slipTimeFilename;
+	const int* constraintPts;
+	const double* slipRateE;
+	const double* slipTimeE;
+	const int numConstraintPts;
+      }; // DataStruct
+    } // _TestConstRateSlipFn
+  } // faults
+} // pylith
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::faults::TestConstRateSlipFn::testConstructor(void)
+{ // testConstructor
+  ConstRateSlipFn slipfn;
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test dbFinalSlip().
+void
+pylith::faults::TestConstRateSlipFn::testDbSlipRate(void)
+{ // testDbFinalSlip
+  const char* label = "database ABC";
+  ConstRateSlipFn slipfn;
+  
+  spatialdata::spatialdb::SimpleDB db(label);
+  slipfn.dbSlipRate(&db);
+
+  CPPUNIT_ASSERT(0 != slipfn._dbSlipRate);
+  CPPUNIT_ASSERT_EQUAL(std::string(label),
+		       std::string(slipfn._dbSlipRate->label()));
+  CPPUNIT_ASSERT(0 == slipfn._dbSlipTime);
+} // testDbSlipRate
+
+// ----------------------------------------------------------------------
+// Test dbSlipTime().
+void
+pylith::faults::TestConstRateSlipFn::testDbSlipTime(void)
+{ // testDbSlipTime
+  const char* label = "database ABCD";
+  ConstRateSlipFn slipfn;
+  
+  spatialdata::spatialdb::SimpleDB db(label);
+  slipfn.dbSlipTime(&db);
+
+  CPPUNIT_ASSERT(0 != slipfn._dbSlipTime);
+  CPPUNIT_ASSERT_EQUAL(std::string(label),
+		       std::string(slipfn._dbSlipTime->label()));
+  CPPUNIT_ASSERT(0 == slipfn._dbSlipRate);
+} // testDbSlipTime
+
+// ----------------------------------------------------------------------
+// Test initialize() in 1-D.
+void
+pylith::faults::TestConstRateSlipFn::testInitialize1D(void)
+{ // testInitialize1D
+  const char* meshFilename = "data/line2.mesh";
+  const char* faultLabel = "fault";
+  const int faultId = 2;
+  const char* slipRateFilename = "data/line2_sliprate.spatialdb";
+  const char* slipTimeFilename = "data/line2_sliptime.spatialdb";
+  const int constraintPts[] = { 3 };
+  const double slipRateE[] = { 0.4 };
+  const double slipTimeE[] = { 1.2 };
+  const int numConstraintPts = 1;
+
+  _TestConstRateSlipFn::DataStruct data = {meshFilename,
+					   faultLabel,
+					   faultId,
+					   slipRateFilename,
+					   slipTimeFilename,
+					   constraintPts,
+					   slipRateE,
+					   slipTimeE,
+					   numConstraintPts};
+  _testInitialize(data);
+} // testInitialize1D
+
+// ----------------------------------------------------------------------
+// Test initialize() in 2-D.
+void
+pylith::faults::TestConstRateSlipFn::testInitialize2D(void)
+{ // testInitialize2D
+  const char* meshFilename = "data/tri3.mesh";
+  const char* faultLabel = "fault";
+  const int faultId = 2;
+  const char* slipRateFilename = "data/tri3_sliprate.spatialdb";
+  const char* slipTimeFilename = "data/tri3_sliptime.spatialdb";
+  const int constraintPts[] = { 3, 4 };
+  const double slipRateE[] = { 0.1, 0.2, 
+			       0.3, 0.4 };
+  const double slipTimeE[] = { 1.2, 1.3 };
+  const int numConstraintPts = 2;
+
+  _TestConstRateSlipFn::DataStruct data = {meshFilename,
+					   faultLabel,
+					   faultId,
+					   slipRateFilename,
+					   slipTimeFilename,
+					   constraintPts,
+					   slipRateE,
+					   slipTimeE,
+					   numConstraintPts};
+  _testInitialize(data);
+} // testInitialize2D
+
+// ----------------------------------------------------------------------
+// Test initialize() in 3-D.
+void
+pylith::faults::TestConstRateSlipFn::testInitialize3D(void)
+{ // testInitialize3D
+  const char* meshFilename = "data/tet4.mesh";
+  const char* faultLabel = "fault";
+  const int faultId = 2;
+  const char* slipRateFilename = "data/tet4_sliprate.spatialdb";
+  const char* slipTimeFilename = "data/tet4_sliptime.spatialdb";
+  const int constraintPts[] = { 3, 4, 5 };
+  const double slipRateE[] = { 1.6, -0.7, 0.1,
+			       1.7, -0.8, 0.2,
+			       1.8, -0.9, 0.3 };
+  const double slipTimeE[] = { 1.2, 1.3, 1.4 };
+  const int numConstraintPts = 3;
+
+  _TestConstRateSlipFn::DataStruct data = {meshFilename,
+					   faultLabel,
+					   faultId,
+					   slipRateFilename,
+					   slipTimeFilename,
+					   constraintPts,
+					   slipRateE,
+					   slipTimeE,
+					   numConstraintPts};
+  _testInitialize(data);
+} // testInitialize3D
+
+// ----------------------------------------------------------------------
+// Test slip().
+void
+pylith::faults::TestConstRateSlipFn::testSlip(void)
+{ // testSlip
+  const double slipRateE[] = { 0.1, 0.2, 
+			       0.3, 0.4};
+  const double slipTimeE[] = { 1.2, 1.3 };
+  const double originTime = 5.064;
+
+  ALE::Obj<Mesh> faultMesh;
+  ConstRateSlipFn slipfn;
+  _initialize(&faultMesh, &slipfn, originTime);
+  
+  const int spaceDim = faultMesh->getDimension() + 1;
+
+  const double t = 2.134;
+  const ALE::Obj<real_section_type>& slip = slipfn.slip(originTime+t, faultMesh);
+  CPPUNIT_ASSERT(!slip.isNull());
+
+  const double tolerance = 1.0e-06;
+  
+  const ALE::Obj<Mesh::label_sequence>& vertices = 
+    faultMesh->depthStratum(0);
+  const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+
+  int iPoint = 0;
+  for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+       v_iter != verticesEnd;
+       ++v_iter, ++iPoint) {
+    const double t0 = slipTimeE[iPoint];
+    const int fiberDim = slip->getFiberDimension(*v_iter);
+    CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
+    const real_section_type::value_type* vals = 
+      slip->restrictPoint(*v_iter);
+    CPPUNIT_ASSERT(0 != vals);
+
+    for (int iDim=0; iDim < fiberDim; ++iDim) {
+      const double slipE = 
+	slipRateE[iPoint*spaceDim+iDim] * (t - slipTimeE[iPoint]);
+      CPPUNIT_ASSERT_DOUBLES_EQUAL(slipE, vals[iDim], tolerance);
+    } // for
+  } // for
+} // testSlip
+
+// ----------------------------------------------------------------------
+// Test slipIncr().
+void
+pylith::faults::TestConstRateSlipFn::testSlipIncr(void)
+{ // testSlipIncr
+  const double slipRateE[] = { 0.1, 0.2, 
+			       0.3, 0.4 };
+  const double slipTimeE[] = { 1.2, 1.3 };
+  const double originTime = 1.064;
+
+  ALE::Obj<Mesh> faultMesh;
+  ConstRateSlipFn slipfn;
+  _initialize(&faultMesh, &slipfn, originTime);
+
+  const int spaceDim = faultMesh->getDimension() + 1;
+
+  const double t0 = 1.234;
+  const double t1 = 3.635;
+  const ALE::Obj<real_section_type>& slip = 
+    slipfn.slipIncr(originTime+t0, originTime+t1, faultMesh);
+  CPPUNIT_ASSERT(!slip.isNull());
+
+  const double tolerance = 1.0e-06;
+
+  const ALE::Obj<Mesh::label_sequence>& vertices = 
+    faultMesh->depthStratum(0);
+  const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+
+  int iPoint = 0;
+  for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+       v_iter != verticesEnd;
+       ++v_iter, ++iPoint) {
+
+    const int fiberDim = slip->getFiberDimension(*v_iter);
+    CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
+    const real_section_type::value_type* vals = 
+      slip->restrictPoint(*v_iter);
+    CPPUNIT_ASSERT(0 != vals);
+
+    for (int iDim=0; iDim < fiberDim; ++iDim) {
+      const double tRef = (slipTimeE[iPoint] > t0) ? slipTimeE[iPoint] : t0;
+      const double slipE = 
+	slipRateE[iPoint*spaceDim+iDim] * (t1 - tRef);
+      CPPUNIT_ASSERT_DOUBLES_EQUAL(slipE, vals[iDim], tolerance);
+    } // for
+  } // for
+} // testSlipIncr
+
+// ----------------------------------------------------------------------
+// Initialize ConstRateSlipFn.
+void
+pylith::faults::TestConstRateSlipFn::_initialize(ALE::Obj<Mesh>* faultMesh,
+						 ConstRateSlipFn* slipfn,
+						 const double originTime)
+{ // _initialize
+  assert(0 != slipfn);
+
+  const char* meshFilename = "data/tri3.mesh";
+  const char* faultLabel = "fault";
+  const int faultId = 2;
+  const char* slipRateFilename = "data/tri3_sliprate.spatialdb";
+  const char* slipTimeFilename = "data/tri3_sliptime.spatialdb";
+
+  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
+  const bool useLagrangeConstraints = true;
+  CohesiveTopology::create(faultMesh, mesh, 
+			   mesh->getIntSection(faultLabel),
+			   faultId);
+  CPPUNIT_ASSERT(!faultMesh->isNull());
+  // Need to copy coordinates from mesh to fault mesh since we are not
+  // using create() instead of createParallel().
+  (*faultMesh)->setRealSection("coordinates", 
+			       mesh->getRealSection("coordinates"));
+
+  // Setup databases
+  spatialdata::spatialdb::SimpleDB dbSlipRate("slip rate");
+  spatialdata::spatialdb::SimpleIOAscii ioSlipRate;
+  ioSlipRate.filename(slipRateFilename);
+  dbSlipRate.ioHandler(&ioSlipRate);
+  
+  spatialdata::spatialdb::SimpleDB dbSlipTime("slip time");
+  spatialdata::spatialdb::SimpleIOAscii ioSlipTime;
+  ioSlipTime.filename(slipTimeFilename);
+  dbSlipTime.ioHandler(&ioSlipTime);
+  
+  // setup ConstRateSlipFn
+  slipfn->dbSlipRate(&dbSlipRate);
+  slipfn->dbSlipTime(&dbSlipTime);
+  
+  slipfn->initialize(*faultMesh, &cs, originTime);
+} // _initialize
+
+// ----------------------------------------------------------------------
+// Test initialize().
+void
+pylith::faults::TestConstRateSlipFn::_testInitialize(const _TestConstRateSlipFn::DataStruct& data)
+{ // _testInitialize
+  typedef std::set<Mesh::point_type>::const_iterator vert_iterator;  
+
+  // Setup mesh
+  ALE::Obj<Mesh> mesh;
+  meshio::MeshIOAscii meshIO;
+  meshIO.filename(data.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(data.faultLabel),
+			   data.faultId);
+  CPPUNIT_ASSERT(!faultMesh.isNull());
+  // Need to copy coordinates from mesh to fault mesh since we are not
+  // using create() instead of createParallel().
+  faultMesh->setRealSection("coordinates", 
+			    mesh->getRealSection("coordinates"));
+
+  // Setup databases
+  spatialdata::spatialdb::SimpleDB dbSlipRate("slip rate");
+  spatialdata::spatialdb::SimpleIOAscii ioSlipRate;
+  ioSlipRate.filename(data.slipRateFilename);
+  dbSlipRate.ioHandler(&ioSlipRate);
+  
+  spatialdata::spatialdb::SimpleDB dbSlipTime("slip time");
+  spatialdata::spatialdb::SimpleIOAscii ioSlipTime;
+  ioSlipTime.filename(data.slipTimeFilename);
+  dbSlipTime.ioHandler(&ioSlipTime);
+  
+  // setup ConstRateSlipFn
+  ConstRateSlipFn slipfn;
+  slipfn.dbSlipRate(&dbSlipRate);
+  slipfn.dbSlipTime(&dbSlipTime);
+  
+  const double originTime = 5.353;
+  
+  slipfn.initialize(faultMesh, &cs, originTime);
+
+  const double tolerance = 1.0e-06;
+
+  const ALE::Obj<Mesh::label_sequence>& vertices = 
+    faultMesh->depthStratum(0);
+  const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+
+  int iPoint = 0;
+  for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+       v_iter != verticesEnd;
+       ++v_iter, ++iPoint) {
+    const int fiberDim = slipfn._parameters->getFiberDimension(*v_iter);
+    CPPUNIT_ASSERT_EQUAL(spaceDim+1, fiberDim);
+    
+    const real_section_type::value_type* vals = 
+      slipfn._parameters->restrictPoint(*v_iter);
+    CPPUNIT_ASSERT(0 != vals);
+
+    for (int iDim=0; iDim < spaceDim; ++iDim)
+      CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipRateE[iPoint*spaceDim+iDim],
+				   vals[iDim],
+				   tolerance);
+
+    const double slipTime = vals[spaceDim];
+
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipTimeE[iPoint]+originTime,
+				 slipTime, tolerance);
+  } // for
+} // _testInitialize
+
+
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.hh	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.hh	2008-05-31 05:09:21 UTC (rev 12066)
@@ -0,0 +1,111 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/faults/TestConstRateSlipFn.hh
+ *
+ * @brief C++ TestConstRateSlipFn object
+ *
+ * C++ unit testing for ConstRateSlipFn.
+ */
+
+#if !defined(pylith_faults_testconstrateslipfn_hh)
+#define pylith_faults_testconstrateslipfn_hh
+
+#include "pylith/utils/sievetypes.hh" // USES Mesh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+/// Namespace for pylith package
+namespace pylith {
+  namespace faults {
+    class TestConstRateSlipFn;
+    class ConstRateSlipFn;
+
+    namespace _TestConstRateSlipFn {
+      struct DataStruct;
+    } // _ConstRateSlipTimeFn
+  } // faults
+} // pylith
+
+/// C++ unit testing for ConstRateSlipFn
+class pylith::faults::TestConstRateSlipFn : public CppUnit::TestFixture
+{ // class TestConstRateSlipFn
+
+  // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+  CPPUNIT_TEST_SUITE( TestConstRateSlipFn );
+
+  CPPUNIT_TEST( testConstructor );
+  CPPUNIT_TEST( testDbSlipRate );
+  CPPUNIT_TEST( testDbSlipTime );
+  CPPUNIT_TEST( testInitialize1D );
+  CPPUNIT_TEST( testInitialize2D );
+  CPPUNIT_TEST( testInitialize3D );
+  CPPUNIT_TEST( testSlip );
+  CPPUNIT_TEST( testSlipIncr );
+
+  CPPUNIT_TEST_SUITE_END();
+
+  // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+  /// Test constructor.
+  void testConstructor(void);
+
+  /// Test dbSlipRate().
+  void testDbSlipRate(void);
+
+  /// Test dbSlipTime().
+  void testDbSlipTime(void);
+
+  /// Test initialize() in 1-D.
+  void testInitialize1D(void);
+
+  /// Test initialize() in 2-D.
+  void testInitialize2D(void);
+
+  /// Test initialize() in 3-D.
+  void testInitialize3D(void);
+
+  /// Test slip().
+  void testSlip(void);
+
+  /// Test slipIncr().
+  void testSlipIncr(void);
+
+  // PRIVATE METHODS ////////////////////////////////////////////////////
+private :
+
+  /** Initialize ConstRateSlipFn.
+   *
+   * @param faultMesh Fault mesh.
+   * @param slipfn ConstRate slip function.
+   * @param originTime Origin time for earthquake rupture.
+   */
+  static
+  void _initialize(ALE::Obj<Mesh>* faultMesh,
+		   ConstRateSlipFn* slipfn,
+		   const double originTime);
+
+  /** Test intialize().
+   *
+   * @param data Data for initialization and testing of ConstRateSlipFn.
+   */
+  static
+  void _testInitialize(const _TestConstRateSlipFn::DataStruct& data);
+
+}; // class TestConstRateSlipFn
+
+#endif // pylith_faults_testconstrateslipfn_hh
+
+
+// End of file 

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/Makefile.am	2008-05-31 02:10:02 UTC (rev 12065)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/Makefile.am	2008-05-31 05:09:21 UTC (rev 12066)
@@ -18,6 +18,7 @@
 	line2_finalslip.spatialdb \
 	line2_sliptime.spatialdb \
 	line2_peakrate.spatialdb \
+	line2_sliprate.spatialdb \
 	tri3.mesh \
 	tri3b.mesh \
 	tri3c.mesh \
@@ -28,6 +29,7 @@
 	tri3_finalslipB.spatialdb \
 	tri3_sliptime.spatialdb \
 	tri3_peakrate.spatialdb \
+	tri3_sliprate.spatialdb \
 	tri3d_finalslip.spatialdb \
 	tri3d_sliptime.spatialdb \
 	tri3d_peakrate.spatialdb \
@@ -58,6 +60,7 @@
 	tet4_finalslip.spatialdb \
 	tet4_sliptime.spatialdb \
 	tet4_peakrate.spatialdb \
+	tet4_sliprate.spatialdb \
 	tet4e_finalslip.spatialdb \
 	tet4e_sliptime.spatialdb \
 	tet4e_peakrate.spatialdb \

Added: short/3D/PyLith/trunk/unittests/libtests/faults/data/line2_sliprate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/line2_sliprate.spatialdb	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/line2_sliprate.spatialdb	2008-05-31 05:09:21 UTC (rev 12066)
@@ -0,0 +1,14 @@
+#SPATIAL.ascii 1
+SimpleDB {
+  num-values = 1
+  value-names =  fault-opening
+  value-units =  m
+  num-locs = 1
+  data-dim = 0
+  space-dim = 1
+  cs-data = cartesian {
+    to-meters = 1.0
+    space-dim = 1
+  }
+}
+0.0   0.4

Added: short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4_sliprate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4_sliprate.spatialdb	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4_sliprate.spatialdb	2008-05-31 05:09:21 UTC (rev 12066)
@@ -0,0 +1,16 @@
+#SPATIAL.ascii 1
+SimpleDB {
+  num-values = 3
+  value-names =  left-lateral-slip  reverse-slip  fault-opening
+  value-units =  m   m   m
+  num-locs = 3
+  data-dim = 2
+  space-dim = 3
+  cs-data = cartesian {
+    to-meters = 1.0
+    space-dim = 3
+  }
+}
+0.0  -1.0  0.0    1.6  -0.7  0.1
+0.0   0.0  1.0    1.7  -0.8  0.2
+0.0   1.0  0.0    1.8  -0.9  0.3

Added: short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3_sliprate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3_sliprate.spatialdb	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3_sliprate.spatialdb	2008-05-31 05:09:21 UTC (rev 12066)
@@ -0,0 +1,15 @@
+#SPATIAL.ascii 1
+SimpleDB {
+  num-values = 2
+  value-names =  left-lateral-slip fault-opening
+  value-units =  m   m
+  num-locs = 2
+  data-dim = 1
+  space-dim = 2
+  cs-data = cartesian {
+    to-meters = 1.0
+    space-dim = 2
+  }
+}
+0.0  +1.0   0.1   0.2
+0.0  -1.0   0.3   0.4

Modified: short/3D/PyLith/trunk/unittests/pytests/faults/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/Makefile.am	2008-05-31 02:10:02 UTC (rev 12065)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/Makefile.am	2008-05-31 05:09:21 UTC (rev 12066)
@@ -22,6 +22,7 @@
 
 noinst_PYTHON = \
 	TestBruneSlipFn.py \
+	TestConstRateSlipFn.py \
 	TestFault.py \
 	TestFaultCohesive.py \
 	TestFaultCohesiveKin.py \

Added: short/3D/PyLith/trunk/unittests/pytests/faults/TestConstRateSlipFn.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/TestConstRateSlipFn.py	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/TestConstRateSlipFn.py	2008-05-31 05:09:21 UTC (rev 12066)
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/faults/TestConstRateSlipFn.py
+
+## @brief Unit testing of ConstRateSlipFn object.
+
+import unittest
+
+from pylith.faults.ConstRateSlipFn import ConstRateSlipFn
+
+# ----------------------------------------------------------------------
+class TestConstRateSlipFn(unittest.TestCase):
+  """
+  Unit testing of ConstRateSlipFn object.
+  """
+
+  def test_constructor(self):
+    """
+    Test constructor.
+    """
+    slipFn = ConstRateSlipFn()
+    slipFn._createCppHandle()
+    self.failIfEqual(None, slipFn.cppHandle)
+    return
+
+
+  def test_initialize(self):
+    """
+    Test initialize().
+    """
+    from spatialdata.spatialdb.SimpleDB import SimpleDB
+    from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
+
+    ioSlipRate = SimpleIOAscii()
+    ioSlipRate.filename = "sliprate.spatialdb"
+    dbSlipRate = SimpleDB()
+    dbSlipRate.iohandler = ioSlipRate
+    dbSlipRate.label = "slip rate"
+    
+    ioSlipTime = SimpleIOAscii()
+    ioSlipTime.filename = "sliptime.spatialdb"
+    dbSlipTime = SimpleDB()
+    dbSlipTime.iohandler = ioSlipTime
+    dbSlipTime.label = "slip time"
+    
+    slipFn = ConstRateSlipFn()
+    slipFn.slipRate = dbSlipRate
+    slipFn.slipTime = dbSlipTime
+    slipFn.preinitialize()
+    slipFn.initialize()
+    return
+
+
+# End of file 

Modified: short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py	2008-05-31 02:10:02 UTC (rev 12065)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py	2008-05-31 05:09:21 UTC (rev 12066)
@@ -59,6 +59,9 @@
     from TestBruneSlipFn import TestBruneSlipFn
     suite.addTest(unittest.makeSuite(TestBruneSlipFn))
 
+    from TestConstRateSlipFn import TestConstRateSlipFn
+    suite.addTest(unittest.makeSuite(TestConstRateSlipFn))
+
     from TestEqKinSrc import TestEqKinSrc
     suite.addTest(unittest.makeSuite(TestEqKinSrc))
 



More information about the cig-commits mailing list