[cig-commits] r16236 - in short/3D/PyLith/trunk: modulesrc/friction pylith pylith/friction unittests/pytests/friction unittests/pytests/friction/data

surendra at geodynamics.org surendra at geodynamics.org
Fri Feb 5 04:21:19 PST 2010


Author: surendra
Date: 2010-02-05 04:21:18 -0800 (Fri, 05 Feb 2010)
New Revision: 16236

Added:
   short/3D/PyLith/trunk/modulesrc/friction/SlipWeakening.i
   short/3D/PyLith/trunk/pylith/friction/SlipWeakening.py
   short/3D/PyLith/trunk/unittests/pytests/friction/TestSlipWeakening.py
   short/3D/PyLith/trunk/unittests/pytests/friction/data/slipweakening.spatialdb
Modified:
   short/3D/PyLith/trunk/modulesrc/friction/Makefile.am
   short/3D/PyLith/trunk/modulesrc/friction/friction.i
   short/3D/PyLith/trunk/pylith/Makefile.am
   short/3D/PyLith/trunk/pylith/friction/__init__.py
   short/3D/PyLith/trunk/unittests/pytests/friction/Makefile.am
   short/3D/PyLith/trunk/unittests/pytests/friction/data/Makefile.am
   short/3D/PyLith/trunk/unittests/pytests/friction/testfriction.py
Log:
Worked on pytests for SlipWeakening (test passed)

Modified: short/3D/PyLith/trunk/modulesrc/friction/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/modulesrc/friction/Makefile.am	2010-02-05 03:36:50 UTC (rev 16235)
+++ short/3D/PyLith/trunk/modulesrc/friction/Makefile.am	2010-02-05 12:21:18 UTC (rev 16236)
@@ -20,7 +20,8 @@
 swig_sources = \
 	friction.i \
 	FrictionModel.i \
-	StaticFriction.i
+	StaticFriction.i \
+	SlipWeakening.i
 
 swigincludedir = $(pkgdatadir)/swig/$(subpackage)
 swiginclude_HEADERS = \

Added: short/3D/PyLith/trunk/modulesrc/friction/SlipWeakening.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/friction/SlipWeakening.i	                        (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/friction/SlipWeakening.i	2010-02-05 12:21:18 UTC (rev 16236)
@@ -0,0 +1,84 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/friction/SlipWeakening.i
+ *
+ * Python interface to C++ SlipWeakening object.
+ */
+
+namespace pylith {
+  namespace friction {
+
+    class SlipWeakening : public FrictionModel
+    { // class SlipWeakening
+
+      // PUBLIC METHODS /////////////////////////////////////////////////
+    public :
+
+      /// Default constructor.
+      SlipWeakening(void);
+
+      /// Destructor.
+      ~SlipWeakening(void);
+
+      // PROTECTED METHODS //////////////////////////////////////////////
+    protected :
+
+      /** Compute properties from values in spatial database.
+       *
+       * @param propValues Array of property values.
+       * @param dbValues Array of database values.
+       */
+      void _dbToProperties(double* const propValues,
+			   const double_array& dbValues) const;
+
+      /** Nondimensionalize properties.
+       *
+       * @param values Array of property values.
+       * @param nvalues Number of values.
+       */
+      void _nondimProperties(double* const values,
+			     const int nvalues) const;
+
+      /** Dimensionalize properties.
+       *
+       * @param values Array of property values.
+       * @param nvalues Number of values.
+       */
+      void _dimProperties(double* const values,
+			  const int nvalues) const;
+
+      /** Compute friction from properties and state variables.
+       *
+       * @param slip Current slip at location.
+       * @param slipRate Current slip rate at location.
+       * @param normalTraction Normal traction at location.
+       * @param properties Properties at location.
+       * @param numProperties Number of properties.
+       * @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);
+
+    }; // class SlipWeakening
+
+  } // friction
+} // pylith
+
+
+// End of file 

Modified: short/3D/PyLith/trunk/modulesrc/friction/friction.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/friction/friction.i	2010-02-05 03:36:50 UTC (rev 16235)
+++ short/3D/PyLith/trunk/modulesrc/friction/friction.i	2010-02-05 12:21:18 UTC (rev 16236)
@@ -22,6 +22,7 @@
 
 #include "pylith/friction/FrictionModel.hh"
 #include "pylith/friction/StaticFriction.hh"
+#include "pylith/friction/SlipWeakening.hh"
 
 #include "pylith/utils/arrayfwd.hh"
 %}
@@ -50,6 +51,7 @@
 // Interfaces
 %include "FrictionModel.i"
 %include "StaticFriction.i"
+%include "SlipWeakening.i"
 
 
 // End of file

Modified: short/3D/PyLith/trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/pylith/Makefile.am	2010-02-05 03:36:50 UTC (rev 16235)
+++ short/3D/PyLith/trunk/pylith/Makefile.am	2010-02-05 12:21:18 UTC (rev 16236)
@@ -57,6 +57,7 @@
 	friction/__init__.py \
 	friction/FrictionModel.py \
 	friction/StaticFriction.py \
+	friction/SlipWeakening.py \
 	materials/__init__.py \
 	materials/ElasticMaterial.py \
 	materials/ElasticIsotropic3D.py \

Added: short/3D/PyLith/trunk/pylith/friction/SlipWeakening.py
===================================================================
--- short/3D/PyLith/trunk/pylith/friction/SlipWeakening.py	                        (rev 0)
+++ short/3D/PyLith/trunk/pylith/friction/SlipWeakening.py	2010-02-05 12:21:18 UTC (rev 16236)
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/friction/SlipWeakening.py
+##
+## @brief Python object implementing slip Weakening.
+##
+## Factory: friction_model.
+
+from FrictionModel import FrictionModel
+from friction import SlipWeakening as ModuleSlipWeakening
+
+# SlipWeakening class
+class SlipWeakening(FrictionModel, ModuleSlipWeakening):
+  """
+  Python object implementing Slip Weakening.
+
+  Factory: friction_model.
+  """
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="slipweakening"):
+    """
+    Constructor.
+    """
+    FrictionModel.__init__(self, name)
+    self.availableFields = \
+        {'vertex': \
+           {'info': ["static_coefficient","dynamic_coefficient","slip_weakening_parameter","cumulative_slip","previous_slip"],
+            'data': []},
+         'cell': \
+           {'info': [],
+            'data': []}}
+    self._loggingPrefix = "FrStat "
+    return
+
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _createModuleObj(self):
+    """
+    Call constructor for module object for access to C++ object.
+    """
+    ModuleSlipWeakening.__init__(self)
+    return
+  
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def friction_model():
+  """
+  Factory associated with SlipWeakening.
+  """
+  return SlipWeakening()
+
+
+# End of file 

Modified: short/3D/PyLith/trunk/pylith/friction/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/friction/__init__.py	2010-02-05 03:36:50 UTC (rev 16235)
+++ short/3D/PyLith/trunk/pylith/friction/__init__.py	2010-02-05 12:21:18 UTC (rev 16236)
@@ -16,6 +16,7 @@
 
 __all__ = ['FrictionModel',
            'StaticFriction',
+           'SlipWeakening',
            ]
 
 

Modified: short/3D/PyLith/trunk/unittests/pytests/friction/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/friction/Makefile.am	2010-02-05 03:36:50 UTC (rev 16235)
+++ short/3D/PyLith/trunk/unittests/pytests/friction/Makefile.am	2010-02-05 12:21:18 UTC (rev 16236)
@@ -22,7 +22,8 @@
 
 noinst_PYTHON = \
 	TestFrictionModel.py \
-	TestStaticFriction.py
+	TestStaticFriction.py \
+	TestSlipWeakening.py
 
 
 # End of file 

Added: short/3D/PyLith/trunk/unittests/pytests/friction/TestSlipWeakening.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/friction/TestSlipWeakening.py	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/friction/TestSlipWeakening.py	2010-02-05 12:21:18 UTC (rev 16236)
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/friction/TestSlipWeakening.py
+
+## @brief Unit testing of SlipWeakening object.
+
+import unittest
+
+from pylith.friction.SlipWeakening import SlipWeakening
+
+# ----------------------------------------------------------------------
+class TestSlipWeakening(unittest.TestCase):
+  """
+  Unit testing of SlipWeakening object.
+  """
+
+  def setUp(self):
+    """
+    Setup test subject.
+    """
+    self.friction = SlipWeakening()
+    return
+  
+
+  def test_constructor(self):
+    """
+    Test constructor.
+    """
+    return
+
+
+  def test_factory(self):
+    """
+    Test factory method.
+    """
+    from pylith.friction.SlipWeakening import friction_model
+    m = friction_model()
+    return
+
+
+# End of file 

Modified: short/3D/PyLith/trunk/unittests/pytests/friction/data/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/friction/data/Makefile.am	2010-02-05 03:36:50 UTC (rev 16235)
+++ short/3D/PyLith/trunk/unittests/pytests/friction/data/Makefile.am	2010-02-05 12:21:18 UTC (rev 16236)
@@ -11,7 +11,8 @@
 #
 
 dist_noinst_DATA = \
-	staticfriction.spatialdb
+	staticfriction.spatialdb \
+	slipweakening.spatialdb
 
 noinst_TMP =
 

Added: short/3D/PyLith/trunk/unittests/pytests/friction/data/slipweakening.spatialdb
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/friction/data/slipweakening.spatialdb	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/friction/data/slipweakening.spatialdb	2010-02-05 12:21:18 UTC (rev 16236)
@@ -0,0 +1,15 @@
+#SPATIAL.ascii 1
+SimpleDB {
+  num-values = 5
+  value-names =  static-coefficient dynamic-coefficient slip-weakening-parameter cumulative-slip previous-slip
+  value-units =  none none none 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.6   0.5   0.8   0.4   0.2
+0.0  -1.0   0.6   0.5   0.4   0.5   0.1  

Modified: short/3D/PyLith/trunk/unittests/pytests/friction/testfriction.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/friction/testfriction.py	2010-02-05 03:36:50 UTC (rev 16235)
+++ short/3D/PyLith/trunk/unittests/pytests/friction/testfriction.py	2010-02-05 12:21:18 UTC (rev 16236)
@@ -59,6 +59,9 @@
     from TestStaticFriction import TestStaticFriction
     suite.addTest(unittest.makeSuite(TestStaticFriction))
 
+    from TestSlipWeakening import TestSlipWeakening
+    suite.addTest(unittest.makeSuite(TestSlipWeakening))
+
     from TestFrictionModel import TestFrictionModel
     suite.addTest(unittest.makeSuite(TestFrictionModel))
 



More information about the CIG-COMMITS mailing list