[cig-commits] r16731 - in short/3D/PyLith/trunk/templates: . friction materials
brad at geodynamics.org
brad at geodynamics.org
Sun May 16 20:26:44 PDT 2010
Author: brad
Date: 2010-05-16 20:26:44 -0700 (Sun, 16 May 2010)
New Revision: 16731
Added:
short/3D/PyLith/trunk/templates/friction/
short/3D/PyLith/trunk/templates/friction/Makefile.am
short/3D/PyLith/trunk/templates/friction/README
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/__init__.py
short/3D/PyLith/trunk/templates/friction/configure.ac
short/3D/PyLith/trunk/templates/friction/frictioncontrib.i
Modified:
short/3D/PyLith/trunk/templates/Makefile.am
short/3D/PyLith/trunk/templates/README
short/3D/PyLith/trunk/templates/materials/materialscontrib.i
Log:
Added friction template (need to document source files).
Modified: short/3D/PyLith/trunk/templates/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/templates/Makefile.am 2010-05-17 02:46:57 UTC (rev 16730)
+++ short/3D/PyLith/trunk/templates/Makefile.am 2010-05-17 03:26:44 UTC (rev 16731)
@@ -27,7 +27,22 @@
materials/tests/TestPlaneStrainState.py \
materials/m4/ac_pkg_swig.m4 \
materials/m4/cit_numpy.m4 \
- materials/m4/cit_python.m4
+ materials/m4/cit_python.m4 \
+ friction/README \
+ friction/configure.ac \
+ friction/Makefile.am \
+ friction/ViscousFriction.hh \
+ friction/ViscousFriction.cc \
+ friction/ViscousFriction.i \
+ friction/frictioncontrib.i \
+ friction/__init__.py \
+ friction/ViscousFriction.py \
+ friction/tests/Makefile.am \
+ friction/tests/testcontrib.py \
+ friction/tests/TestViscousFriction.py \
+ friction/m4/ac_pkg_swig.m4 \
+ friction/m4/cit_numpy.m4 \
+ friction/m4/cit_python.m4
# End of file
Modified: short/3D/PyLith/trunk/templates/README
===================================================================
--- short/3D/PyLith/trunk/templates/README 2010-05-17 02:46:57 UTC (rev 16730)
+++ short/3D/PyLith/trunk/templates/README 2010-05-17 03:26:44 UTC (rev 16731)
@@ -1,3 +1,6 @@
This directory contains templates for extending the functionality of
-PyLith. This includes creating user-defined bulk constitutive models
-(see the materials directory).
+PyLith.
+
+Directories
+ * friction - fault constitutive models
+ * materials - bulk constitutive models
Property changes on: short/3D/PyLith/trunk/templates/friction
___________________________________________________________________
Name: svn:externals
+ m4 http://geodynamics.org/svn/cig/cs/autoconf/trunk
Added: short/3D/PyLith/trunk/templates/friction/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/templates/friction/Makefile.am (rev 0)
+++ short/3D/PyLith/trunk/templates/friction/Makefile.am 2010-05-17 03:26:44 UTC (rev 16731)
@@ -0,0 +1,87 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+ACLOCAL_AMFLAGS = -I ./m4
+
+SUBDIRS = tests
+
+subpkgpythondir = $(pythondir)/pylith/friction/contrib
+subpkgpyexecdir = $(pyexecdir)/pylith/friction/contrib
+
+
+# LIBRARY --------------------------------------------------------------
+lib_LTLIBRARIES = libfrictioncontrib.la
+
+libfrictioncontrib_la_SOURCES = \
+ ViscousFriction.cc
+
+noinst_HEADERS = \
+ ViscousFriction.hh
+
+libfrictioncontrib_la_LDFLAGS = $(AM_LDFLAGS)
+
+libfrictioncontrib_la_LIBADD = \
+ -lpylith
+if NO_UNDEFINED
+libfrictioncontrib_la_LIBADD += \
+ $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
+endif
+
+AM_CPPFLAGS = $(PYTHON_EGG_CPPFLAGS) -I$(PYTHON_INCDIR)
+
+INCLUDES =
+
+# MODULE ---------------------------------------------------------------
+
+subpkgpyexec_LTLIBRARIES = _frictioncontribmodule.la
+
+subpkgpyexec_PYTHON = \
+ frictioncontrib.py \
+ __init__.py
+
+swig_sources = \
+ frictioncontrib.i \
+ ViscousFriction.i
+
+swig_generated = \
+ frictioncontrib_wrap.cxx \
+ frictioncontrib.py
+
+_frictioncontribmodule_la_LDFLAGS = -module -avoid-version \
+ $(AM_LDFLAGS) $(PYTHON_LA_LDFLAGS)
+
+dist__frictioncontribmodule_la_SOURCES = $(swig_sources) $(swig_generated)
+
+_frictioncontribmodule_la_LIBADD = libfrictioncontrib.la
+if NO_UNDEFINED
+_frictioncontribmodule_la_LIBADD += \
+ $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
+endif
+
+INCLUDES += -I$(NUMPY_INCDIR) -I$(PYTHON_INCDIR)
+
+$(srcdir)/frictioncontrib_wrap.cxx $(srcdir)/frictioncontrib.py: $(swig_sources)
+ $(SWIG) -Wall -c++ -python $(SWIG_FLAGS) $<
+
+
+MAINTAINERCLEANFILES = $(swig_generated)
+
+
+
+# PYTHON ---------------------------------------------------------------
+
+nobase_subpkgpyexec_PYTHON = \
+ __init__.py \
+ ViscousFriction.py
+
+
+# End of file
Added: short/3D/PyLith/trunk/templates/friction/README
===================================================================
--- short/3D/PyLith/trunk/templates/friction/README (rev 0)
+++ short/3D/PyLith/trunk/templates/friction/README 2010-05-17 03:26:44 UTC (rev 16731)
@@ -0,0 +1,115 @@
+Overview
+
+ This directory contains source files for building a user defined
+ fault constitutive model component consisting of C++ code, a Python
+ module, and Python code. The example implementation provides viscous
+ (slip rate proportional) friction. State variables are used to hold
+ the slip rate. Note that state variables are not needed in this
+ case, but we use them in this example to illustrate how to use state
+ variables in a fault constitutive model.
+
+ The suggested path to customizing this component is to build and
+ install the provided ViscousFriction component and then rename/copy
+ the files and gradually adopt it to your specific needs. For more
+ complex bulk rheologies, you may want to use the SlipWeakening or
+ RateStateAgeing components provided with PyLith as templates.
+
+
+
+Requirements
+
+ In order to build the component and interface it with PyLith, you will need
+ * C++ compiler
+ * SWIG (version 1.3.33 or later)
+ * Python with header files (version 2.3 or later)
+ * autoconf tools
+
+ The C++ compiler must be compatible with the installed Python and
+ both must be compatible with the C++ compiler and Python used to
+ build PyLith. The safest way to insure compatibility is to use the
+ C++ compiler and Python provided with your operating system and
+ build PyLith from source. However, on many systems it should be
+ possible to build the component using g++ and have it work with
+ PyLith installed from a binary package.
+
+Files
+
+ Makefile.am - automake parameters for constructing a Makefile
+ ViscousFriction.cc - C++ source file implementing ViscousFriction object functions
+ ViscousFriction.hh - C++ header file with class definition for ViscousFriction
+ ViscousFriction.i - SWIG interface file for the C++ ViscousFriction object
+ README - this file
+ __init__.py - Python source file for module initialization
+ configure.ac - autoconf parameters for construction a configure script
+ m4 - directory containing autoconf macros
+ frictioncontrib.i - SWIG interface file defining the frictioncontrib Python module
+ tests - directory containing tests of the ViscousFriction object
+
+How to build/install the ViscousFriction component
+
+ 1. Run "autoreconf -if" in this directory (templates/friction).
+
+ 2. Run configure either from this directory or a scratch build
+ directory. Use the --prefix=DIRECTORY to indicate where the files
+ should be installed. We strongly recommend that you install the
+ component to the same location as where PyLith is installed. For
+ example, if PyLith is installed in $HOME/cig then use the
+ --prefix=$HOME/cig command line argument to configure. To build in a
+ separate directory simply invoke the configure script from the other
+ directory. For example, from $HOME/build/pylith-contrib run
+ $HOME/src/pylith/templates/friction/configure --prefix=$HOME/cig.
+
+ Configure will check for a number of files including the location of
+ PyLith C++ header files, library, and SWIG interface files. You
+ may need to define some additional command line arguments to
+ configure and/or environment variables to help configure find the
+ required files.
+
+ We run configure using on a MacBook Pro using MacPorts where we have
+ defined a number of environment variables in .bashrc for installed
+ tools.
+
+ ${HOME}/src/cig/pylith/templates/friction/configure \
+ --prefix=${CIG_DIR} \
+ CPPFLAGS="-I${PROJ4_INCDIR} -I${PORTS_INCDIR} -I${CIG_INCDIR}" \
+ LDFLAGS="-L${PROJ4_LIBDIR} -L${PORTS_LIBDIR} -L${CIG_LIBDIR} -F${PORTS_DIR}/Library/Frameworks" \
+ PYLITH_SWIG_DIR="${CIG_DIR}/share/pylith/swig" CC=gcc CXX=g++
+
+
+ 3. Run "make", "make install", and "make check" from the top-level
+ build directory. This will first build the C++ library and module,
+ then install the files to the location specified by the --prefix
+ command line argument to configure, and finally run some Python
+ tests to verify that the ViscousFriction component was installed
+ correctly.
+
+Customization
+
+ This is where the fun begins. Read over the Python and C++ source
+ code to become familiar with the features implemented with the
+ ViscousFriction component. The ViscousFriction Python object
+ simply defines what fields are available for output (properties in
+ the info files and state variables stress and strain in data files
+ at a given time in a simulation. The ViscousFriction C++ object
+ does the grunt work of computing the various quantities required for
+ computing the coefficient of friction. The interface for the fault
+ constitutive models has been designed to be simple and use arrays
+ rather than complex C++ data structures. This reduces speed slightly
+ but makes it much easier to implement new constitutive models.
+
+ We recommend that you start by changing the constitutive equations,
+ followed by changing the properties and state variables.
+
+Hints
+
+ Functions in friction model routines are called for every fault
+ vertex, so efficient code is important. Having said that, get the
+ implementation correct first and then worry about speed.
+
+ The consistency checks of user input should throw exceptions with a
+ meaningful error message so that the user can fix the
+ mistake. Consistency checks in the other routines should use the
+ assert() macro so that they can be removed during compilation. To
+ remove the assert() calls during compilation configure with -DNDEBUG
+ added to the CFLAGS and CXXFLAGS environment variables.
+
Added: short/3D/PyLith/trunk/templates/friction/ViscousFriction.cc
===================================================================
--- short/3D/PyLith/trunk/templates/friction/ViscousFriction.cc (rev 0)
+++ short/3D/PyLith/trunk/templates/friction/ViscousFriction.cc 2010-05-17 03:26:44 UTC (rev 16731)
@@ -0,0 +1,280 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "ViscousFriction.hh" // implementation of object methods
+
+#include "pylith/materials/Metadata.hh" // USES Metadata
+
+#include "pylith/utils/array.hh" // USES double_array
+#include "pylith/utils/constdefs.h" // USES MAXDOUBLE
+
+#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 {
+ namespace friction {
+ namespace _ViscousFriction {
+
+ // Number of physical properties.
+ const int numProperties = 3;
+
+ // Friction model parameters.
+ const pylith::materials::Metadata::ParamDescription properties[] = {
+ { "static_coefficient", 1, pylith::topology::FieldBase::SCALAR },
+ { "reference_slip_rate", 1, pylith::topology::FieldBase::SCALAR },
+ { "cohesion", 1, pylith::topology::FieldBase::SCALAR },
+ };
+
+ // Number of state variables.
+ const int numStateVars = 1;
+
+ // State variables.
+ const pylith::materials::Metadata::ParamDescription stateVars[] = {
+ { "slip_rate", 1, pylith::topology::FieldBase::SCALAR },
+ };
+
+ // Values expected in spatial database
+ const int numDBProperties = 3;
+ const char* dbProperties[3] = { "viscous-coefficient",
+ "reference-slip-rate",
+ "cohesion",
+ };
+
+ const int numDBStateVars = 1;
+ const char* dbStateVars[1] = { "slip-rate",
+ };
+
+ } // _ViscousFriction
+ } // friction
+} // pylith
+
+// 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 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;
+
+// Indices of state variables.
+const int pylith::friction::ViscousFriction::s_slipRate = 0;
+
+// Indices of database values (order must match dbProperties)
+const int pylith::friction::ViscousFriction::db_slipRate = 0;
+
+// ----------------------------------------------------------------------
+// Default constructor.
+pylith::friction::ViscousFriction::ViscousFriction(void) :
+ FrictionModel(materials::Metadata(_ViscousFriction::properties,
+ _ViscousFriction::numProperties,
+ _ViscousFriction::dbProperties,
+ _ViscousFriction::numDBProperties,
+ _ViscousFriction::stateVars,
+ _ViscousFriction::numStateVars,
+ _ViscousFriction::dbStateVars,
+ _ViscousFriction::numDBStateVars))
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor.
+pylith::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
+{ // _dbToProperties
+ assert(0 != propValues);
+ const int numDBValues = dbValues.size();
+ assert(_ViscousFriction::numDBProperties == numDBValues);
+
+ const double coefS = dbValues[db_coefS];
+ const double v0 = dbValues[db_v0];
+ const double cohesion = dbValues[db_cohesion];
+
+ if (coefS <= 0.0) {
+ std::ostringstream msg;
+ msg << "Spatial database returned nonpositive value for static "
+ << "coefficient of friction.\n"
+ << "Static coefficient of friction: " << v0 << "\n";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ if (cohesion < 0.0) {
+ std::ostringstream msg;
+ msg << "Spatial database returned negative value for cohesion.\n"
+ << "Cohesion: " << cohesion << "\n";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ propValues[p_coefS] = coefS;
+ propValues[p_v0] = db_v0;
+ propValues[p_cohesion] = cohesion;
+
+} // _dbToProperties
+
+// ----------------------------------------------------------------------
+// Nondimensionalize properties.
+void
+pylith::friction::ViscousFriction::_nondimProperties(double* const values,
+ const int nvalues) const
+{ // _nondimProperties
+ assert(0 != _normalizer);
+ assert(0 != values);
+ assert(nvalues == _ViscousFriction::numProperties);
+
+ 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;
+} // _nondimProperties
+
+// ----------------------------------------------------------------------
+// Dimensionalize properties.
+void
+pylith::friction::ViscousFriction::_dimProperties(double* const values,
+ const int nvalues) const
+{ // _dimProperties
+ assert(0 != _normalizer);
+ assert(0 != values);
+ assert(nvalues == _ViscousFriction::numProperties);
+
+ 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;
+} // _dimProperties
+
+// ----------------------------------------------------------------------
+// Compute state variables from values in spatial database.
+void
+pylith::friction::ViscousFriction::_dbToStateVars(
+ double* const stateValues,
+ const double_array& dbValues) const
+{ // _dbToStateVars
+ assert(0 != stateValues);
+ const int numDBValues = dbValues.size();
+ assert(_ViscousFriction::numDBStateVars == numDBValues);
+
+ const double slipRate = dbValues[db_slipRate];
+
+ stateValues[s_slipRate] = slipRate;
+} // _dbToStateVars
+
+// ----------------------------------------------------------------------
+// Nondimensionalize state variables.
+void
+pylith::friction::ViscousFriction::_nondimStateVars(double* const values,
+ const int nvalues) const
+{ // _nondimStateVars
+ assert(0 != _normalizer);
+ assert(0 != values);
+ assert(nvalues == _ViscousFriction::numStateVars);
+
+ const double lengthScale = _normalizer->lengthScale();
+ const double timeScale = _normalizer->timeScale();
+ const double velocityScale = lengthScale / timeScale;
+
+ values[s_slipRate] /= velocityScale;
+} // _nondimStateVars
+
+// ----------------------------------------------------------------------
+// Dimensionalize state variables.
+void
+pylith::friction::ViscousFriction::_dimStateVars(double* const values,
+ const int nvalues) const
+{ // _dimStateVars
+ assert(0 != _normalizer);
+ assert(0 != values);
+ assert(nvalues == _ViscousFriction::numStateVars);
+
+ const double lengthScale = _normalizer->lengthScale();
+ const double timeScale = _normalizer->timeScale();
+ const double velocityScale = lengthScale / timeScale;
+
+ values[s_slipRate] *= velocityScale;
+} // _dimStateVars
+
+// ----------------------------------------------------------------------
+// Compute friction from properties and state variables.
+double
+pylith::friction::ViscousFriction::_calcFriction(const double slip,
+ const double slipRate,
+ const double normalTraction,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars)
+{ // _calcFriction
+ assert(0 != properties);
+ assert(_numPropsVertex == numProperties);
+ assert(0 != numStateVars);
+ assert(_numVarsVertex == numStateVars);
+
+ double friction = 0.0;
+ double 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]);
+ 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,
+ const double slipRate,
+ const double normalTraction,
+ double* const stateVars,
+ const int numStateVars,
+ const double* properties,
+ const int numProperties)
+{ // _updateStateVars
+ assert(0 != numStateVars);
+ assert(0 != numProperties);
+
+ stateVars[s_slipRate] = stateVars[s_slipRate];
+} // _updateStateVars
+
+
+// End of file
Added: short/3D/PyLith/trunk/templates/friction/ViscousFriction.hh
===================================================================
--- short/3D/PyLith/trunk/templates/friction/ViscousFriction.hh (rev 0)
+++ short/3D/PyLith/trunk/templates/friction/ViscousFriction.hh 2010-05-17 03:26:44 UTC (rev 16731)
@@ -0,0 +1,170 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file libsrc/friction/ViscousFriction.hh
+ *
+ * @brief C++ viscous (slip rate proportional) fault constitutive
+ * model.
+ */
+
+#if !defined(pylith_friction_viscousfriction_hh)
+#define pylith_friction_viscousfriction_hh
+
+// Include directives ---------------------------------------------------
+#include "FrictionModel.hh" // ISA FrictionModel
+
+// 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 ViscousFriction
+ friend class TestViscousFriction; // unit testing
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Default constructor.
+ ViscousFriction(void);
+
+ /// Destructor.
+ ~ViscousFriction(void);
+
+ // PROTECTED METHODS //////////////////////////////////////////////////
+protected :
+
+ /// These methods should be implemented by every constitutive model.
+
+ /** 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.
+ */
+ void _dbToStateVars(double* const stateValues,
+ const double_array& dbValues) const;
+
+ /** Nondimensionalize state variables.
+ *
+ * @param values Array of initial state values.
+ * @param nvalues Number of values.
+ */
+ void _nondimStateVars(double* const values,
+ const int nvalues) const;
+
+ /** Dimensionalize state variables.
+ *
+ * @param values Array of initial state values.
+ * @param nvalues Number of values.
+ */
+ void _dimStateVars(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);
+
+ /** Update state variables (for next time step).
+ *
+ * @param slip Current slip at location.
+ * @param slipRate Current slip rate at location.
+ * @param normalTraction Normal traction at location.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @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);
+
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+
+ /// Indices for properties in section and spatial database.
+ 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 ////////////////////////////////////////////////////
+private :
+
+ ViscousFriction(const ViscousFriction&); ///< Not implemented.
+ const ViscousFriction& operator=(const ViscousFriction&); ///< Not implemented
+
+}; // class ViscousFriction
+
+#endif // pylith_friction_viscousfriction_hh
+
+
+// End of file
Added: short/3D/PyLith/trunk/templates/friction/ViscousFriction.i
===================================================================
--- short/3D/PyLith/trunk/templates/friction/ViscousFriction.i (rev 0)
+++ short/3D/PyLith/trunk/templates/friction/ViscousFriction.i 2010-05-17 03:26:44 UTC (rev 16731)
@@ -0,0 +1,84 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/friction/ViscousFriction.i
+ *
+ * Python interface to C++ ViscousFriction object.
+ */
+
+namespace pylith {
+ namespace friction {
+
+ class ViscousFriction : public FrictionModel
+ { // class ViscousFriction
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ ViscousFriction(void);
+
+ /// Destructor.
+ ~ViscousFriction(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 ViscousFriction
+
+ } // friction
+} // pylith
+
+
+// End of file
Added: short/3D/PyLith/trunk/templates/friction/ViscousFriction.py
===================================================================
--- short/3D/PyLith/trunk/templates/friction/ViscousFriction.py (rev 0)
+++ short/3D/PyLith/trunk/templates/friction/ViscousFriction.py 2010-05-17 03:26:44 UTC (rev 16731)
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/friction/ViscousFriction.py
+##
+## @brief Python object implementing viscous friction.
+##
+## Factory: friction_model.
+
+from FrictionModel import FrictionModel
+from friction import ViscousFriction as ModuleViscousFriction
+
+# ViscousFriction class
+class ViscousFriction(FrictionModel, ModuleViscousFriction):
+ """
+ Python object implementing viscous friction.
+
+ Factory: friction_model.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="viscousfriction"):
+ """
+ Constructor.
+ """
+ FrictionModel.__init__(self, name)
+ self.availableFields = \
+ {'vertex': \
+ {'info': ["static_coefficient",
+ "reference_slip_rate"],
+ 'data': ["slip_rate"]},
+ 'cell': \
+ {'info': [],
+ 'data': []}}
+ self._loggingPrefix = "FrVisc "
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _createModuleObj(self):
+ """
+ Call constructor for module object for access to C++ object.
+ """
+ ModuleViscousFriction.__init__(self)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def friction_model():
+ """
+ Factory associated with ViscousFriction.
+ """
+ return ViscousFriction()
+
+
+# End of file
Added: short/3D/PyLith/trunk/templates/friction/__init__.py
===================================================================
--- short/3D/PyLith/trunk/templates/friction/__init__.py (rev 0)
+++ short/3D/PyLith/trunk/templates/friction/__init__.py 2010-05-17 03:26:44 UTC (rev 16731)
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file __init__.py
+##
+## @brief Python module initialization
+
+__all__ = ['ViscousFriction',
+ ]
+
+
+# End of file
Added: short/3D/PyLith/trunk/templates/friction/configure.ac
===================================================================
--- short/3D/PyLith/trunk/templates/friction/configure.ac (rev 0)
+++ short/3D/PyLith/trunk/templates/friction/configure.ac 2010-05-17 03:26:44 UTC (rev 16731)
@@ -0,0 +1,79 @@
+# -*- autoconf -*-
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+AC_PREREQ(2.59)
+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])
+AM_INIT_AUTOMAKE([foreign])
+
+# ----------------------------------------------------------------------
+# C/C++/libtool/install
+AC_PROG_CXX
+AC_PROG_CC
+AC_DISABLE_STATIC
+
+AC_PROG_LIBTOOL
+if test "$allow_undefined_flag" = unsupported; then
+ # See issue119.
+ AM_LDFLAGS="-no-undefined $AM_LDFLAGS"
+fi
+AM_CONDITIONAL([NO_UNDEFINED], [test "$allow_undefined_flag" = unsupported])
+AC_SUBST(AM_LDFLAGS)
+
+AC_PROG_INSTALL
+
+# PYTHON
+AM_PATH_PYTHON([2.3])
+CIT_PYTHON_SYSCONFIG
+
+# SWIG
+CIT_NUMPY_PYTHON_MODULE
+CIT_NUMPY_INCDIR
+AC_PROG_SWIG(1.3.33)
+
+# PYLITH
+AC_LANG(C++)
+AC_CHECK_HEADER([pylith/friction/FrictionModel.hh], [], [
+ AC_MSG_ERROR([PyLith FrictionModel header not found; try CPPFLAGS="-I<PyLith include dir>"])
+])
+AC_MSG_CHECKING([for friction::StaticFriction in -lpylith])
+AC_REQUIRE_CPP
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[#include <pylith/friction/StaticFriction.hh>]],
+ [[pylith::friction::StaticFriction material;]])],
+ [AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)
+ AC_MSG_ERROR([PyLith library not found; try LDFLAGS="-L<PyLith lib dir>"])
+])
+if test "x$PYLITH_SWIG_DIR" != "x" ; then
+ AC_CHECK_FILE([$PYLITH_SWIG_DIR/friction/FrictionModel.i], [], [
+ AC_MSG_ERROR([PyLith FrictionModel.i SWIG interface file not found])])
+ AC_SUBST([SWIG_FLAGS], ["-I$PYLITH_SWIG_DIR $SWIG_FLAGS"])
+else
+ AC_CHECK_FILE([friction/FrictionModel.i], [], [
+ AC_MSG_ERROR([PyLith FrictionModel.i SWIG interface file not found; Try setting PYLITH_SWIG_DIR=<directory containing friction/FrictionModel.i>])])
+fi
+
+
+# ENDIANNESS
+AC_C_BIGENDIAN
+
+# ----------------------------------------------------------------------
+AC_CONFIG_FILES([Makefile
+ tests/Makefile])
+
+AC_OUTPUT
+
+
+# End of file
Added: short/3D/PyLith/trunk/templates/friction/frictioncontrib.i
===================================================================
--- short/3D/PyLith/trunk/templates/friction/frictioncontrib.i (rev 0)
+++ short/3D/PyLith/trunk/templates/friction/frictioncontrib.i 2010-05-17 03:26:44 UTC (rev 16731)
@@ -0,0 +1,55 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// Define the frictioncontrib SWIG interface module.
+
+// Set module name
+%module frictioncontrib
+
+// Header files for module C++ code.
+%{
+#include "pylith/friction/frictionfwd.hh" // forward declarations
+
+#include "ViscousFriction.hh"
+
+#include "pylith/utils/arrayfwd.hh"
+%}
+
+// Convert standard C++ exceptions to Python exceptions.
+%include "exception.i"
+%exception {
+ try {
+ $action
+ } catch (const std::exception& err) {
+ SWIG_exception(SWIG_RuntimeError, err.what());
+ } // try/catch
+} // exception
+
+%include "typemaps.i"
+%include "include/doublearray.i"
+
+// Numpy interface stuff
+%{
+#define SWIG_FILE_WITH_INIT
+%}
+%include "include/numpy.i"
+%init %{
+import_array();
+%}
+
+
+// Interface files.
+%include "friction/FrictionModel.i"
+%include "ViscousFriction.i"
+
+
+// End of file
Modified: short/3D/PyLith/trunk/templates/materials/materialscontrib.i
===================================================================
--- short/3D/PyLith/trunk/templates/materials/materialscontrib.i 2010-05-17 02:46:57 UTC (rev 16730)
+++ short/3D/PyLith/trunk/templates/materials/materialscontrib.i 2010-05-17 03:26:44 UTC (rev 16731)
@@ -10,7 +10,7 @@
// ======================================================================
//
-// Define the spatialdatacontrib SWIG interface module.
+// Define the materialscontrib SWIG interface module.
// Set module name
%module materialscontrib
More information about the CIG-COMMITS
mailing list