[cig-commits] r20280 - in short/3D/PyLith/branches/v1.7-trunk/templates/friction: . tests

brad at geodynamics.org brad at geodynamics.org
Fri Jun 1 15:16:34 PDT 2012


Author: brad
Date: 2012-06-01 15:16:34 -0700 (Fri, 01 Jun 2012)
New Revision: 20280

Modified:
   short/3D/PyLith/branches/v1.7-trunk/templates/friction/Makefile.am
   short/3D/PyLith/branches/v1.7-trunk/templates/friction/ViscousFriction.cc
   short/3D/PyLith/branches/v1.7-trunk/templates/friction/ViscousFriction.hh
   short/3D/PyLith/branches/v1.7-trunk/templates/friction/ViscousFriction.i
   short/3D/PyLith/branches/v1.7-trunk/templates/friction/frictioncontrib.i
   short/3D/PyLith/branches/v1.7-trunk/templates/friction/tests/TestViscousFriction.py
Log:
Updated friction model template.

Modified: short/3D/PyLith/branches/v1.7-trunk/templates/friction/Makefile.am
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/templates/friction/Makefile.am	2012-06-01 21:39:29 UTC (rev 20279)
+++ short/3D/PyLith/branches/v1.7-trunk/templates/friction/Makefile.am	2012-06-01 22:16:34 UTC (rev 20280)
@@ -68,7 +68,7 @@
 
 dist__frictioncontribmodule_la_SOURCES = $(swig_sources) $(swig_generated)
 
-_frictioncontribmodule_la_LIBADD = libfrictioncontrib.la
+_frictioncontribmodule_la_LIBADD = libfrictioncontrib.la -lpylith
 if NO_UNDEFINED
 _frictioncontribmodule_la_LIBADD += \
 	$(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)

Modified: short/3D/PyLith/branches/v1.7-trunk/templates/friction/ViscousFriction.cc
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/templates/friction/ViscousFriction.cc	2012-06-01 21:39:29 UTC (rev 20279)
+++ short/3D/PyLith/branches/v1.7-trunk/templates/friction/ViscousFriction.cc	2012-06-01 22:16:34 UTC (rev 20280)
@@ -25,8 +25,8 @@
 
 #include "pylith/materials/Metadata.hh" // USES Metadata
 
-#include "pylith/utils/array.hh" // USES double_array
-#include "pylith/utils/constdefs.h" // USES MAXDOUBLE
+#include "pylith/utils/array.hh" // USES scaary_array
+#include "pylith/utils/constdefs.h" // USES PYLITH_MAXSCALAR
 
 #include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
 
@@ -131,8 +131,8 @@
 // Compute properties from values in spatial database.
 void
 contrib::friction::ViscousFriction::_dbToProperties(
-				   double* const propValues,
-				   const pylith::double_array& dbValues) const
+				   PylithScalar* const propValues,
+				   const pylith::scalar_array& dbValues) const
 { // _dbToProperties
   // Check consistency of arguments
   assert(0 != propValues);
@@ -140,9 +140,9 @@
   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];
+  const PylithScalar coefS = dbValues[db_coefS];
+  const PylithScalar v0 = dbValues[db_v0];
+  const PylithScalar cohesion = dbValues[db_cohesion];
 
   // Check for reasonable values. If user supplied unreasonable values
   // throw an exception.
@@ -171,7 +171,7 @@
 // ----------------------------------------------------------------------
 // Nondimensionalize properties.
 void
-contrib::friction::ViscousFriction::_nondimProperties(double* const values,
+contrib::friction::ViscousFriction::_nondimProperties(PylithScalar* const values,
 						    const int nvalues) const
 { // _nondimProperties
   // Check consistency of arguments.
@@ -181,10 +181,10 @@
 
   // 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;
+  const PylithScalar lengthScale = _normalizer->lengthScale();
+  const PylithScalar timeScale = _normalizer->timeScale();
+  const PylithScalar pressureScale = _normalizer->pressureScale();
+  const PylithScalar velocityScale = lengthScale / timeScale;
 
   // Use the Nondimensional::nondimensionalize() function to
   // nondimensionalize the quantities using the appropriate scale.
@@ -196,7 +196,7 @@
 // ----------------------------------------------------------------------
 // Dimensionalize properties.
 void
-contrib::friction::ViscousFriction::_dimProperties(double* const values,
+contrib::friction::ViscousFriction::_dimProperties(PylithScalar* const values,
 						      const int nvalues) const
 { // _dimProperties
   // Check consistency of arguments.
@@ -206,10 +206,10 @@
 
   // 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;
+  const PylithScalar lengthScale = _normalizer->lengthScale();
+  const PylithScalar timeScale = _normalizer->timeScale();
+  const PylithScalar pressureScale = _normalizer->pressureScale();
+  const PylithScalar velocityScale = lengthScale / timeScale;
 
   // Use the Nondimensional::dimensionalize() function to
   // dimensionalize the quantities using the appropriate scale.
@@ -222,8 +222,8 @@
 // Compute state variables from values in spatial database.
 void
 contrib::friction::ViscousFriction::_dbToStateVars(
-				  double* const stateValues,
-				  const pylith::double_array& dbValues) const
+				  PylithScalar* const stateValues,
+				  const pylith::scalar_array& dbValues) const
 { // _dbToStateVars
   // Check consistency of arguments.
   assert(0 != stateValues);
@@ -232,7 +232,7 @@
 
   // Compute friction parameters that we store from the user-supplied
   // friction parameters.
-  const double slipRate = dbValues[db_slipRate];
+  const PylithScalar slipRate = dbValues[db_slipRate];
  
   // Store computed friction parameters in the properties array.
   stateValues[s_slipRate] = slipRate;
@@ -241,7 +241,7 @@
 // ----------------------------------------------------------------------
 // Nondimensionalize state variables.
 void
-contrib::friction::ViscousFriction::_nondimStateVars(double* const values,
+contrib::friction::ViscousFriction::_nondimStateVars(PylithScalar* const values,
 						  const int nvalues) const
 { // _nondimStateVars
   // Check consistency of arguments.
@@ -251,9 +251,9 @@
 
   // 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;
+  const PylithScalar lengthScale = _normalizer->lengthScale();
+  const PylithScalar timeScale = _normalizer->timeScale();
+  const PylithScalar velocityScale = lengthScale / timeScale;
 
   // Use the Nondimensional::dimensionalize() function to
   // dimensionalize the quantities using the appropriate scale.
@@ -264,7 +264,7 @@
 // ----------------------------------------------------------------------
 // Dimensionalize state variables.
 void
-contrib::friction::ViscousFriction::_dimStateVars(double* const values,
+contrib::friction::ViscousFriction::_dimStateVars(PylithScalar* const values,
 					       const int nvalues) const
 { // _dimStateVars
   // Check consistency of arguments.
@@ -274,9 +274,9 @@
 
   // 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;
+  const PylithScalar lengthScale = _normalizer->lengthScale();
+  const PylithScalar timeScale = _normalizer->timeScale();
+  const PylithScalar velocityScale = lengthScale / timeScale;
 
   // Use the Nondimensional::dimensionalize() function to
   // dimensionalize the quantities using the appropriate scale.
@@ -286,14 +286,15 @@
 
 // ----------------------------------------------------------------------
 // Compute friction from properties and state variables.
-double
-contrib::friction::ViscousFriction::_calcFriction(const double slip,
-						const double slipRate,
-						const double normalTraction,
-						const double* properties,
-						const int numProperties,
-						const double* stateVars,
-						const int numStateVars)
+PylithScalar
+contrib::friction::ViscousFriction::_calcFriction(const PylithScalar t,
+						  const PylithScalar slip,
+						  const PylithScalar slipRate,
+						  const PylithScalar normalTraction,
+						  const PylithScalar* properties,
+						  const int numProperties,
+						  const PylithScalar* stateVars,
+						  const int numStateVars)
 { // _calcFriction
   // Check consistency of arguments.
   assert(properties);
@@ -302,8 +303,8 @@
   assert(_ViscousFriction::numStateVars == numStateVars);
 
   // Compute friction traction.
-  double friction = 0.0;
-  double mu_f = 0.0;
+  PylithScalar friction = 0.0;
+  PylithScalar mu_f = 0.0;
   if (normalTraction <= 0.0) {
     // if fault is in compression
     mu_f = properties[p_coefS] * (1.0 + fabs(slipRate) / properties[p_v0]);
@@ -316,13 +317,14 @@
 // ----------------------------------------------------------------------
 // Update state variables (for next time step).
 void
-contrib::friction::ViscousFriction::_updateStateVars(const double slip,
-						  const double slipRate,
-						  const double normalTraction,
-						  double* const stateVars,
-						  const int numStateVars,
-						  const double* properties,
-						  const int numProperties)
+contrib::friction::ViscousFriction::_updateStateVars(const PylithScalar t,
+						     const PylithScalar slip,
+						     const PylithScalar slipRate,
+						     const PylithScalar normalTraction,
+						     PylithScalar* const stateVars,
+						     const int numStateVars,
+						     const PylithScalar* properties,
+						     const int numProperties)
 { // _updateStateVars
   // Check consistency of arguments.
   assert(properties);

Modified: short/3D/PyLith/branches/v1.7-trunk/templates/friction/ViscousFriction.hh
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/templates/friction/ViscousFriction.hh	2012-06-01 21:39:29 UTC (rev 20279)
+++ short/3D/PyLith/branches/v1.7-trunk/templates/friction/ViscousFriction.hh	2012-06-01 22:16:34 UTC (rev 20280)
@@ -73,15 +73,15 @@
    * @param propValues Array of property values.
    * @param dbValues Array of database values.
    */
-  void _dbToProperties(double* const propValues,
-		       const pylith::double_array& dbValues) const;
+  void _dbToProperties(PylithScalar* const propValues,
+		       const pylith::scalar_array& dbValues) const;
 
   /** Nondimensionalize properties.
    *
    * @param values Array of property values.
    * @param nvalues Number of values.
    */
-  void _nondimProperties(double* const values,
+  void _nondimProperties(PylithScalar* const values,
 			 const int nvalues) const;
 
   /** Dimensionalize properties.
@@ -89,7 +89,7 @@
    * @param values Array of property values.
    * @param nvalues Number of values.
    */
-  void _dimProperties(double* const values,
+  void _dimProperties(PylithScalar* const values,
 		      const int nvalues) const;
 
   /** Compute friction from properties and state variables.
@@ -102,15 +102,15 @@
    * @param stateVars State variables at location.
    * @param numStateVars Number of state variables.
    */
-  void _dbToStateVars(double* const stateValues,
-		      const pylith::double_array& dbValues) const;
+  void _dbToStateVars(PylithScalar* const stateValues,
+		      const pylith::scalar_array& dbValues) const;
 
   /** Nondimensionalize state variables.
    *
    * @param values Array of initial state values.
    * @param nvalues Number of values.
    */
-  void _nondimStateVars(double* const values,
+  void _nondimStateVars(PylithScalar* const values,
 			const int nvalues) const;
   
   /** Dimensionalize state variables.
@@ -118,11 +118,12 @@
    * @param values Array of initial state values.
    * @param nvalues Number of values.
    */
-  void _dimStateVars(double* const values,
+  void _dimStateVars(PylithScalar* const values,
 		     const int nvalues) const;
 
   /** Compute friction from properties and state variables.
    *
+   * @param t Time in simulation.
    * @param slip Current slip at location.
    * @param slipRate Current slip rate at location.
    * @param normalTraction Normal traction at location.
@@ -131,13 +132,14 @@
    * @param stateVars State variables at location.
    * @param numStateVars Number of state variables.
    */
-  double _calcFriction(const double slip,
-		       const double slipRate,
-		       const double normalTraction,
-		       const double* properties,
-		       const int numProperties,
-		       const double* stateVars,
-		       const int numStateVars);
+  PylithScalar _calcFriction(const PylithScalar t,
+			     const PylithScalar slip,
+			     const PylithScalar slipRate,
+			     const PylithScalar normalTraction,
+			     const PylithScalar* properties,
+			     const int numProperties,
+			     const PylithScalar* stateVars,
+			     const int numStateVars);
 
   // --------------------------------------------------------------------
   // Optional function in the PyLith interface for a fault
@@ -148,6 +150,7 @@
 
   /** Update state variables (for next time step).
    *
+   * @param t Time in simulation.
    * @param slip Current slip at location.
    * @param slipRate Current slip rate at location.
    * @param normalTraction Normal traction at location.
@@ -156,13 +159,14 @@
    * @param properties Properties at location.
    * @param numProperties Number of properties.
    */
-  void _updateStateVars(const double slip,
-      const double slipRate,
-      const double normalTraction,
-      double* const stateVars,
-      const int numStateVars,
-      const double* properties,
-      const int numProperties);
+  void _updateStateVars(const PylithScalar t,
+			const PylithScalar slip,
+			const PylithScalar slipRate,
+			const PylithScalar normalTraction,
+			PylithScalar* const stateVars,
+			const int numStateVars,
+			const PylithScalar* properties,
+			const int numProperties);
 
   // PRIVATE MEMBERS ////////////////////////////////////////////////////
 private :

Modified: short/3D/PyLith/branches/v1.7-trunk/templates/friction/ViscousFriction.i
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/templates/friction/ViscousFriction.i	2012-06-01 21:39:29 UTC (rev 20279)
+++ short/3D/PyLith/branches/v1.7-trunk/templates/friction/ViscousFriction.i	2012-06-01 22:16:34 UTC (rev 20280)
@@ -51,15 +51,15 @@
        * @param propValues Array of property values.
        * @param dbValues Array of database values.
        */
-      void _dbToProperties(double* const propValues,
-			   const double_array& dbValues) const;
+      void _dbToProperties(PylithScalar* const propValues,
+			   const scalar_array& dbValues) const;
 
       /** Nondimensionalize properties.
        *
        * @param values Array of property values.
        * @param nvalues Number of values.
        */
-      void _nondimProperties(double* const values,
+      void _nondimProperties(PylithScalar* const values,
 			     const int nvalues) const;
 
       /** Dimensionalize properties.
@@ -67,11 +67,12 @@
        * @param values Array of property values.
        * @param nvalues Number of values.
        */
-      void _dimProperties(double* const values,
+      void _dimProperties(PylithScalar* const values,
 			  const int nvalues) const;
 
       /** Compute friction from properties and state variables.
        *
+       * @param t Time in simulation.
        * @param slip Current slip at location.
        * @param slipRate Current slip rate at location.
        * @param normalTraction Normal traction at location.
@@ -80,13 +81,14 @@
        * @param stateVars State variables at location.
        * @param numStateVars Number of state variables.
        */
-      double _calcFriction(const double slip,
-			   const double slipRate,
-			   const double normalTraction,
-			   const double* properties,
-			   const int numProperties,
-			   const double* stateVars,
-			   const int numStateVars);
+      PylithScalar _calcFriction(const PylithScalar t,
+				 const PylithScalar slip,
+				 const PylithScalar slipRate,
+				 const PylithScalar normalTraction,
+				 const PylithScalar* properties,
+				 const int numProperties,
+				 const PylithScalar* stateVars,
+				 const int numStateVars);
 
     }; // class ViscousFriction
 

Modified: short/3D/PyLith/branches/v1.7-trunk/templates/friction/frictioncontrib.i
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/templates/friction/frictioncontrib.i	2012-06-01 21:39:29 UTC (rev 20279)
+++ short/3D/PyLith/branches/v1.7-trunk/templates/friction/frictioncontrib.i	2012-06-01 22:16:34 UTC (rev 20280)
@@ -27,7 +27,9 @@
 
 #include "ViscousFriction.hh"
 
-#include "pylith/utils/arrayfwd.hh"
+#include "pylith/utils/types.hh"
+#include "pylith/utils/array.hh"
+#include "pylith/utils/sievetypes.hh"
 %}
 
 // Convert standard C++ exceptions to Python exceptions.
@@ -41,7 +43,7 @@
 } // exception
 
 %include "typemaps.i"
-%include "include/doublearray.i"
+%include "include/scalartypemaps.i"
 
 // Numpy interface stuff
 %{

Modified: short/3D/PyLith/branches/v1.7-trunk/templates/friction/tests/TestViscousFriction.py
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/templates/friction/tests/TestViscousFriction.py	2012-06-01 21:39:29 UTC (rev 20279)
+++ short/3D/PyLith/branches/v1.7-trunk/templates/friction/tests/TestViscousFriction.py	2012-06-01 22:16:34 UTC (rev 20280)
@@ -54,22 +54,10 @@
     """
     dt = 2.4
     self.model.timeStep(dt)
-    self.assertEqual(dt, self.model.timeStep())
+    self.assertAlmostEqual(dt, self.model.timeStep(), 5)
     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.



More information about the CIG-COMMITS mailing list