[cig-commits] r15793 - in short/3D/PyLith/branches/pylith-friction: libsrc libsrc/faults modulesrc/faults pylith pylith/faults
brad at geodynamics.org
brad at geodynamics.org
Sat Oct 10 21:45:10 PDT 2009
Author: brad
Date: 2009-10-10 21:45:09 -0700 (Sat, 10 Oct 2009)
New Revision: 15793
Added:
short/3D/PyLith/branches/pylith-friction/libsrc/faults/TimeHistorySlipFn.cc
short/3D/PyLith/branches/pylith-friction/libsrc/faults/TimeHistorySlipFn.hh
short/3D/PyLith/branches/pylith-friction/libsrc/faults/TimeHistorySlipFn.icc
short/3D/PyLith/branches/pylith-friction/modulesrc/faults/TimeHistorySlipFn.i
short/3D/PyLith/branches/pylith-friction/pylith/faults/TimeHistorySlipFn.py
Modified:
short/3D/PyLith/branches/pylith-friction/libsrc/Makefile.am
short/3D/PyLith/branches/pylith-friction/libsrc/faults/Makefile.am
short/3D/PyLith/branches/pylith-friction/libsrc/faults/faultsfwd.hh
short/3D/PyLith/branches/pylith-friction/modulesrc/faults/faults.i
short/3D/PyLith/branches/pylith-friction/pylith/Makefile.am
short/3D/PyLith/branches/pylith-friction/pylith/faults/LiuCosSlipFn.py
Log:
Added TimeHistorySlipFn.
Modified: short/3D/PyLith/branches/pylith-friction/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-friction/libsrc/Makefile.am 2009-10-09 22:17:00 UTC (rev 15792)
+++ short/3D/PyLith/branches/pylith-friction/libsrc/Makefile.am 2009-10-11 04:45:09 UTC (rev 15793)
@@ -38,6 +38,7 @@
faults/StepSlipFn.cc \
faults/ConstRateSlipFn.cc \
faults/BruneSlipFn.cc \
+ faults/TimeHistorySlipFn.cc \
faults/LiuCosSlipFn.cc \
faults/EqKinSrc.cc \
faults/TopologyOps.cc \
Modified: short/3D/PyLith/branches/pylith-friction/libsrc/faults/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-friction/libsrc/faults/Makefile.am 2009-10-09 22:17:00 UTC (rev 15792)
+++ short/3D/PyLith/branches/pylith-friction/libsrc/faults/Makefile.am 2009-10-11 04:45:09 UTC (rev 15793)
@@ -34,6 +34,8 @@
SlipTimeFn.hh \
StepSlipFn.hh \
StepSlipFn.icc \
+ TimeHistorySlipFn.hh \
+ TimeHistorySlipFn.icc \
faultsfwd.hh
noinst_HEADERS = \
Added: short/3D/PyLith/branches/pylith-friction/libsrc/faults/TimeHistorySlipFn.cc
===================================================================
--- short/3D/PyLith/branches/pylith-friction/libsrc/faults/TimeHistorySlipFn.cc (rev 0)
+++ short/3D/PyLith/branches/pylith-friction/libsrc/faults/TimeHistorySlipFn.cc 2009-10-11 04:45:09 UTC (rev 15793)
@@ -0,0 +1,351 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TimeHistorySlipFn.hh" // implementation of object methods
+
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Fields.hh" // USES Fields
+#include "pylith/topology/Field.hh" // USES Field
+
+#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
+#include "spatialdata/spatialdb/TimeHistory.hh" // USES TimeHistory
+#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
+#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
+
+#include <cassert> // USES assert()
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
+
+// ----------------------------------------------------------------------
+typedef pylith::topology::SubMesh::SieveMesh SieveMesh;
+typedef pylith::topology::SubMesh::SieveMesh::label_sequence label_sequence;
+typedef pylith::topology::SubMesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
+// Default constructor.
+pylith::faults::TimeHistorySlipFn::TimeHistorySlipFn(void) :
+ _slipTimeVertex(0),
+ _timeScale(1.0),
+ _dbAmplitude(0),
+ _dbSlipTime(0),
+ _dbTimeHistory(0)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor.
+pylith::faults::TimeHistorySlipFn::~TimeHistorySlipFn(void)
+{ // destructor
+ deallocate();
+} // destructor
+
+// ----------------------------------------------------------------------
+// Deallocate PETSc and local data structures.
+void
+pylith::faults::TimeHistorySlipFn::deallocate(void)
+{ // deallocate
+ SlipTimeFn::deallocate();
+
+ _dbAmplitude = 0; // :TODO: Use shared pointer
+ _dbSlipTime = 0; // :TODO: Use shared pointer
+ _dbTimeHistory = 0; // :TODO: Use shared pointer
+} // deallocate
+
+// ----------------------------------------------------------------------
+// Initialize slip time function.
+void
+pylith::faults::TimeHistorySlipFn::initialize(
+ const topology::SubMesh& faultMesh,
+ const spatialdata::units::Nondimensional& normalizer,
+ const double originTime)
+{ // initialize
+ assert(0 != _dbAmplitude);
+ assert(0 != _dbSlipTime);
+
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ assert(0 != cs);
+ const int spaceDim = cs->spaceDim();
+
+ const double lengthScale = normalizer.lengthScale();
+ const double timeScale = normalizer.timeScale();
+
+ // Memory logging
+ ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
+ logger.stagePush("Fault");
+
+ // Get vertices in fault mesh
+ const ALE::Obj<SieveMesh>& sieveMesh = faultMesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const label_sequence::iterator verticesBegin = vertices->begin();
+ const label_sequence::iterator verticesEnd = vertices->end();
+
+ delete _parameters; _parameters = new topology::Fields<topology::Field<topology::SubMesh> >(faultMesh);
+ assert(0 != _parameters);
+ _parameters->add("slip amplitude", "slip_amplitude");
+
+ topology::Field<topology::SubMesh>& slipAmplitude = _parameters->get("slip amplitude");
+ slipAmplitude.newSection(vertices, spaceDim);
+ slipAmplitude.allocate();
+ slipAmplitude.scale(lengthScale);
+ slipAmplitude.vectorFieldType(topology::FieldBase::VECTOR);
+ const ALE::Obj<RealSection>& slipAmplitudeSection = slipAmplitude.section();
+ assert(!slipAmplitudeSection.isNull());
+
+ _parameters->add("slip time", "slip_time");
+ topology::Field<topology::SubMesh>& slipTime = _parameters->get("slip time");
+ slipTime.newSection(slipAmplitude, 1);
+ slipTime.allocate();
+ slipTime.scale(timeScale);
+ slipTime.vectorFieldType(topology::FieldBase::SCALAR);
+ const ALE::Obj<RealSection>& slipTimeSection = slipTime.section();
+ assert(!slipTimeSection.isNull());
+
+ logger.stagePop();
+
+ // Open databases and set query values
+ _dbAmplitude->open();
+ switch (spaceDim)
+ { // switch
+ case 1 : {
+ const char* slipValues[] = {"fault-opening"};
+ _dbAmplitude->queryVals(slipValues, 1);
+ break;
+ } // case 1
+ case 2 : {
+ const char* slipValues[] = {"left-lateral-slip", "fault-opening"};
+ _dbAmplitude->queryVals(slipValues, 2);
+ break;
+ } // case 2
+ case 3 : {
+ const char* slipValues[] = {"left-lateral-slip", "reverse-slip",
+ "fault-opening"};
+ _dbAmplitude->queryVals(slipValues, 3);
+ break;
+ } // case 3
+ default :
+ std::cerr << "Bad spatial dimension '" << spaceDim << "'." << std::endl;
+ assert(0);
+ throw std::logic_error("Bad spatial dimension in TimeHistorySlipFn.");
+ } // switch
+
+ _dbSlipTime->open();
+ const char* slipTimeValues[] = {"slip-time"};
+ _dbSlipTime->queryVals(slipTimeValues, 1);
+
+ // Get coordinates of vertices
+ const ALE::Obj<RealSection>& coordinates =
+ sieveMesh->getRealSection("coordinates");
+ assert(!coordinates.isNull());
+
+ _slipVertex.resize(spaceDim);
+ double_array vCoordsGlobal(spaceDim);
+ for (label_sequence::iterator v_iter=verticesBegin;
+ v_iter != verticesEnd;
+ ++v_iter) {
+ coordinates->restrictPoint(*v_iter,
+ &vCoordsGlobal[0], vCoordsGlobal.size());
+ normalizer.dimensionalize(&vCoordsGlobal[0], vCoordsGlobal.size(),
+ lengthScale);
+
+ int err = _dbAmplitude->query(&_slipVertex[0], _slipVertex.size(),
+ &vCoordsGlobal[0], vCoordsGlobal.size(), cs);
+ if (err) {
+ std::ostringstream msg;
+ msg << "Could not find slip amplitude at (";
+ for (int i=0; i < spaceDim; ++i)
+ msg << " " << vCoordsGlobal[i];
+ msg << ") using spatial database " << _dbAmplitude->label() << ".";
+ throw std::runtime_error(msg.str());
+ } // if
+ normalizer.nondimensionalize(&_slipVertex[0], _slipVertex.size(),
+ lengthScale);
+
+ err = _dbSlipTime->query(&_slipTimeVertex, 1,
+ &vCoordsGlobal[0], vCoordsGlobal.size(), cs);
+ if (err) {
+ std::ostringstream msg;
+ msg << "Could not find slip initiation time at (";
+ for (int i=0; i < spaceDim; ++i)
+ msg << " " << vCoordsGlobal[i];
+ msg << ") using spatial database " << _dbSlipTime->label() << ".";
+ throw std::runtime_error(msg.str());
+ } // if
+ normalizer.nondimensionalize(&_slipTimeVertex, 1, timeScale);
+ // add origin time to rupture time
+ _slipTimeVertex += originTime;
+
+ slipAmplitudeSection->updatePoint(*v_iter, &_slipVertex[0]);
+ slipTimeSection->updatePoint(*v_iter, &_slipTimeVertex);
+ } // for
+
+ // Close databases.
+ _dbAmplitude->close();
+ _dbSlipTime->close();
+
+ // Open time history database.
+ _dbTimeHistory->open();
+ _timeScale = timeScale;
+} // initialize
+
+// ----------------------------------------------------------------------
+// Get slip on fault surface at time t.
+void
+pylith::faults::TimeHistorySlipFn::slip(topology::Field<topology::SubMesh>* slip,
+ const double t)
+{ // slip
+ assert(0 != slip);
+ assert(0 != _parameters);
+ assert(0 != _dbTimeHistory);
+
+ // Get vertices in fault mesh
+ const ALE::Obj<SieveMesh>& sieveMesh = slip->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const label_sequence::iterator verticesBegin = vertices->begin();
+ const label_sequence::iterator verticesEnd = vertices->end();
+
+ // Get sections
+ const topology::Field<topology::SubMesh>& slipAmplitude =
+ _parameters->get("slip amplitude");
+ const ALE::Obj<RealSection>& slipAmplitudeSection = slipAmplitude.section();
+ assert(!slipAmplitudeSection.isNull());
+ const topology::Field<topology::SubMesh>& slipTime =
+ _parameters->get("slip time");
+ const ALE::Obj<RealSection>& slipTimeSection = slipTime.section();
+ assert(!slipTimeSection.isNull());
+ const ALE::Obj<RealSection>& slipSection = slip->section();
+ assert(!slipSection.isNull());
+
+ double amplitude = 0.0;
+ for (label_sequence::iterator v_iter=verticesBegin;
+ v_iter != verticesEnd;
+ ++v_iter) {
+ slipAmplitudeSection->restrictPoint(*v_iter, &_slipVertex[0], _slipVertex.size());
+ slipTimeSection->restrictPoint(*v_iter, &_slipTimeVertex, 1);
+
+ double relTime = t - _slipTimeVertex;
+ if (relTime < 0.0)
+ _slipVertex = 0.0;
+ else {
+ relTime *= _timeScale;
+ const int err = _dbTimeHistory->query(&litude, relTime);
+ if (0 != err) {
+ std::ostringstream msg;
+ msg << "Error querying for time '" << relTime
+ << "' in time history database "
+ << _dbTimeHistory->label() << ".";
+ throw std::runtime_error(msg.str());
+ } // if
+ _slipVertex *= amplitude;
+ } // else
+
+ // Update field
+ slipSection->updateAddPoint(*v_iter, &_slipVertex[0]);
+ } // for
+
+ PetscLogFlops(vertices->size() * 1);
+} // slip
+
+// ----------------------------------------------------------------------
+// Get increment of slip on fault surface between time t0 and t1.
+void
+pylith::faults::TimeHistorySlipFn::slipIncr(topology::Field<topology::SubMesh>* slip,
+ const double t0,
+ const double t1)
+{ // slipIncr
+ assert(0 != slip);
+ assert(0 != _parameters);
+
+ // Get vertices in fault mesh
+ const ALE::Obj<SieveMesh>& sieveMesh = slip->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const label_sequence::iterator verticesBegin = vertices->begin();
+ const label_sequence::iterator verticesEnd = vertices->end();
+
+ // Get sections
+ const topology::Field<topology::SubMesh>& slipAmplitude =
+ _parameters->get("slip amplitude");
+ const ALE::Obj<RealSection>& slipAmplitudeSection = slipAmplitude.section();
+ assert(!slipAmplitudeSection.isNull());
+ const topology::Field<topology::SubMesh>& slipTime =
+ _parameters->get("slip time");
+ const ALE::Obj<RealSection>& slipTimeSection = slipTime.section();
+ assert(!slipTimeSection.isNull());
+ const ALE::Obj<RealSection>& slipSection = slip->section();
+ assert(!slipSection.isNull());
+
+ double amplitude0 = 0.0;
+ double amplitude1 = 0.0;
+ for (label_sequence::iterator v_iter=verticesBegin;
+ v_iter != verticesEnd;
+ ++v_iter) {
+ slipAmplitudeSection->restrictPoint(*v_iter, &_slipVertex[0], _slipVertex.size());
+ slipTimeSection->restrictPoint(*v_iter, &_slipTimeVertex, 1);
+
+ double relTime0 = t0 - _slipTimeVertex;
+ double relTime1 = t1 - _slipTimeVertex;
+ if (relTime1 < 0.0)
+ _slipVertex = 0.0;
+ else {
+ relTime0 *= _timeScale;
+ relTime1 *= _timeScale;
+ int err = _dbTimeHistory->query(&litude0, relTime0);
+ if (0 != err) {
+ std::ostringstream msg;
+ msg << "Error querying for time '" << relTime0
+ << "' in time history database "
+ << _dbTimeHistory->label() << ".";
+ throw std::runtime_error(msg.str());
+ } // if
+ err = _dbTimeHistory->query(&litude1, relTime1);
+ if (0 != err) {
+ std::ostringstream msg;
+ msg << "Error querying for time '" << relTime1
+ << "' in time history database "
+ << _dbTimeHistory->label() << ".";
+ throw std::runtime_error(msg.str());
+ } // if
+ _slipVertex *= amplitude1 - amplitude0;
+ } // else
+
+ // Update field
+ slipSection->updateAddPoint(*v_iter, &_slipVertex[0]);
+ } // for
+
+ PetscLogFlops(vertices->size() * 2);
+} // slipIncr
+
+// ----------------------------------------------------------------------
+// Get final slip.
+const pylith::topology::Field<pylith::topology::SubMesh>&
+pylith::faults::TimeHistorySlipFn::finalSlip(void)
+{ // finalSlip
+ return _parameters->get("slip amplitude");
+} // finalSlip
+
+// ----------------------------------------------------------------------
+// Get time when slip begins at each point.
+const pylith::topology::Field<pylith::topology::SubMesh>&
+pylith::faults::TimeHistorySlipFn::slipTime(void)
+{ // slipTime
+ return _parameters->get("slip time");
+} // slipTime
+
+
+// End of file
Added: short/3D/PyLith/branches/pylith-friction/libsrc/faults/TimeHistorySlipFn.hh
===================================================================
--- short/3D/PyLith/branches/pylith-friction/libsrc/faults/TimeHistorySlipFn.hh (rev 0)
+++ short/3D/PyLith/branches/pylith-friction/libsrc/faults/TimeHistorySlipFn.hh 2009-10-11 04:45:09 UTC (rev 15793)
@@ -0,0 +1,144 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file libsrc/faults/TimeHistorySlipFn.hh
+ *
+ * @brief C++ implementation of a slip time function with a
+ * user-specified time history.
+ */
+
+#if !defined(pylith_faults_timehistoryslipfn_hh)
+#define pylith_faults_timehistoryslipfn_hh
+
+// Include directives ---------------------------------------------------
+#include "SlipTimeFn.hh"
+
+#include "pylith/utils/array.hh" // HASA double_array
+
+// TimeHistorySlipFn -----------------------------------------------------------
+/**
+ * @brief C++ implementation of a slip time function with a
+ * user-specified time history.
+ *
+ * User-specified slip time function with spatial variable amplitude
+ * and starting time t0.
+*/
+class pylith::faults::TimeHistorySlipFn : public SlipTimeFn
+{ // class TimeHistorySlipFn
+ friend class TestTimeHistorySlipFn; // unit testing
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ /// Default constructor.
+ TimeHistorySlipFn(void);
+
+ /// Destructor.
+ ~TimeHistorySlipFn(void);
+
+ /// Deallocate PETSc and local data structures.
+ virtual
+ void deallocate(void);
+
+ /** Set spatial database for amplitude of slip time history.
+ *
+ * @param db Spatial database
+ */
+ void dbAmplitude(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Set spatial database for slip initiation time.
+ *
+ * @param db Spatial database
+ */
+ void dbSlipTime(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Set time history.
+ *
+ * @param th Time history.
+ */
+ void dbTimeHistory(spatialdata::spatialdb::TimeHistory* const th);
+
+ /** Initialize slip time function.
+ *
+ * @param faultMesh Finite-element mesh of fault.
+ * @param cs Coordinate system for mesh
+ * @param normalizer Nondimensionalization of scales.
+ * @param originTime Origin time for earthquake source.
+ */
+ void initialize(const topology::SubMesh& faultMesh,
+ const spatialdata::units::Nondimensional& normalizer,
+ const double originTime =0.0);
+
+ /** Get slip on fault surface at time t.
+ *
+ * @param slipField Slip field over fault surface.
+ * @param t Time t.
+ *
+ * @returns Slip vector as left-lateral/reverse/normal.
+ */
+ void slip(topology::Field<topology::SubMesh>* const slipField,
+ const double t);
+
+ /** Get slip increment on fault surface between time t0 and t1.
+ *
+ * @param slipField Slip field over fault surface.
+ * @param t0 Time t.
+ * @param t1 Time t+dt.
+ *
+ * @returns Increment in slip vector as left-lateral/reverse/normal.
+ */
+ void slipIncr(topology::Field<topology::SubMesh>* slipField,
+ const double t0,
+ const double t1);
+
+ /** Get final slip.
+ *
+ * @returns Final slip.
+ */
+ const topology::Field<topology::SubMesh>& finalSlip(void);
+
+ /** Get time when slip begins at each point.
+ *
+ * @returns Time when slip begins.
+ */
+ const topology::Field<topology::SubMesh>& slipTime(void);
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ TimeHistorySlipFn(const TimeHistorySlipFn&); ///< Not implemented.
+ const TimeHistorySlipFn& operator=(const TimeHistorySlipFn&); ///< Not implemented
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+ double _slipTimeVertex; ///< Slip time at a vertex.
+ double _timeScale; ///< Time scale.
+ double_array _slipVertex; ///< Final slip at a vertex.
+
+ /// Spatial database for amplitude of slip time history.
+ spatialdata::spatialdb::SpatialDB* _dbAmplitude;
+
+ /// Spatial database for slip time.
+ spatialdata::spatialdb::SpatialDB* _dbSlipTime;
+
+ /// Time history database.
+ spatialdata::spatialdb::TimeHistory* _dbTimeHistory;
+
+}; // class TimeHistorySlipFn
+
+#include "TimeHistorySlipFn.icc" // inline methods
+
+#endif // pylith_faults_timehistoryslipfn_hh
+
+
+// End of file
Added: short/3D/PyLith/branches/pylith-friction/libsrc/faults/TimeHistorySlipFn.icc
===================================================================
--- short/3D/PyLith/branches/pylith-friction/libsrc/faults/TimeHistorySlipFn.icc (rev 0)
+++ short/3D/PyLith/branches/pylith-friction/libsrc/faults/TimeHistorySlipFn.icc 2009-10-11 04:45:09 UTC (rev 15793)
@@ -0,0 +1,39 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#if !defined(pylith_faults_timehistoryslipfn_hh)
+#error "TimeHistorySlipFn.icc can only be included from TimeHistorySlipFn.hh"
+#endif
+
+// Set spatial database for final slip.
+inline
+void
+pylith::faults::TimeHistorySlipFn::dbAmplitude(spatialdata::spatialdb::SpatialDB* const db) {
+ _dbAmplitude = db;
+} // dbFinalSlip
+
+// Set spatial database for slip initiation time.
+inline
+void
+pylith::faults::TimeHistorySlipFn::dbSlipTime(spatialdata::spatialdb::SpatialDB* const db) {
+ _dbSlipTime = db;
+} // dbSlipTime
+
+// Set time history.
+inline
+void
+pylith::faults::TimeHistorySlipFn::dbTimeHistory(spatialdata::spatialdb::TimeHistory* const th) {
+ _dbTimeHistory = th;
+} // dbTimeHistory
+
+
+// End of file
Modified: short/3D/PyLith/branches/pylith-friction/libsrc/faults/faultsfwd.hh
===================================================================
--- short/3D/PyLith/branches/pylith-friction/libsrc/faults/faultsfwd.hh 2009-10-09 22:17:00 UTC (rev 15792)
+++ short/3D/PyLith/branches/pylith-friction/libsrc/faults/faultsfwd.hh 2009-10-11 04:45:09 UTC (rev 15793)
@@ -38,6 +38,7 @@
class ConstRateSlipFn;
class LiuCosSlipFn;
class StepSlipFn;
+ class TimeHistorySlipFn;
class TopologyOps;
template<typename Sieve, typename Renumbering> class ReplaceVisitor;
Added: short/3D/PyLith/branches/pylith-friction/modulesrc/faults/TimeHistorySlipFn.i
===================================================================
--- short/3D/PyLith/branches/pylith-friction/modulesrc/faults/TimeHistorySlipFn.i (rev 0)
+++ short/3D/PyLith/branches/pylith-friction/modulesrc/faults/TimeHistorySlipFn.i 2009-10-11 04:45:09 UTC (rev 15793)
@@ -0,0 +1,106 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/faults/TimeHistorySlipFn.i
+ *
+ * @brief Python interface to C++ Fault object.
+ */
+
+namespace pylith {
+ namespace faults {
+
+ class TimeHistorySlipFn : public SlipTimeFn
+ { // class TimeHistorySlipFn
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ TimeHistorySlipFn(void);
+
+ /// Destructor.
+ ~TimeHistorySlipFn(void);
+
+ /// Deallocate PETSc and local data structures.
+ virtual
+ void deallocate(void);
+
+ /** Set spatial database for amplitude of slip time history.
+ *
+ * @param db Spatial database
+ */
+ void dbAmplitude(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Set spatial database for slip initiation time.
+ *
+ * @param db Spatial database
+ */
+ void dbSlipTime(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Set time history.
+ *
+ * @param th Time history.
+ */
+ void dbTimeHistory(spatialdata::spatialdb::TimeHistory* const th);
+
+ /** Initialize slip time function.
+ *
+ * @param faultMesh Finite-element mesh of fault.
+ * @param cs Coordinate system for mesh
+ * @param normalizer Nondimensionalization of scales.
+ * @param originTime Origin time for earthquake source.
+ */
+ void initialize(const pylith::topology::SubMesh& faultMesh,
+ const spatialdata::units::Nondimensional& normalizer,
+ const double originTime =0.0);
+
+ /** Get slip on fault surface at time t.
+ *
+ * @param slipField Slip field over fault surface.
+ * @param t Time t.
+ *
+ * @returns Slip vector as left-lateral/reverse/normal.
+ */
+ void slip(pylith::topology::Field<pylith::topology::SubMesh>* const slipField,
+ const double t);
+
+ /** Get slip increment on fault surface between time t0 and t1.
+ *
+ * @param slipField Slip field over fault surface.
+ * @param t0 Time t.
+ * @param t1 Time t+dt.
+ *
+ * @returns Increment in slip vector as left-lateral/reverse/normal.
+ */
+ void slipIncr(pylith::topology::Field<pylith::topology::SubMesh>* slipField,
+ const double t0,
+ const double t1);
+
+ /** Get final slip.
+ *
+ * @returns Final slip.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>& finalSlip(void);
+
+ /** Get time when slip begins at each point.
+ *
+ * @returns Time when slip begins.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>& slipTime(void);
+
+ }; // class TimeHistorySlipFn
+
+ } // faults
+} // pylith
+
+
+// End of file
Modified: short/3D/PyLith/branches/pylith-friction/modulesrc/faults/faults.i
===================================================================
--- short/3D/PyLith/branches/pylith-friction/modulesrc/faults/faults.i 2009-10-09 22:17:00 UTC (rev 15792)
+++ short/3D/PyLith/branches/pylith-friction/modulesrc/faults/faults.i 2009-10-11 04:45:09 UTC (rev 15793)
@@ -20,6 +20,7 @@
#include "pylith/faults/ConstRateSlipFn.hh"
#include "pylith/faults/BruneSlipFn.hh"
#include "pylith/faults/LiuCosSlipFn.hh"
+#include "pylith/faults/TimeHistorySlipFn.hh"
#include "pylith/faults/EqKinSrc.hh"
#include "pylith/faults/Fault.hh"
#include "pylith/faults/FaultCohesive.hh"
@@ -68,6 +69,7 @@
%include "ConstRateSlipFn.i"
%include "BruneSlipFn.i"
%include "LiuCosSlipFn.i"
+%include "TimeHistorySlipFn.i"
%include "EqKinSrc.i"
%include "Fault.i"
%include "FaultCohesive.i"
Modified: short/3D/PyLith/branches/pylith-friction/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-friction/pylith/Makefile.am 2009-10-09 22:17:00 UTC (rev 15792)
+++ short/3D/PyLith/branches/pylith-friction/pylith/Makefile.am 2009-10-11 04:45:09 UTC (rev 15793)
@@ -38,6 +38,7 @@
faults/SingleRupture.py \
faults/SlipTimeFn.py \
faults/StepSlipFn.py \
+ faults/TimeHistorySlipFn.py \
feassemble/__init__.py \
feassemble/Constraint.py \
feassemble/ElasticityExplicit.py \
Modified: short/3D/PyLith/branches/pylith-friction/pylith/faults/LiuCosSlipFn.py
===================================================================
--- short/3D/PyLith/branches/pylith-friction/pylith/faults/LiuCosSlipFn.py 2009-10-09 22:17:00 UTC (rev 15792)
+++ short/3D/PyLith/branches/pylith-friction/pylith/faults/LiuCosSlipFn.py 2009-10-11 04:45:09 UTC (rev 15793)
@@ -10,7 +10,7 @@
# ----------------------------------------------------------------------
#
-## @file pylith/faults/BruneSlipFn.py
+## @file pylith/faults/LiuCosSlipFn.py
##
## @brief Sine/cosine slip time function from Liu, Archuleta, and Hartzell,
## BSSA, 2006 (doi:10.1785/0120060036) which has a rapid rise and then
@@ -62,13 +62,13 @@
# PUBLIC METHODS /////////////////////////////////////////////////////
- def __init__(self, name="bruneslipfn"):
+ def __init__(self, name="liucosslipfn"):
"""
Constructor.
"""
SlipTimeFn.__init__(self, name)
ModuleLiuCosSlipFn.__init__(self)
- self._loggingPrefix = "BrSF "
+ self._loggingPrefix = "LCSF "
return
Added: short/3D/PyLith/branches/pylith-friction/pylith/faults/TimeHistorySlipFn.py
===================================================================
--- short/3D/PyLith/branches/pylith-friction/pylith/faults/TimeHistorySlipFn.py (rev 0)
+++ short/3D/PyLith/branches/pylith-friction/pylith/faults/TimeHistorySlipFn.py 2009-10-11 04:45:09 UTC (rev 15793)
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/faults/TimeHistorySlipFn.py
+##
+## @brief User-defined slip-time function with spatially variable
+## amplitude and start time.
+##
+## Factory: slip_time_fn
+
+from SlipTimeFn import SlipTimeFn
+from faults import TimeHistorySlipFn as ModuleTimeHistorySlipFn
+
+# TimeHistorySlipFn class
+class TimeHistorySlipFn(SlipTimeFn, ModuleTimeHistorySlipFn):
+ """
+ User-defined slip-time function with spatially variable amplitude
+ and start time.
+
+ Inventory
+
+ \b Properties
+ @li None
+
+ \b Facilities
+ @li \b slip Spatial database of slip amplitude.
+ @li \b slip_time Spatial database of slip initiation time.
+ @li \b time_history Temporal database for slip time history function.
+
+ Factory: slip_time_fn
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ import pyre.inventory
+
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+
+ dbSlip = pyre.inventory.facility("slip", family="spatial_database",
+ factory=SimpleDB)
+ dbSlip.meta['tip'] = "Spatial database of slip amplitude."
+
+ dbSlipTime = pyre.inventory.facility("slip_time", family="spatial_database",
+ factory=SimpleDB)
+ dbSlipTime.meta['tip'] = "Spatial database of slip initiation time."
+
+ from spatialdata.spatialdb.TimeHistory import TimeHistory
+ dbTimeHistory = pyre.inventory.facility("time_history",
+ family="temporal_database",
+ factory=TimeHistory)
+ dbTimeHistory.meta['tip'] = "Spatial database of rise time (t95)."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="timehistoryslipfn"):
+ """
+ Constructor.
+ """
+ SlipTimeFn.__init__(self, name)
+ ModuleTimeHistorySlipFn.__init__(self)
+ self._loggingPrefix = "THSF "
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ SlipTimeFn._configure(self)
+ ModuleTimeHistorySlipFn.dbAmplitude(self, self.inventory.dbSlip)
+ ModuleTimeHistorySlipFn.dbSlipTime(self, self.inventory.dbSlipTime)
+ ModuleTimeHistorySlipFn.dbTimeHistory(self, self.inventory.dbTimeHistory)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def slip_time_fn():
+ """
+ Factory associated with TimeHistorySlipFn.
+ """
+ return TimeHistorySlipFn()
+
+
+# End of file
More information about the CIG-COMMITS
mailing list