[cig-commits] r16737 - in short/3D/PyLith/trunk/templates/friction: . tests

brad at geodynamics.org brad at geodynamics.org
Mon May 17 20:58:16 PDT 2010


Author: brad
Date: 2010-05-17 20:58:16 -0700 (Mon, 17 May 2010)
New Revision: 16737

Added:
   short/3D/PyLith/trunk/templates/friction/tests/
   short/3D/PyLith/trunk/templates/friction/tests/Makefile.am
   short/3D/PyLith/trunk/templates/friction/tests/TestViscousFriction.py
   short/3D/PyLith/trunk/templates/friction/tests/testcontrib.py
Modified:
   short/3D/PyLith/trunk/templates/friction/ViscousFriction.cc
   short/3D/PyLith/trunk/templates/friction/ViscousFriction.hh
   short/3D/PyLith/trunk/templates/friction/ViscousFriction.i
   short/3D/PyLith/trunk/templates/friction/ViscousFriction.py
   short/3D/PyLith/trunk/templates/friction/configure.ac
Log:
Finished friction template.

Modified: short/3D/PyLith/trunk/templates/friction/ViscousFriction.cc
===================================================================
--- short/3D/PyLith/trunk/templates/friction/ViscousFriction.cc	2010-05-18 00:58:40 UTC (rev 16736)
+++ short/3D/PyLith/trunk/templates/friction/ViscousFriction.cc	2010-05-18 03:58:16 UTC (rev 16737)
@@ -10,8 +10,11 @@
 // ----------------------------------------------------------------------
 //
 
-#include <portinfo>
+// See ViscousFriction.hh for a description of each C++ function and
+// its arguments.
 
+#include <portinfo> // machine specific info generated by configure
+
 #include "ViscousFriction.hh" // implementation of object methods
 
 #include "pylith/materials/Metadata.hh" // USES Metadata
@@ -21,18 +24,24 @@
 
 #include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
 
-#include "petsc.h" // USES PetscLogFlops
-
 #include <cassert> // USES assert()
 #include <sstream> // USES std::ostringstream
 #include <stdexcept> // USES std::runtime_error
-#include <iostream>
 
 // ----------------------------------------------------------------------
-namespace pylith {
+// Create a local namespace to use for local constants and other
+// information. This insulates all other classes from this information
+// while preventing clashes with other local constants and data (as
+// long as no other object use the same _ViscousFriction namespace in
+// the  namespace.
+namespace contrib {
   namespace friction {
     namespace _ViscousFriction {
 
+      // These are the fault constitutive parameters stored during the
+      // simulation and need not coincide with the physical properties
+      // provided by the user.
+
       // Number of physical properties.
       const int numProperties = 3;
 
@@ -58,38 +67,44 @@
 				      "cohesion",
       };
 
+      // These are the state variables stored during the
+      // simulation. Usually, we store only the time-dependent values
+      // needed to compute the behavior at a given point in time. In
+      // this example, however, for illustration purposes we store the
+      // slip rate.
+
       const int numDBStateVars = 1;
       const char* dbStateVars[1] = { "slip-rate",
       };      
       
     } // _ViscousFriction
   } // friction
-} // pylith
+} // contrib
 
-// Indices of physical properties
-const int pylith::friction::ViscousFriction::p_coefS = 0;
-const int pylith::friction::ViscousFriction::p_v0 = 
-  pylith::friction::ViscousFriction::p_coefS + 1;
-const int pylith::friction::ViscousFriction::p_cohesion =
-  pylith::friction::ViscousFriction::p_v0 + 1;
+// Indices of fault constitutive parameters.
+const int contrib::friction::ViscousFriction::p_coefS = 0;
+const int contrib::friction::ViscousFriction::p_v0 = 
+  contrib::friction::ViscousFriction::p_coefS + 1;
+const int contrib::friction::ViscousFriction::p_cohesion =
+  contrib::friction::ViscousFriction::p_v0 + 1;
 
 // Indices of database values (order must match dbProperties)
-const int pylith::friction::ViscousFriction::db_coefS = 0;
-const int pylith::friction::ViscousFriction::db_v0 =
-  pylith::friction::ViscousFriction::db_coefS + 1;
-const int pylith::friction::ViscousFriction::db_cohesion =
-  pylith::friction::ViscousFriction::db_v0 + 1;
+const int contrib::friction::ViscousFriction::db_coefS = 0;
+const int contrib::friction::ViscousFriction::db_v0 =
+  contrib::friction::ViscousFriction::db_coefS + 1;
+const int contrib::friction::ViscousFriction::db_cohesion =
+  contrib::friction::ViscousFriction::db_v0 + 1;
 
 // Indices of state variables.
-const int pylith::friction::ViscousFriction::s_slipRate = 0;
+const int contrib::friction::ViscousFriction::s_slipRate = 0;
 
 // Indices of database values (order must match dbProperties)
-const int pylith::friction::ViscousFriction::db_slipRate = 0;
+const int contrib::friction::ViscousFriction::db_slipRate = 0;
 
 // ----------------------------------------------------------------------
 // Default constructor.
-pylith::friction::ViscousFriction::ViscousFriction(void) :
-  FrictionModel(materials::Metadata(_ViscousFriction::properties,
+contrib::friction::ViscousFriction::ViscousFriction(void) :
+  pylith::friction::FrictionModel(pylith::materials::Metadata(_ViscousFriction::properties,
 				    _ViscousFriction::numProperties,
 				    _ViscousFriction::dbProperties,
 				    _ViscousFriction::numDBProperties,
@@ -102,25 +117,29 @@
 
 // ----------------------------------------------------------------------
 // Destructor.
-pylith::friction::ViscousFriction::~ViscousFriction(void)
+contrib::friction::ViscousFriction::~ViscousFriction(void)
 { // destructor
 } // destructor
 
 // ----------------------------------------------------------------------
 // Compute properties from values in spatial database.
 void
-pylith::friction::ViscousFriction::_dbToProperties(
-					   double* const propValues,
-					   const double_array& dbValues) const
+contrib::friction::ViscousFriction::_dbToProperties(
+				   double* const propValues,
+				   const pylith::double_array& dbValues) const
 { // _dbToProperties
+  // Check consistency of arguments
   assert(0 != propValues);
   const int numDBValues = dbValues.size();
   assert(_ViscousFriction::numDBProperties == numDBValues);
 
+  // Extract values from array using our defined indices.
   const double coefS = dbValues[db_coefS];
   const double v0 = dbValues[db_v0];
   const double cohesion = dbValues[db_cohesion];
 
+  // Check for reasonable values. If user supplied unreasonable values
+  // throw an exception.
   if (coefS <= 0.0) {
     std::ostringstream msg;
     msg << "Spatial database returned nonpositive value for static "
@@ -136,6 +155,7 @@
     throw std::runtime_error(msg.str());
   } // if
 
+  // Compute parameters that we store from the user-supplied parameters.
   propValues[p_coefS] = coefS;
   propValues[p_v0] = db_v0;
   propValues[p_cohesion] = cohesion;
@@ -145,95 +165,123 @@
 // ----------------------------------------------------------------------
 // Nondimensionalize properties.
 void
-pylith::friction::ViscousFriction::_nondimProperties(double* const values,
+contrib::friction::ViscousFriction::_nondimProperties(double* const values,
 						    const int nvalues) const
 { // _nondimProperties
+  // Check consistency of arguments.
   assert(0 != _normalizer);
   assert(0 != values);
   assert(nvalues == _ViscousFriction::numProperties);
 
+  // Get scales needed to nondimensional parameters from the
+  // Nondimensional object.
   const double lengthScale = _normalizer->lengthScale();
   const double timeScale = _normalizer->timeScale();
   const double pressureScale = _normalizer->pressureScale();
   const double velocityScale = lengthScale / timeScale;
 
-  values[p_v0] /= velocityScale;
-  values[p_cohesion] /= pressureScale;
+  // Use the Nondimensional::nondimensionalize() function to
+  // nondimensionalize the quantities using the appropriate scale.
+  values[p_v0] = _normalizer->nondimensionalize(values[p_v0], velocityScale);
+  values[p_cohesion] = 
+    _normalizer->nondimensionalize(values[p_cohesion], pressureScale);
 } // _nondimProperties
 
 // ----------------------------------------------------------------------
 // Dimensionalize properties.
 void
-pylith::friction::ViscousFriction::_dimProperties(double* const values,
+contrib::friction::ViscousFriction::_dimProperties(double* const values,
 						      const int nvalues) const
 { // _dimProperties
+  // Check consistency of arguments.
   assert(0 != _normalizer);
   assert(0 != values);
   assert(nvalues == _ViscousFriction::numProperties);
 
+  // Get scales needed to dimensional parameters from the
+  // Nondimensional object.
   const double lengthScale = _normalizer->lengthScale();
   const double timeScale = _normalizer->timeScale();
   const double pressureScale = _normalizer->pressureScale();
   const double velocityScale = lengthScale / timeScale;
 
-  values[p_v0] *= velocityScale;
-  values[p_cohesion] *= pressureScale;
+  // Use the Nondimensional::dimensionalize() function to
+  // dimensionalize the quantities using the appropriate scale.
+  values[p_v0] = _normalizer->dimensionalize(values[p_v0], velocityScale);
+  values[p_cohesion] = 
+    _normalizer->dimensionalize(values[p_cohesion], pressureScale);
 } // _dimProperties
 
 // ----------------------------------------------------------------------
 // Compute state variables from values in spatial database.
 void
-pylith::friction::ViscousFriction::_dbToStateVars(
-					   double* const stateValues,
-					   const double_array& dbValues) const
+contrib::friction::ViscousFriction::_dbToStateVars(
+				  double* const stateValues,
+				  const pylith::double_array& dbValues) const
 { // _dbToStateVars
+  // Check consistency of arguments.
   assert(0 != stateValues);
   const int numDBValues = dbValues.size();
   assert(_ViscousFriction::numDBStateVars == numDBValues);
 
+  // Compute friction parameters that we store from the user-supplied
+  // friction parameters.
   const double slipRate = dbValues[db_slipRate];
  
+  // Store computed friction parameters in the properties array.
   stateValues[s_slipRate] = slipRate;
 } // _dbToStateVars
 
 // ----------------------------------------------------------------------
 // Nondimensionalize state variables.
 void
-pylith::friction::ViscousFriction::_nondimStateVars(double* const values,
+contrib::friction::ViscousFriction::_nondimStateVars(double* const values,
 						  const int nvalues) const
 { // _nondimStateVars
+  // Check consistency of arguments.
   assert(0 != _normalizer);
   assert(0 != values);
   assert(nvalues == _ViscousFriction::numStateVars);
 
+  // Get scales needed to nondimensional parameters from the
+  // Nondimensional object.
   const double lengthScale = _normalizer->lengthScale();
   const double timeScale = _normalizer->timeScale();
   const double velocityScale = lengthScale / timeScale;
 
-  values[s_slipRate] /= velocityScale;
+  // Use the Nondimensional::dimensionalize() function to
+  // dimensionalize the quantities using the appropriate scale.
+  values[s_slipRate] = 
+    _normalizer->nondimensionalize(values[s_slipRate], velocityScale);
 } // _nondimStateVars
 
 // ----------------------------------------------------------------------
 // Dimensionalize state variables.
 void
-pylith::friction::ViscousFriction::_dimStateVars(double* const values,
+contrib::friction::ViscousFriction::_dimStateVars(double* const values,
 					       const int nvalues) const
 { // _dimStateVars
+  // Check consistency of arguments.
   assert(0 != _normalizer);
   assert(0 != values);
   assert(nvalues == _ViscousFriction::numStateVars);
 
+  // Get scales needed to dimensional parameters from the
+  // Nondimensional object.
   const double lengthScale = _normalizer->lengthScale();
   const double timeScale = _normalizer->timeScale();
   const double velocityScale = lengthScale / timeScale;
 
-  values[s_slipRate] *= velocityScale;
+  // Use the Nondimensional::dimensionalize() function to
+  // dimensionalize the quantities using the appropriate scale.
+  values[s_slipRate] = 
+    _normalizer->dimensionalize(values[s_slipRate], velocityScale);
 } // _dimStateVars
 
 // ----------------------------------------------------------------------
 // Compute friction from properties and state variables.
 double
-pylith::friction::ViscousFriction::_calcFriction(const double slip,
+contrib::friction::ViscousFriction::_calcFriction(const double slip,
 						const double slipRate,
 						const double normalTraction,
 						const double* properties,
@@ -241,11 +289,13 @@
 						const double* stateVars,
 						const int numStateVars)
 { // _calcFriction
+  // Check consistency of arguments.
   assert(0 != properties);
   assert(_numPropsVertex == numProperties);
   assert(0 != numStateVars);
   assert(_numVarsVertex == numStateVars);
 
+  // Compute friction traction.
   double friction = 0.0;
   double mu_f = 0.0;
   if (normalTraction <= 0.0) {
@@ -254,15 +304,13 @@
     friction = - mu_f * normalTraction + properties[p_cohesion];
   } // if
 
-  PetscLogFlops(6);
-
   return friction;
 } // _calcFriction
 
 // ----------------------------------------------------------------------
 // Update state variables (for next time step).
 void
-pylith::friction::ViscousFriction::_updateStateVars(const double slip,
+contrib::friction::ViscousFriction::_updateStateVars(const double slip,
 						  const double slipRate,
 						  const double normalTraction,
 						  double* const stateVars,
@@ -270,9 +318,11 @@
 						  const double* properties,
 						  const int numProperties)
 { // _updateStateVars
+  // Check consistency of arguments.
   assert(0 != numStateVars);
   assert(0 != numProperties);
 
+  // Store state variables.
   stateVars[s_slipRate] = stateVars[s_slipRate]; 
 } // _updateStateVars
 

Modified: short/3D/PyLith/trunk/templates/friction/ViscousFriction.hh
===================================================================
--- short/3D/PyLith/trunk/templates/friction/ViscousFriction.hh	2010-05-18 00:58:40 UTC (rev 16736)
+++ short/3D/PyLith/trunk/templates/friction/ViscousFriction.hh	2010-05-18 03:58:16 UTC (rev 16737)
@@ -10,32 +10,44 @@
 // ----------------------------------------------------------------------
 //
 
-/** @file libsrc/friction/ViscousFriction.hh
+/* @brief C++ ViscousFriction object that implements friction
+ * correlated with slip rate.
  *
- * @brief C++ viscous (slip rate proportional) fault constitutive
- * model.
+ * This objects demonstrates how to extend PyLith by adding fault
+ * constitutive models.
+ *
+ * Friction model in which the perturbation from the static
+ * coefficient of friction is proportional to slip rate. The physical
+ * properties are specified using cohesion, static coefficient of
+ * friction, and a reference slip rate.
+ *
+ * $\mu_f = \mu_s (1 + \dot{D} / v_0)
  */
 
 #if !defined(pylith_friction_viscousfriction_hh)
 #define pylith_friction_viscousfriction_hh
 
 // Include directives ---------------------------------------------------
-#include "FrictionModel.hh" // ISA FrictionModel
+#include "pylith/friction/FrictionModel.hh" // ISA FrictionModel
 
+// Forward declarations
+namespace contrib {
+  namespace friction {
+    class ViscousFriction;
+  } // friction
+} // pylith
+
 // ViscousFriction -------------------------------------------------------
-/** @brief C++ viscous (slip rate proportional) fault constitutive
- * model.
- *
- * Friction is equal to the cohesion plus the product of a coefficient
- * of friction (function of slip rate) and the normal traction.
- *
- * mu_f = mu_s (1 + v/v0)
- */
-
-class pylith::friction::ViscousFriction : public FrictionModel
+class contrib::friction::ViscousFriction : 
+  public pylith::friction::FrictionModel
 { // class ViscousFriction
   friend class TestViscousFriction; // unit testing
 
+  // --------------------------------------------------------------------
+  // All of these functions are required to satisfy the PyLith
+  // interface for a fault constitutive model.
+  // --------------------------------------------------------------------
+
   // PUBLIC METHODS /////////////////////////////////////////////////////
 public :
 
@@ -56,7 +68,7 @@
    * @param dbValues Array of database values.
    */
   void _dbToProperties(double* const propValues,
-		       const double_array& dbValues) const;
+		       const pylith::double_array& dbValues) const;
 
   /** Nondimensionalize properties.
    *
@@ -85,7 +97,7 @@
    * @param numStateVars Number of state variables.
    */
   void _dbToStateVars(double* const stateValues,
-		      const double_array& dbValues) const;
+		      const pylith::double_array& dbValues) const;
 
   /** Nondimensionalize state variables.
    *
@@ -101,7 +113,7 @@
    * @param nvalues Number of values.
    */
   void _dimStateVars(double* const values,
-			const int nvalues) const;
+		     const int nvalues) const;
 
   /** Compute friction from properties and state variables.
    *
@@ -121,6 +133,13 @@
 		       const double* stateVars,
 		       const int numStateVars);
 
+  // --------------------------------------------------------------------
+  // Optional function in the PyLith interface for a fault
+  // constitutive model. Even though this function is optional, for it
+  // to be used it the interface must exactly matched the one
+  // specified in FrictionModel.
+  // --------------------------------------------------------------------
+
   /** Update state variables (for next time step).
    *
    * @param slip Current slip at location.
@@ -142,18 +161,19 @@
   // PRIVATE MEMBERS ////////////////////////////////////////////////////
 private :
 
-  /// Indices for properties in section and spatial database.
+  // --------------------------------------------------------------------
+  // We use these constants for consistent access into the arrays of
+  // physical properties and state variables.
+  // --------------------------------------------------------------------
+
   static const int p_coefS;
   static const int p_v0;
   static const int p_cohesion;
-
   static const int db_coefS;
   static const int db_v0;
   static const int db_cohesion;
 
-  /// Indices for state variables in section and spatial database.
   static const int s_slipRate;
-
   static const int db_slipRate;
 
   // NOT IMPLEMENTED ////////////////////////////////////////////////////

Modified: short/3D/PyLith/trunk/templates/friction/ViscousFriction.i
===================================================================
--- short/3D/PyLith/trunk/templates/friction/ViscousFriction.i	2010-05-18 00:58:40 UTC (rev 16736)
+++ short/3D/PyLith/trunk/templates/friction/ViscousFriction.i	2010-05-18 03:58:16 UTC (rev 16737)
@@ -10,15 +10,22 @@
 // ----------------------------------------------------------------------
 //
 
-/** @file modulesrc/friction/ViscousFriction.i
+// SWIG interface to C++ ViscousFriction object.
+
+/* This is nearly identical to the C++ ViscousFriction header
+ * file. There are a few important differences required by SWIG:
  *
- * Python interface to C++ ViscousFriction object.
+ * (1) Instead of forward declaring the ViscousFriction class, we
+ * embed the class definition within the namespace declarations.
+ *
+ * (2) We only include public members and methods and implementations
+ * of abstract methods, because this is an interface file.
  */
 
-namespace pylith {
+namespace contrib {
   namespace friction {
 
-    class ViscousFriction : public FrictionModel
+    class ViscousFriction : public pylith::friction::FrictionModel
     { // class ViscousFriction
 
       // PUBLIC METHODS /////////////////////////////////////////////////

Modified: short/3D/PyLith/trunk/templates/friction/ViscousFriction.py
===================================================================
--- short/3D/PyLith/trunk/templates/friction/ViscousFriction.py	2010-05-18 00:58:40 UTC (rev 16736)
+++ short/3D/PyLith/trunk/templates/friction/ViscousFriction.py	2010-05-18 03:58:16 UTC (rev 16737)
@@ -16,9 +16,14 @@
 ##
 ## Factory: friction_model.
 
-from FrictionModel import FrictionModel
-from friction import ViscousFriction as ModuleViscousFriction
+# ISA FrictionModel
+from pylith.friction.FrictionModel import FrictionModel
 
+# Import the SWIG module ViscousFriction object and rename it
+# ModuleViscousFriction so that it doesn't clash with the local Python
+# class of the same name.
+from frictioncontrib import ViscousFriction as ModuleViscousFriction
+
 # ViscousFriction class
 class ViscousFriction(FrictionModel, ModuleViscousFriction):
   """
@@ -34,6 +39,16 @@
     Constructor.
     """
     FrictionModel.__init__(self, name)
+    # Set the fields that are available for output. These are the
+    # stored physical properties and state variables. The friction
+    # model information is output with the fault information, so we
+    # can also output slip, slip rate and the fault tractions.
+    #
+    # There are no cell fields because the fault constitutive model
+    # operations on quantities evaluated at the fault vertices.
+    #
+    # Do not change the name of this variable. The output manager will
+    # request this variable by name.
     self.availableFields = \
         {'vertex': \
            {'info': ["static_coefficient",
@@ -42,7 +57,7 @@
          'cell': \
            {'info': [],
             'data': []}}
-    self._loggingPrefix = "FrVisc "
+    self._loggingPrefix = "FrVisc " # Prefix that appears in PETSc logging
     return
 
 
@@ -50,7 +65,9 @@
 
   def _createModuleObj(self):
     """
-    Call constructor for module object for access to C++ object.
+    Call constructor for module object for access to C++ object. This
+    function is called automatically by the generic Python FrictionModel
+    object. It must have this name and self as the only argument.
     """
     ModuleViscousFriction.__init__(self)
     return
@@ -58,11 +75,14 @@
 
 # FACTORIES ////////////////////////////////////////////////////////////
 
+# This is the function that is called when you invoke
+# friction = pylith.pylith.contrib.ViscousFfriction
+# The name of this function MUST be 'friction_model'.
 def friction_model():
   """
   Factory associated with ViscousFriction.
   """
-  return ViscousFriction()
+  return ViscousFriction() # Return our object
 
 
 # End of file 

Modified: short/3D/PyLith/trunk/templates/friction/configure.ac
===================================================================
--- short/3D/PyLith/trunk/templates/friction/configure.ac	2010-05-18 00:58:40 UTC (rev 16736)
+++ short/3D/PyLith/trunk/templates/friction/configure.ac	2010-05-18 03:58:16 UTC (rev 16737)
@@ -14,7 +14,7 @@
 AC_INIT([frictioncontrib], [0.0.1], [cig-short at geodynamics.org])
 AC_CONFIG_HEADER([portinfo])
 AC_CONFIG_AUX_DIR([./aux-config])
-#AC_CONFIG_MACRO_DIR([./m4])
+AC_CONFIG_MACRO_DIR([./m4])
 AM_INIT_AUTOMAKE([foreign])
 
 # ----------------------------------------------------------------------
@@ -51,7 +51,7 @@
 AC_REQUIRE_CPP
 AC_COMPILE_IFELSE(
   [AC_LANG_PROGRAM([[#include <pylith/friction/StaticFriction.hh>]],
-                   [[pylith::friction::StaticFriction material;]])],
+                   [[pylith::friction::StaticFriction model;]])],
   [AC_MSG_RESULT(yes)],
   [AC_MSG_RESULT(no)
    AC_MSG_ERROR([PyLith library not found; try LDFLAGS="-L<PyLith lib dir>"])

Added: short/3D/PyLith/trunk/templates/friction/tests/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/templates/friction/tests/Makefile.am	                        (rev 0)
+++ short/3D/PyLith/trunk/templates/friction/tests/Makefile.am	2010-05-18 03:58:16 UTC (rev 16737)
@@ -0,0 +1,22 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+TESTS = testcontrib.py
+dist_check_SCRIPTS = testcontrib.py
+
+TESTS_ENVIRONMENT = $(PYTHON)
+
+noinst_PYTHON = \
+	TestViscousFriction.py 
+
+
+# End of file 

Added: short/3D/PyLith/trunk/templates/friction/tests/TestViscousFriction.py
===================================================================
--- short/3D/PyLith/trunk/templates/friction/tests/TestViscousFriction.py	                        (rev 0)
+++ short/3D/PyLith/trunk/templates/friction/tests/TestViscousFriction.py	2010-05-18 03:58:16 UTC (rev 16737)
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+# We cannot test the low-level functionality of the ViscousFriction
+# object because it is not exposed to Python. You should really setup
+# C++ unit tests using CppUnit as is done for PyLith in addition to
+# the simple Python unit tests here.
+
+import unittest
+
+
+class TestViscousFriction(unittest.TestCase):
+  """
+  Unit testing of ViscousFriction object.
+  """
+
+  def setUp(self):
+    """
+    Setup test subject.
+    """
+    from pylith.friction.contrib.ViscousFriction import ViscousFriction
+    self.model = ViscousFriction()
+    return
+  
+
+  def test_label(self):
+    """
+    Test constructor.
+    """
+    label = "viscous friction"
+    self.model.label(label)
+    self.assertEqual(label, self.model.label())
+    return
+
+
+  def test_timeStep(self):
+    """
+    Test constructor.
+    """
+    dt = 2.4
+    self.model.timeStep(dt)
+    self.assertEqual(dt, self.model.timeStep())
+    return
+
+
+  def testHasProperty(self):
+    self.failUnless(self.model.hasProperty("static_coefficient"))
+    self.failUnless(self.model.hasProperty("reference_slip_rate"))
+    self.failUnless(self.model.hasProperty("cohesion"))
+    return
+
+
+  def testHasStateVar(self):
+    self.failUnless(self.model.hasStateVar("slip_rate"))
+    return
+
+
+  def test_factory(self):
+    """
+    Test factory method.
+    """
+    from pylith.friction.contrib.ViscousFriction import friction_model
+    f = friction_model()
+    return
+
+
+# End of file 

Added: short/3D/PyLith/trunk/templates/friction/tests/testcontrib.py
===================================================================
--- short/3D/PyLith/trunk/templates/friction/tests/testcontrib.py	                        (rev 0)
+++ short/3D/PyLith/trunk/templates/friction/tests/testcontrib.py	2010-05-18 03:58:16 UTC (rev 16737)
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+import unittest
+
+def suite():
+
+  suite = unittest.TestSuite()
+
+  from TestViscousFriction import TestViscousFriction
+  suite.addTest(unittest.makeSuite(TestViscousFriction))
+
+  return suite
+
+def main():
+  unittest.TextTestRunner(verbosity=2).run(suite())
+  return
+
+if __name__ == '__main__':
+  main()
+  
+
+# End of file 


Property changes on: short/3D/PyLith/trunk/templates/friction/tests/testcontrib.py
___________________________________________________________________
Name: svn:executable
   + *



More information about the CIG-COMMITS mailing list