[cig-commits] r12199 - in short/3D/PyLith/trunk: examples/3d/hex8 examples/3d/tet4 examples/bar_shearwave/hex8 examples/bar_shearwave/quad4 examples/bar_shearwave/tet4 examples/bar_shearwave/tri3 examples/twocells/twohex8 examples/twocells/twoquad4 examples/twocells/twotet4 examples/twocells/twotet4-geoproj examples/twocells/twotri3 libsrc libsrc/faults modulesrc/faults pylith pylith/faults unittests/libtests/faults unittests/pytests/faults
brad at geodynamics.org
brad at geodynamics.org
Fri Jun 13 15:50:07 PDT 2008
Author: brad
Date: 2008-06-13 15:50:07 -0700 (Fri, 13 Jun 2008)
New Revision: 12199
Added:
short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.cc
short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.hh
short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.icc
short/3D/PyLith/trunk/pylith/faults/StepSlipFn.py
short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.hh
short/3D/PyLith/trunk/unittests/pytests/faults/TestStepSlipFn.py
Removed:
short/3D/PyLith/trunk/examples/3d/hex8/sliprate.spatialdb
short/3D/PyLith/trunk/examples/3d/tet4/sliprate.spatialdb
short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation_sliprate.spatialdb
short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation_sliprate.spatialdb
short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation_sliprate.spatialdb
short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation_sliprate.spatialdb
short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation_sliprate.spatialdb
Modified:
short/3D/PyLith/trunk/examples/3d/hex8/dislocation.cfg
short/3D/PyLith/trunk/examples/3d/hex8/savageprescott.cfg
short/3D/PyLith/trunk/examples/3d/hex8/sliprate_creep.spatialdb
short/3D/PyLith/trunk/examples/3d/tet4/dislocation.cfg
short/3D/PyLith/trunk/examples/3d/tet4/sliptime.spatialdb
short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave.cfg
short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave.cfg
short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave.cfg
short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave.cfg
short/3D/PyLith/trunk/examples/twocells/twohex8/README
short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation.cfg
short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation_sliptime.spatialdb
short/3D/PyLith/trunk/examples/twocells/twoquad4/README
short/3D/PyLith/trunk/examples/twocells/twoquad4/axialtract.cfg
short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation.cfg
short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation_sliptime.spatialdb
short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/README
short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation.cfg
short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation_sliptime.spatialdb
short/3D/PyLith/trunk/examples/twocells/twotet4/README
short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation.cfg
short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation_sliptime.spatialdb
short/3D/PyLith/trunk/examples/twocells/twotri3/README
short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation.cfg
short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation_sliptime.spatialdb
short/3D/PyLith/trunk/libsrc/Makefile.am
short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.cc
short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc
short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.hh
short/3D/PyLith/trunk/libsrc/faults/Makefile.am
short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src
short/3D/PyLith/trunk/pylith/Makefile.am
short/3D/PyLith/trunk/pylith/faults/ConstRateSlipFn.py
short/3D/PyLith/trunk/pylith/faults/EqKinSrc.py
short/3D/PyLith/trunk/pylith/faults/__init__.py
short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.cc
short/3D/PyLith/trunk/unittests/pytests/faults/Makefile.am
short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py
Log:
Added step-function slip time function (with appropriate tests). Switched default slip time function to step-function (updated examples accordingly).
Modified: short/3D/PyLith/trunk/examples/3d/hex8/dislocation.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/3d/hex8/dislocation.cfg 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/3d/hex8/dislocation.cfg 2008-06-13 22:50:07 UTC (rev 12199)
@@ -73,11 +73,9 @@
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 2
mat_db.iohandler.filename = mat_elastic.spatialdb
-eq_srcs.rupture.origin_time = -1.0*s
[pylithapp.timedependent.interfaces.fault.eq_srcs.rupture.slip_function]
slip.iohandler.filename = finalslip.spatialdb
-slip_rate.iohandler.filename = sliprate.spatialdb
slip_time.iohandler.filename = sliptime.spatialdb
Modified: short/3D/PyLith/trunk/examples/3d/hex8/savageprescott.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/3d/hex8/savageprescott.cfg 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/3d/hex8/savageprescott.cfg 2008-06-13 22:50:07 UTC (rev 12199)
@@ -92,13 +92,11 @@
# one
[pylithapp.timedependent.interfaces.fault.eq_srcs.one.slip_function]
slip.iohandler.filename = finalslip_rupture.spatialdb
-slip_rate.iohandler.filename = sliprate.spatialdb
slip_time.iohandler.filename = sliptime.spatialdb
# two
[pylithapp.timedependent.interfaces.fault.eq_srcs.two.slip_function]
slip.iohandler.filename = finalslip_rupture.spatialdb
-slip_rate.iohandler.filename = sliprate.spatialdb
slip_time.iohandler.filename = sliptime.spatialdb
# creep
Deleted: short/3D/PyLith/trunk/examples/3d/hex8/sliprate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/3d/hex8/sliprate.spatialdb 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/3d/hex8/sliprate.spatialdb 2008-06-13 22:50:07 UTC (rev 12199)
@@ -1,25 +0,0 @@
-// -*- C++ -*- (tell Emacs to use C++ mode for syntax highlighting)
-//
-// This spatial database specifies the distribution of the peak slip
-// rate for the kinematic fault rupture. We set the peak slip rate to
-// a large value for instantaneous slip.
-//
-#SPATIAL.ascii 1
-SimpleDB {
- num-values = 1
- value-names = slip-rate
- value-units = m/s
- num-locs = 1
- data-dim = 0 // data is uniform (1 location)
- space-dim = 3
- cs-data = cartesian {
- to-meters = 1.0
- space-dim = 3
- }
-}
-// Columns are
-// (1) x coordinate (m)
-// (2) y coordinate (m)
-// (3) z coordinate (m)
-// (4) Peak slip rate (m/s)
-0.0 0.0 0.0 1.0e+6
Modified: short/3D/PyLith/trunk/examples/3d/hex8/sliprate_creep.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/3d/hex8/sliprate_creep.spatialdb 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/3d/hex8/sliprate_creep.spatialdb 2008-06-13 22:50:07 UTC (rev 12199)
@@ -2,7 +2,7 @@
//
// This spatial database specifies the distribution of slip rate on
// the fault surface for a constant slip rate time function. In this
-// case we specify a uniform slip rate of -0.10 m/s for z < -2.0 m and
+// case we specify a uniform slip rate of -0.20 m/s for z < -2.0 m and
// zero slip for z >= -2.0 m. There is no reverse-slip or fault
// opening.
//
@@ -28,5 +28,5 @@
// (6) fault-opening rate (m/s)
0.0 0.0 0.00 0.00 0.0 0.0
0.0 0.0 -2.00 0.00 0.0 0.0
-0.0 0.0 -2.01 -0.10 0.0 0.0
-0.0 0.0 -4.00 -0.10 0.0 0.0
+0.0 0.0 -2.01 -0.20 0.0 0.0
+0.0 0.0 -4.00 -0.20 0.0 0.0
Modified: short/3D/PyLith/trunk/examples/3d/tet4/dislocation.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/3d/tet4/dislocation.cfg 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/3d/tet4/dislocation.cfg 2008-06-13 22:50:07 UTC (rev 12199)
@@ -73,7 +73,6 @@
[pylithapp.timedependent.interfaces.fault.eq_srcs.rupture.slip_function]
slip.iohandler.filename = finalslip.spatialdb
-slip_rate.iohandler.filename = sliprate.spatialdb
slip_time.iohandler.filename = sliptime.spatialdb
Deleted: short/3D/PyLith/trunk/examples/3d/tet4/sliprate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/3d/tet4/sliprate.spatialdb 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/3d/tet4/sliprate.spatialdb 2008-06-13 22:50:07 UTC (rev 12199)
@@ -1,25 +0,0 @@
-// -*- C++ -*- (tell Emacs to use C++ mode for syntax highlighting)
-//
-// This spatial database specifies the distribution of the peak slip
-// rate for the kinematic fault rupture. We set the peak slip rate to
-// a large value for instantaneous slip.
-//
-#SPATIAL.ascii 1
-SimpleDB {
- num-values = 1
- value-names = slip-rate
- value-units = m/s
- num-locs = 1
- data-dim = 0 // data is uniform (1 location)
- space-dim = 3
- cs-data = cartesian {
- to-meters = 1.0
- space-dim = 3
- }
-}
-// Columns are
-// (1) x coordinate (m)
-// (2) y coordinate (m)
-// (3) z coordinate (m)
-// (4) Peak slip rate (m/s)
-0.0 0.0 0.0 1.0e+6
Modified: short/3D/PyLith/trunk/examples/3d/tet4/sliptime.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/3d/tet4/sliptime.spatialdb 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/3d/tet4/sliptime.spatialdb 2008-06-13 22:50:07 UTC (rev 12199)
@@ -3,8 +3,8 @@
// This spatial database specifies the distribution of the slip
// initiation time over the fault surface for the kinematic fault
// rupture. Because this is a quasi-static simulation, we specify that
-// the slip initiates at t=-1.0 s (before the simulation starts) so
-// that we have slip at the first time step.
+// the slip initiates at t=0.0 s so that we have slip at the first
+// time step.
//
#SPATIAL.ascii 1
SimpleDB {
@@ -24,4 +24,4 @@
// (2) y coordinate (m)
// (3) z coordinate (m)
// (4) Slip initiation time (s)
-0.0 0.0 0.0 -1.0
+0.0 0.0 0.0 0.0
Modified: short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave.cfg 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave.cfg 2008-06-13 22:50:07 UTC (rev 12199)
@@ -163,6 +163,9 @@
# system of equations.
mat_db.iohandler.filename = matprops.spatialdb
+# Switch to Brune slip time function
+eq_srcs.rupture.slip_function = pylith.faults.BruneSlipFn
+
[pylithapp.timedependent.interfaces.fault.eq_srcs.rupture.slip_function]
# Database specifying the final slip.
Modified: short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave.cfg 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave.cfg 2008-06-13 22:50:07 UTC (rev 12199)
@@ -167,6 +167,9 @@
# system of equations.
mat_db.iohandler.filename = matprops.spatialdb
+# Switch to Brune slip time function
+eq_srcs.rupture.slip_function = pylith.faults.BruneSlipFn
+
[pylithapp.timedependent.interfaces.fault.eq_srcs.rupture.slip_function]
# Database specifying the final slip.
Modified: short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave.cfg 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave.cfg 2008-06-13 22:50:07 UTC (rev 12199)
@@ -181,6 +181,9 @@
# system of equations.
mat_db.iohandler.filename = matprops.spatialdb
+# Switch to Brune slip time function
+eq_srcs.rupture.slip_function = pylith.faults.BruneSlipFn
+
[pylithapp.timedependent.interfaces.fault.eq_srcs.rupture.slip_function]
# Database specifying the final slip.
Modified: short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave.cfg 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave.cfg 2008-06-13 22:50:07 UTC (rev 12199)
@@ -167,6 +167,9 @@
# system of equations.
mat_db.iohandler.filename = matprops.spatialdb
+# Switch to Brune slip time function
+eq_srcs.rupture.slip_function = pylith.faults.BruneSlipFn
+
[pylithapp.timedependent.interfaces.fault.eq_srcs.rupture.slip_function]
# Database specifying the final slip.
Modified: short/3D/PyLith/trunk/examples/twocells/twohex8/README
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twohex8/README 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twohex8/README 2008-06-13 22:50:07 UTC (rev 12199)
@@ -33,8 +33,6 @@
elements, while the left and right corners are fixed in x, y, and z.
a. dislocation.cfg: Parameter settings for this problem.
b. dislocation_slip.spatialdb: Fault slip database for this problem.
- c. dislocation_sliprate.spatialdb: Fault slip rate database for this
- problem.
d. dislocation_sliptime.spatialdb: Fault slip time database for this
problem.
Modified: short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation.cfg 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation.cfg 2008-06-13 22:50:07 UTC (rev 12199)
@@ -108,10 +108,7 @@
# Database specifying fault slip (0.01 m of left-lateral slip).
slip.iohandler.filename = dislocation_slip.spatialdb
-# Database specifying fault slip rate (1.0e+6 m/s).
-slip_rate.iohandler.filename = dislocation_sliprate.spatialdb
-
-# Database specifying time at which fault slips (-1.0 s).
+# Database specifying time at which fault slips (0.0 s).
slip_time.iohandler.filename = dislocation_sliptime.spatialdb
# ----------------------------------------------------------------------
Deleted: short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation_sliprate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation_sliprate.spatialdb 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation_sliprate.spatialdb 2008-06-13 22:50:07 UTC (rev 12199)
@@ -1,41 +0,0 @@
-#SPATIAL.ascii 1
-
-// This database is used to specify the fault slip rate for the
-// dislocation (kinematic fault) example.
-SimpleDB {
-
- // There is one value specified in the database, corresponding to the
- // slip rate.
- num-values = 1
- value-names = slip-rate
-
- // The fault slip rate has units of meters/second.
- value-units = m/s
-
- // The value is specified at one spatial location.
- num-locs = 1
-
- // The dimension of the spatial distribution is 0, since the same data
- // is specified for all points in the set.
- data-dim = 0
-
- // The spatial dimension of the database is 3.
- space-dim = 3
-
- // We are specifying the data in a Cartesian coordinate system.
- cs-data = cartesian {
-
- // Our units are already in meters, so we can just multiply by one.
- to-meters = 1.0
-
- // We are using a 3D Cartesian coordinate system.
- space-dim = 3
- }
-}
-
-// This is where the data is specified.
-// As described in dislocation.cfg, this database will be used to specify
-// uniform data for a fault (pylith.faults.SingleFault).
-// The entries are:
-// X-Coord, Y-Coord, Z-Coord, slip rate
-0.0 0.0 0.0 1.0e+6
Modified: short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation_sliptime.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation_sliptime.spatialdb 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation_sliptime.spatialdb 2008-06-13 22:50:07 UTC (rev 12199)
@@ -38,4 +38,4 @@
// uniform data for a fault (pylith.faults.SingleFault).
// The entries are:
// X-Coord, Y-Coord, Z-Coord, slip time
-0.0 0.0 0.0 -1.0
+0.0 0.0 0.0 0.0
Modified: short/3D/PyLith/trunk/examples/twocells/twoquad4/README
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twoquad4/README 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twoquad4/README 2008-06-13 22:50:07 UTC (rev 12199)
@@ -37,7 +37,6 @@
- dislocation.cfg: Parameter settings.
- dislocation_slip.spatialdb: Database of fault slip values.
- - dislocation_sliprate.spatialdb: Database of peak slip rate values.
- dislocation_sliptime.spatialdb: Database of slip initiation time values.
* axialtract
@@ -51,7 +50,6 @@
- axialtract.cfg: Parameter settings.
- axialtract.spatialdb: Database of Neumann BC values.
- dislocation_slip_zero.spatialdb: Database of fault slip values.
- - dislocation_sliprate.spatialdb: Database of peak slip rate values.
- dislocation_sliptime.spatialdb: Database of slip initiation time values.
All of the files are documented. The 'pylithapp.cfg' file is read
Modified: short/3D/PyLith/trunk/examples/twocells/twoquad4/axialtract.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twoquad4/axialtract.cfg 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twoquad4/axialtract.cfg 2008-06-13 22:50:07 UTC (rev 12199)
@@ -153,15 +153,12 @@
quadrature.cell.dimension = 1
# Give the spatial databases specifying the fault slip.
-[pylithapp.timedependent.interfaces.fault.eq_src.slip_function]
+[pylithapp.timedependent.interfaces.fault.eq_srcs.rupture.slip_function]
# Database specifying zero fault slip.
slip.iohandler.filename = dislocation_slip_zero.spatialdb
-# Database specifying fault slip rate (1.0e+6 m/s).
-slip_rate.iohandler.filename = dislocation_sliprate.spatialdb
-
-# Database specifying time at which fault slips (-1.0 s).
+# Database specifying time at which fault slips (0.0 s).
slip_time.iohandler.filename = dislocation_sliptime.spatialdb
# ----------------------------------------------------------------------
Modified: short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation.cfg 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation.cfg 2008-06-13 22:50:07 UTC (rev 12199)
@@ -109,10 +109,7 @@
# Database specifying fault slip (0.01 m of left-lateral slip).
slip.iohandler.filename = dislocation_slip.spatialdb
-# Database specifying fault slip rate (1.0e+6 m/s).
-slip_rate.iohandler.filename = dislocation_sliprate.spatialdb
-
-# Database specifying time at which fault slips (-1.0 s).
+# Database specifying time at which fault slips (0.0 s).
slip_time.iohandler.filename = dislocation_sliptime.spatialdb
# ----------------------------------------------------------------------
Deleted: short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation_sliprate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation_sliprate.spatialdb 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation_sliprate.spatialdb 2008-06-13 22:50:07 UTC (rev 12199)
@@ -1,41 +0,0 @@
-#SPATIAL.ascii 1
-
-// This database is used to specify the fault slip rate for the
-// dislocation (kinematic fault) example.
-SimpleDB {
-
- // There is one value specified in the database, corresponding to the
- // slip rate.
- num-values = 1
- value-names = slip-rate
-
- // The fault slip rate has units of meters/second.
- value-units = m/s
-
- // The value is specified at one spatial location.
- num-locs = 1
-
- // The dimension of the spatial distribution is 0, since the same data
- // is specified for all points in the set.
- data-dim = 0
-
- // The spatial dimension of the database is 2.
- space-dim = 2
-
- // We are specifying the data in a Cartesian coordinate system.
- cs-data = cartesian {
-
- // Our units are already in meters, so we can just multiply by one.
- to-meters = 1.0
-
- // We are using a 2D Cartesian coordinate system.
- space-dim = 2
- }
-}
-
-// This is where the data is specified.
-// As described in dislocation.cfg, this database will be used to specify
-// uniform data for a fault (pylith.faults.SingleFault).
-// The entries are:
-// X-Coord, Y-Coord, slip rate
-0.0 0.0 1.0e+6
Modified: short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation_sliptime.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation_sliptime.spatialdb 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation_sliptime.spatialdb 2008-06-13 22:50:07 UTC (rev 12199)
@@ -38,4 +38,4 @@
// uniform data for a fault (pylith.faults.SingleFault).
// The entries are:
// X-Coord, Y-Coord, slip time
-0.0 0.0 -1.0
+0.0 0.0 0.0
Modified: short/3D/PyLith/trunk/examples/twocells/twotet4/README
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotet4/README 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twotet4/README 2008-06-13 22:50:07 UTC (rev 12199)
@@ -26,8 +26,6 @@
elements, while the left and right corners are fixed in x, y, and z.
a. dislocation.cfg: Parameter settings for this problem.
b. dislocation_slip.spatialdb: Fault slip database for this problem.
- c. dislocation_sliprate.spatialdb: Fault slip rate database for this
- problem.
d. dislocation_sliptime.spatialdb: Fault slip time database for this
problem.
Modified: short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation.cfg 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation.cfg 2008-06-13 22:50:07 UTC (rev 12199)
@@ -92,10 +92,7 @@
# Database specifying fault slip (0.01 m of left-lateral slip).
slip.iohandler.filename = dislocation_slip.spatialdb
-# Database specifying fault slip rate (1.0e+6 m/s).
-slip_rate.iohandler.filename = dislocation_sliprate.spatialdb
-
-# Database specifying time at which fault slips (-1.0 s).
+# Database specifying time at which fault slips (0.0 s).
slip_time.iohandler.filename = dislocation_sliptime.spatialdb
# ----------------------------------------------------------------------
Deleted: short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation_sliprate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation_sliprate.spatialdb 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation_sliprate.spatialdb 2008-06-13 22:50:07 UTC (rev 12199)
@@ -1,41 +0,0 @@
-#SPATIAL.ascii 1
-
-// This database is used to specify the fault slip rate for the
-// dislocation (kinematic fault) example.
-SimpleDB {
-
- // There is one value specified in the database, corresponding to the
- // slip rate.
- num-values = 1
- value-names = slip-rate
-
- // The fault slip rate has units of meters/second.
- value-units = m/s
-
- // The value is specified at one spatial location.
- num-locs = 1
-
- // The dimension of the spatial distribution is 0, since the same data
- // is specified for all points in the set.
- data-dim = 0
-
- // The spatial dimension of the database is 3.
- space-dim = 3
-
- // We are specifying the data in a Cartesian coordinate system.
- cs-data = cartesian {
-
- // Our units are already in meters, so we can just multiply by one.
- to-meters = 1.0
-
- // We are using a 3D Cartesian coordinate system.
- space-dim = 3
- }
-}
-
-// This is where the data is specified.
-// As described in dislocation.cfg, this database will be used to specify
-// uniform data for a fault (pylith.faults.SingleFault).
-// The entries are:
-// X-Coord, Y-Coord, Z-Coord, slip rate
-0.0 0.0 0.0 1.0e+6
Modified: short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation_sliptime.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation_sliptime.spatialdb 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation_sliptime.spatialdb 2008-06-13 22:50:07 UTC (rev 12199)
@@ -38,4 +38,4 @@
// uniform data for a fault (pylith.faults.SingleFault).
// The entries are:
// X-Coord, Y-Coord, Z-Coord, slip time
-0.0 0.0 0.0 -1.0
+0.0 0.0 0.0 0.0
Modified: short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/README
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/README 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/README 2008-06-13 22:50:07 UTC (rev 12199)
@@ -22,8 +22,6 @@
elements, while the left and right corners are fixed in x, y, and z.
a. dislocation.cfg: Parameter settings for this problem.
b. dislocation_slip.spatialdb: Fault slip database for this problem.
- c. dislocation_sliprate.spatialdb: Fault slip rate database for this
- problem.
d. dislocation_sliptime.spatialdb: Fault slip time database for this
problem.
Modified: short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation.cfg 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation.cfg 2008-06-13 22:50:07 UTC (rev 12199)
@@ -100,10 +100,7 @@
# Database specifying fault slip (0.01 m of left-lateral slip).
slip.iohandler.filename = dislocation_slip.spatialdb
-# Database specifying fault slip rate (1.0e+6 m/s).
-slip_rate.iohandler.filename = dislocation_sliprate.spatialdb
-
-# Database specifying time at which fault slips (-1.0 s).
+# Database specifying time at which fault slips (0.0 s).
slip_time.iohandler.filename = dislocation_sliptime.spatialdb
# ----------------------------------------------------------------------
Deleted: short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation_sliprate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation_sliprate.spatialdb 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation_sliprate.spatialdb 2008-06-13 22:50:07 UTC (rev 12199)
@@ -1,44 +0,0 @@
-#SPATIAL.ascii 1
-
-// This database is used to specify the fault slip rate for the
-// dislocation (kinematic fault) example.
-SimpleDB {
-
- // There is one value specified in the database, corresponding to the
- // slip rate.
- num-values = 1
- value-names = slip-rate
-
- // The fault slip rate has units of meters/second.
- value-units = m/s
-
- // The value is specified at one spatial location.
- num-locs = 1
-
- // The dimension of the spatial distribution is 0, since the same data
- // is specified for all points in the set.
- data-dim = 0
-
- // The spatial dimension of the database is 3.
- space-dim = 3
-
- // We are specifying the data in a projected geographic coordinate system.
- cs-data = geo-projected {
- to-meters = 1.0
- ellipsoid = clrk66
- datum-horiz = NAD27
- datum-vert = mean sea level
- projector = projection {
- projection = utm
- units = m
- proj-options = +zone=11
- }
- }
-}
-
-// This is where the data is specified.
-// As described in dislocation.cfg, this database will be used to specify
-// uniform data for a fault.
-// The entries are:
-// X-Coord, Y-Coord, Z-Coord, slip rate
-500000.0 3.7e6 0.0 1.0e+6
Modified: short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation_sliptime.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation_sliptime.spatialdb 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation_sliptime.spatialdb 2008-06-13 22:50:07 UTC (rev 12199)
@@ -41,4 +41,4 @@
// uniform data for a fault.
// The entries are:
// X-Coord, Y-Coord, Z-Coord, slip time
-500000.0 3.7e6 0.0 -1.0
+500000.0 3.7e6 0.0 0.0
Modified: short/3D/PyLith/trunk/examples/twocells/twotri3/README
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotri3/README 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twotri3/README 2008-06-13 22:50:07 UTC (rev 12199)
@@ -40,7 +40,6 @@
- dislocation.cfg: Parameter settings.
- dislocation_slip.spatialdb: Database with fault slip values.
- - dislocation_sliprate.spatialdb: Database with peak slip rate values.
- dislocation_sliptime.spatialdb: Database with slip initiation time
values.
Modified: short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation.cfg 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation.cfg 2008-06-13 22:50:07 UTC (rev 12199)
@@ -93,10 +93,7 @@
# Database specifying fault slip (0.01 m of left-lateral slip).
slip.iohandler.filename = dislocation_slip.spatialdb
-# Database specifying fault slip rate (1.0e+6 m/s).
-slip_rate.iohandler.filename = dislocation_sliprate.spatialdb
-
-# Database specifying time at which fault slips (-1.0 s).
+# Database specifying time at which fault slips (0.0 s).
slip_time.iohandler.filename = dislocation_sliptime.spatialdb
# ----------------------------------------------------------------------
Deleted: short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation_sliprate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation_sliprate.spatialdb 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation_sliprate.spatialdb 2008-06-13 22:50:07 UTC (rev 12199)
@@ -1,41 +0,0 @@
-#SPATIAL.ascii 1
-
-// This database is used to specify the fault slip rate for the
-// dislocation (kinematic fault) example.
-SimpleDB {
-
- // There is one value specified in the database, corresponding to the
- // slip rate.
- num-values = 1
- value-names = slip-rate
-
- // The fault slip rate has units of meters/second.
- value-units = m/s
-
- // The value is specified at one spatial location.
- num-locs = 1
-
- // The dimension of the spatial distribution is 0, since the same data
- // is specified for all points in the set.
- data-dim = 0
-
- // The spatial dimension of the database is 2.
- space-dim = 2
-
- // We are specifying the data in a Cartesian coordinate system.
- cs-data = cartesian {
-
- // Our units are already in meters, so we can just multiply by one.
- to-meters = 1.0
-
- // We are using a 2D Cartesian coordinate system.
- space-dim = 2
- }
-}
-
-// This is where the data is specified.
-// As described in dislocation.cfg, this database will be used to specify
-// uniform data for a fault (pylith.faults.SingleFault).
-// The entries are:
-// X-Coord, Y-Coord, slip rate
-0.0 0.0 1.0e+6
Modified: short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation_sliptime.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation_sliptime.spatialdb 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation_sliptime.spatialdb 2008-06-13 22:50:07 UTC (rev 12199)
@@ -38,4 +38,4 @@
// uniform data for a fault (pylith.faults.SingleFault).
// The entries are:
// X-Coord, Y-Coord, slip time
-0.0 0.0 -1.0
+0.0 0.0 0.0
Modified: short/3D/PyLith/trunk/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/Makefile.am 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/libsrc/Makefile.am 2008-06-13 22:50:07 UTC (rev 12199)
@@ -36,6 +36,7 @@
faults/FaultCohesiveKin.cc \
faults/FaultCohesiveDyn.cc \
faults/SlipTimeFn.cc \
+ faults/StepSlipFn.cc \
feassemble/CellGeometry.cc \
feassemble/Constraint.cc \
feassemble/ElasticityExplicit.cc \
Modified: short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.cc 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.cc 2008-06-13 22:50:07 UTC (rev 12199)
@@ -254,11 +254,11 @@
// Get vertices in fault mesh
const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ const int numVertices = vertices->size();
- int count = 0;
for (Mesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
- ++v_iter, ++count) {
+ ++v_iter) {
const real_section_type::value_type* paramsVertex =
_parameters->restrictPoint(*v_iter);
assert(0 != paramsVertex);
@@ -283,7 +283,7 @@
slipField->updateAddPoint(*v_iter, &slipValues[0]);
} // for
- PetscLogFlops(count * (3+2*8 + 3*spaceDim));
+ PetscLogFlops(numVertices * (3+2*8 + 3*spaceDim));
} // slipIncr
// ----------------------------------------------------------------------
Modified: short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc 2008-06-13 22:50:07 UTC (rev 12199)
@@ -78,7 +78,7 @@
assert(2 == _parameters->getNumSpaces());
_parameters->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(), vertices->end()), *std::max_element(vertices->begin(), vertices->end())+1));
_parameters->setFiberDimension(vertices, fiberDim);
- _parameters->setFiberDimension(vertices, spaceDim, 0); // final slip
+ _parameters->setFiberDimension(vertices, spaceDim, 0); // slip rate
_parameters->setFiberDimension(vertices, 1, 1); // slip time
faultMesh->allocate(_parameters);
assert(!_parameters.isNull());
@@ -131,7 +131,7 @@
coordsVertex, spaceDim, cs);
if (err) {
std::ostringstream msg;
- msg << "Could not slip rate at (";
+ msg << "Could not find slip rate at (";
for (int i=0; i < spaceDim; ++i)
msg << " " << coordsVertex[i];
msg << ") using spatial database " << _dbSlipRate->label() << ".";
@@ -190,6 +190,7 @@
const double* slipRate = ¶msVertex[indexSlipRate];
const double slipTime = paramsVertex[indexSlipTime];
+ slipValues = 0.0;
const double relTime = t - slipTime;
if (relTime > 0)
@@ -224,17 +225,18 @@
// Get vertices in fault mesh
const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ const int numVertices = vertices->size();
- int count = 0;
for (Mesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
- ++v_iter, ++count) {
+ ++v_iter) {
const real_section_type::value_type* paramsVertex =
_parameters->restrictPoint(*v_iter);
assert(0 != paramsVertex);
const double* slipRate = ¶msVertex[indexSlipRate];
const double slipTime = paramsVertex[indexSlipTime];
+ slipValues = 0.0;
const double relTime0 = t0 - slipTime;
const double relTime1 = t1 - slipTime;
@@ -250,11 +252,11 @@
slipField->updateAddPoint(*v_iter, &slipValues[0]);
} // for
- PetscLogFlops(count * (2 + spaceDim));
+ PetscLogFlops(numVertices * (2 + spaceDim));
} // slipIncr
// ----------------------------------------------------------------------
-// Get final slip (slip rate).
+// Get final slip (slip rate in this case).
ALE::Obj<pylith::real_section_type>
pylith::faults::ConstRateSlipFn::finalSlip(void)
{ // finalSlip
Modified: short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.hh 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.hh 2008-06-13 22:50:07 UTC (rev 12199)
@@ -128,13 +128,13 @@
private :
/// Parameters for ConstRate slip time function.
- /// Final slip (vector), peak slip rate (scalar), slip time (scalar).
+ /// Slip rate (vector), slip time (scalar).
ALE::Obj<real_section_type> _parameters;
- /// Spatial database for final slip
+ /// Spatial database for slip rate.
spatialdata::spatialdb::SpatialDB* _dbSlipRate;
- /// Spatial database for slip time
+ /// Spatial database for slip time.
spatialdata::spatialdb::SpatialDB* _dbSlipTime;
int _spaceDim; ///< Spatial dimension for slip field.
Modified: short/3D/PyLith/trunk/libsrc/faults/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/Makefile.am 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/libsrc/faults/Makefile.am 2008-06-13 22:50:07 UTC (rev 12199)
@@ -27,7 +27,9 @@
FaultCohesiveDyn.icc \
FaultCohesiveKin.hh \
FaultCohesiveKin.icc \
- SlipTimeFn.hh
+ SlipTimeFn.hh \
+ StepSlipFn.hh \
+ StepSlipFn.icc
noinst_HEADERS =
Added: short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.cc 2008-06-13 22:50:07 UTC (rev 12199)
@@ -0,0 +1,271 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "StepSlipFn.hh" // implementation of object methods
+
+#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
+#include "pylith/utils/array.hh" // USES double_array
+
+#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
+#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
+
+#include <assert.h> // USES assert()
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
+
+namespace pylith {
+ namespace faults {
+ namespace _StepSlipFn {
+ const int offsetSlipTime = 0;
+ } // _StepSlipFn
+ } // faults
+} // pylith
+
+// ----------------------------------------------------------------------
+// Default constructor.
+pylith::faults::StepSlipFn::StepSlipFn(void) :
+ _dbFinalSlip(0),
+ _dbSlipTime(0),
+ _spaceDim(0)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor.
+pylith::faults::StepSlipFn::~StepSlipFn(void)
+{ // destructor
+ _dbFinalSlip = 0;
+ _dbSlipTime = 0;
+} // destructor
+
+// ----------------------------------------------------------------------
+// Initialize slip time function.
+void
+pylith::faults::StepSlipFn::initialize(
+ const ALE::Obj<Mesh>& faultMesh,
+ const spatialdata::geocoords::CoordSys* cs,
+ const double originTime)
+{ // initialize
+ assert(!faultMesh.isNull());
+ assert(0 != cs);
+ assert(0 != _dbFinalSlip);
+ assert(0 != _dbSlipTime);
+
+ _spaceDim = cs->spaceDim();
+ const int spaceDim = _spaceDim;
+ const int indexFinalSlip = 0;
+ const int indexSlipTime = spaceDim + _StepSlipFn::offsetSlipTime;
+
+ // Get vertices in fault mesh
+ const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
+ const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+
+ const int fiberDim = spaceDim + 1;
+ _parameters = new real_section_type(faultMesh->comm(), faultMesh->debug());
+ _parameters->addSpace(); // final slip
+ _parameters->addSpace(); // slip time
+ assert(2 == _parameters->getNumSpaces());
+ _parameters->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(), vertices->end()), *std::max_element(vertices->begin(), vertices->end())+1));
+ _parameters->setFiberDimension(vertices, fiberDim);
+ _parameters->setFiberDimension(vertices, spaceDim, 0); // final slip
+ _parameters->setFiberDimension(vertices, 1, 1); // slip time
+ faultMesh->allocate(_parameters);
+ assert(!_parameters.isNull());
+
+ // Open databases and set query values
+ _dbFinalSlip->open();
+ switch (spaceDim)
+ { // switch
+ case 1 : {
+ const char* slipValues[] = {"fault-opening"};
+ _dbFinalSlip->queryVals(slipValues, 1);
+ break;
+ } // case 1
+ case 2 : {
+ const char* slipValues[] = {"left-lateral-slip", "fault-opening"};
+ _dbFinalSlip->queryVals(slipValues, 2);
+ break;
+ } // case 2
+ case 3 : {
+ const char* slipValues[] = {"left-lateral-slip", "reverse-slip",
+ "fault-opening"};
+ _dbFinalSlip->queryVals(slipValues, 3);
+ break;
+ } // case 3
+ default :
+ assert(0);
+ } // switch
+
+ _dbSlipTime->open();
+ const char* slipTimeValues[] = {"slip-time"};
+ _dbSlipTime->queryVals(slipTimeValues, 1);
+
+ // Get coordinates of vertices
+ const ALE::Obj<real_section_type>& coordinates =
+ faultMesh->getRealSection("coordinates");
+ assert(!coordinates.isNull());
+
+ double_array paramsVertex(fiberDim);
+
+ for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != verticesEnd;
+ ++v_iter) {
+
+ // Get coordinates of vertex
+ const real_section_type::value_type* coordsVertex =
+ coordinates->restrictPoint(*v_iter);
+ assert(0 != coordsVertex);
+
+ int err = _dbFinalSlip->query(¶msVertex[indexFinalSlip], spaceDim,
+ coordsVertex, spaceDim, cs);
+ if (err) {
+ std::ostringstream msg;
+ msg << "Could not find final slip at (";
+ for (int i=0; i < spaceDim; ++i)
+ msg << " " << coordsVertex[i];
+ msg << ") using spatial database " << _dbFinalSlip->label() << ".";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ err = _dbSlipTime->query(¶msVertex[indexSlipTime], 1,
+ coordsVertex, spaceDim, cs);
+ if (err) {
+ std::ostringstream msg;
+ msg << "Could not find slip initiation time at (";
+ for (int i=0; i < spaceDim; ++i)
+ msg << " " << coordsVertex[i];
+ msg << ") using spatial database " << _dbSlipTime->label() << ".";
+ throw std::runtime_error(msg.str());
+ } // if
+ // add origin time to rupture time
+ paramsVertex[indexSlipTime] += originTime;
+
+ _parameters->updatePoint(*v_iter, ¶msVertex[0]);
+ } // for
+
+ // Close databases
+ _dbFinalSlip->close();
+ _dbSlipTime->close();
+} // initialize
+
+// ----------------------------------------------------------------------
+// Get slip on fault surface at time t.
+void
+pylith::faults::StepSlipFn::slip(const ALE::Obj<pylith::real_section_type>& slipField,
+ const double t,
+ const ALE::Obj<Mesh>& faultMesh)
+{ // slip
+ assert(!_parameters.isNull());
+ assert(!slipField.isNull());
+ assert(!faultMesh.isNull());
+
+ const int spaceDim = _spaceDim;
+ const int indexFinalSlip = 0;
+ const int indexSlipTime = spaceDim + _StepSlipFn::offsetSlipTime;
+
+ double_array slipValues(spaceDim);
+
+ // Get vertices in fault mesh
+ const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
+ const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ const int numVertices = vertices->size();
+
+ for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != verticesEnd;
+ ++v_iter) {
+ const real_section_type::value_type* paramsVertex =
+ _parameters->restrictPoint(*v_iter);
+ assert(0 != paramsVertex);
+
+ const double* finalSlip = ¶msVertex[indexFinalSlip];
+ const double slipTime = paramsVertex[indexSlipTime];
+ slipValues = 0.0;
+
+ const double relTime = t - slipTime;
+ if (relTime >= 0.0)
+ for (int i=0; i < spaceDim; ++i)
+ slipValues[i] = finalSlip[i];
+
+ // Update field
+ slipField->updateAddPoint(*v_iter, &slipValues[0]);
+ } // for
+
+ PetscLogFlops(numVertices * 1);
+} // slip
+
+// ----------------------------------------------------------------------
+// Get increment of slip on fault surface between time t0 and t1.
+void
+pylith::faults::StepSlipFn::slipIncr(const ALE::Obj<pylith::real_section_type>& slipField,
+ const double t0,
+ const double t1,
+ const ALE::Obj<Mesh>& faultMesh)
+{ // slipIncr
+ assert(!_parameters.isNull());
+ assert(!slipField.isNull());
+ assert(!faultMesh.isNull());
+
+ const int spaceDim = _spaceDim;
+ const int indexFinalSlip = 0;
+ const int indexSlipTime = spaceDim + _StepSlipFn::offsetSlipTime;
+
+ double_array slipValues(spaceDim);
+
+ // Get vertices in fault mesh
+ const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
+ const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ const int numVertices = vertices->size();
+
+ for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != verticesEnd;
+ ++v_iter) {
+ const real_section_type::value_type* paramsVertex =
+ _parameters->restrictPoint(*v_iter);
+ assert(0 != paramsVertex);
+
+ const double* finalSlip = ¶msVertex[indexFinalSlip];
+ const double slipTime = paramsVertex[indexSlipTime];
+ slipValues = 0.0;
+
+ const double relTime0 = t0 - slipTime;
+ const double relTime1 = t1 - slipTime;
+ if (relTime1 >= 0.0 && relTime0 < 0.0)
+ for (int i=0; i < spaceDim; ++i)
+ slipValues[i] = finalSlip[i];
+
+ // Update field
+ slipField->updateAddPoint(*v_iter, &slipValues[0]);
+ } // for
+
+ PetscLogFlops(numVertices * 3);
+} // slipIncr
+
+// ----------------------------------------------------------------------
+// Get final slip.
+ALE::Obj<pylith::real_section_type>
+pylith::faults::StepSlipFn::finalSlip(void)
+{ // finalSlip
+ return _parameters->getFibration(0);
+} // finalSlip
+
+// ----------------------------------------------------------------------
+// Get time when slip begins at each point.
+ALE::Obj<pylith::real_section_type>
+pylith::faults::StepSlipFn::slipTime(void)
+{ // slipTime
+ return _parameters->getFibration(1);
+} // slipTime
+
+
+// End of file
Added: short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.hh 2008-06-13 22:50:07 UTC (rev 12199)
@@ -0,0 +1,147 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file libsrc/faults/StepSlipFn.hh
+ *
+ * @brief C++ implementation of a step-function slip time function.
+ *
+ * Slip time function is a step function with slip beginning at time t0.
+ *
+ * Normalized slip = 1 if t >= t0, 0 otherwise
+ */
+
+#if !defined(pylith_faults_stepslipfn_hh)
+#define pylith_faults_stepslipfn_hh
+
+#include "SlipTimeFn.hh"
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace faults {
+ class StepSlipFn;
+ class TestStepSlipFn; // unit testing
+ } // faults
+} // pylith
+
+/// Namespace for spatialdata package
+namespace spatialdata {
+ namespace spatialdb {
+ class SpatialDB;
+ } // spatialdb
+} // spatialdata
+
+/// C++ implementation of Step slip time function.
+class pylith::faults::StepSlipFn : public SlipTimeFn
+{ // class StepSlipFn
+ friend class TestStepSlipFn; // unit testing
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ /// Default constructor.
+ StepSlipFn(void);
+
+ /// Destructor.
+ ~StepSlipFn(void);
+
+ /** Set spatial database for final slip.
+ *
+ * @param db Spatial database
+ */
+ void dbFinalSlip(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Set spatial database for slip initiation time.
+ *
+ * @param db Spatial database
+ */
+ void dbSlipTime(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Initialize slip time function.
+ *
+ * @param faultMesh Finite-element mesh of fault.
+ * @param cs Coordinate system for mesh.
+ * @param originTime Origin time for earthquake source.
+ */
+ void initialize(const ALE::Obj<Mesh>& faultMesh,
+ const spatialdata::geocoords::CoordSys* cs,
+ const double originTime =0.0);
+
+ /** Get slip on fault surface at time t.
+ *
+ * @param slipField Slip field over fault surface.
+ * @param t Time t.
+ * @param faultMesh Mesh over fault surface.
+ *
+ * @returns Slip vector as left-lateral/reverse/normal.
+ */
+ void slip(const ALE::Obj<real_section_type>& slipField,
+ const double t,
+ const ALE::Obj<Mesh>& faultMesh);
+
+ /** 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.
+ * @param faultMesh Mesh over fault surface.
+ *
+ * @returns Increment in slip vector as left-lateral/reverse/normal.
+ */
+ void slipIncr(const ALE::Obj<real_section_type>& slipField,
+ const double t0,
+ const double t1,
+ const ALE::Obj<Mesh>& faultMesh);
+
+ /** Get final slip.
+ *
+ * @returns Final slip.
+ */
+ ALE::Obj<real_section_type> finalSlip(void);
+
+ /** Get time when slip begins at each point.
+ *
+ * @returns Time when slip begins.
+ */
+ ALE::Obj<real_section_type> slipTime(void);
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ /// Not implemented
+ StepSlipFn(const StepSlipFn& m);
+
+ /// Not implemented
+ const StepSlipFn& operator=(const StepSlipFn& f);
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+ /// Parameters for Step slip time function.
+ /// Final slip (vector), slip time (scalar).
+ ALE::Obj<real_section_type> _parameters;
+
+ /// Spatial database for final slip
+ spatialdata::spatialdb::SpatialDB* _dbFinalSlip;
+
+ /// Spatial database for slip time
+ spatialdata::spatialdb::SpatialDB* _dbSlipTime;
+
+ int _spaceDim; ///< Spatial dimension for slip field.
+
+}; // class StepSlipFn
+
+#include "StepSlipFn.icc" // inline methods
+
+#endif // pylith_faults_stepslipfn_hh
+
+
+// End of file
Added: short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.icc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.icc 2008-06-13 22:50:07 UTC (rev 12199)
@@ -0,0 +1,35 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#if !defined(pylith_faults_stepslipfn_hh)
+#error "StepSlipFn.icc can only be included from StepSlipFn.hh"
+#endif
+
+#include <math.h> // USES exp()
+#include <assert.h> // USES assert()
+
+// Set spatial database for final slip.
+inline
+void
+pylith::faults::StepSlipFn::dbFinalSlip(spatialdata::spatialdb::SpatialDB* const db) {
+ _dbFinalSlip = db;
+} // dbFinalSlip
+
+// Set spatial database for slip initiation time.
+inline
+void
+pylith::faults::StepSlipFn::dbSlipTime(spatialdata::spatialdb::SpatialDB* const db) {
+ _dbSlipTime = db;
+} // dbSlipTime
+
+
+// End of file
Modified: short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src 2008-06-13 22:50:07 UTC (rev 12199)
@@ -18,6 +18,7 @@
#include "pylith/faults/SlipTimeFn.hh"
#include "pylith/faults/BruneSlipFn.hh"
#include "pylith/faults/ConstRateSlipFn.hh"
+#include "pylith/faults/StepSlipFn.hh"
#include "pylith/utils/array.hh"
@@ -1128,4 +1129,98 @@
ConstRateSlipFn_dbSlipTime_set(self.thisptr, ptrFromHandle(value))
+# ----------------------------------------------------------------------
+cdef class StepSlipFn(SlipTimeFn):
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ # create shim for constructor
+ #embed{ void* StepSlipFn_constructor()
+ void* result = 0;
+ try {
+ result = (void*)(new pylith::faults::StepSlipFn);
+ assert(0 != result);
+ } catch (const std::exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.what()));
+ } catch (const ALE::Exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.msg().c_str()));
+ } catch (...) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Caught unknown C++ exception.");
+ } // try/catch
+ return result;
+ #}embed
+
+ SlipTimeFn.__init__(self)
+ self.thisptr = StepSlipFn_constructor()
+ self.handle = self._createHandle()
+ return
+
+
+ property dbFinalSlip:
+ def __set__(self, value):
+ """
+ Set database for slip rate.
+ """
+ # create shim for method 'dbFinalSlip'
+ #embed{ void StepSlipFn_dbFinalSlip_set(void* objVptr, void* dbVptr)
+ try {
+ assert(0 != objVptr);
+ assert(0 != dbVptr);
+ spatialdata::spatialdb::SpatialDB* db =
+ (spatialdata::spatialdb::SpatialDB*) dbVptr;
+ ((pylith::faults::StepSlipFn*) objVptr)->dbFinalSlip(db);
+ } catch (const std::exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.what()));
+ } catch (const ALE::Exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.msg().c_str()));
+ } catch (...) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Caught unknown C++ exception.");
+ } // try/catch
+ #}embed
+ if not value.name == "spatialdata_spatialdb_SpatialDB":
+ raise TypeError, \
+ "Argument must be extension module type " \
+ "'spatialdata::spatialdb::SpatialDB'."
+ StepSlipFn_dbFinalSlip_set(self.thisptr, ptrFromHandle(value))
+
+
+ property dbSlipTime:
+ def __set__(self, value):
+ """
+ Set database for slip initiation time.
+ """
+ # create shim for method 'dbSlipTime'
+ #embed{ void StepSlipFn_dbSlipTime_set(void* objVptr, void* dbVptr)
+ try {
+ assert(0 != objVptr);
+ assert(0 != dbVptr);
+ spatialdata::spatialdb::SpatialDB* db =
+ (spatialdata::spatialdb::SpatialDB*) dbVptr;
+ ((pylith::faults::StepSlipFn*) objVptr)->dbSlipTime(db);
+ } catch (const std::exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.what()));
+ } catch (const ALE::Exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.msg().c_str()));
+ } catch (...) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Caught unknown C++ exception.");
+ } // try/catch
+ #}embed
+ if not value.name == "spatialdata_spatialdb_SpatialDB":
+ raise TypeError, \
+ "Argument must be extension module type " \
+ "'spatialdata::spatialdb::SpatialDB'."
+ StepSlipFn_dbSlipTime_set(self.thisptr, ptrFromHandle(value))
+
+
# End of file
Modified: short/3D/PyLith/trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/pylith/Makefile.am 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/pylith/Makefile.am 2008-06-13 22:50:07 UTC (rev 12199)
@@ -29,6 +29,7 @@
faults/FaultCohesiveKin.py \
faults/SingleRupture.py \
faults/SlipTimeFn.py \
+ faults/StepSlipFn.py \
feassemble/__init__.py \
feassemble/Constraint.py \
feassemble/ElasticityExplicit.py \
Modified: short/3D/PyLith/trunk/pylith/faults/ConstRateSlipFn.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/ConstRateSlipFn.py 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/pylith/faults/ConstRateSlipFn.py 2008-06-13 22:50:07 UTC (rev 12199)
@@ -40,7 +40,7 @@
## @li None
##
## \b Facilities
- ## @li \b slip_rate Spatial database of peak slip rate
+ ## @li \b slip_rate Spatial database of slip rate
## @li \b slip_time Spatial database of slip initiation time
import pyre.inventory
@@ -53,7 +53,7 @@
slipRate = pyre.inventory.facility("slip_rate", family="spatial_database",
factory=SimpleDB)
- slipRate.meta['tip'] = "Spatial database of peak slip rate."
+ slipRate.meta['tip'] = "Spatial database of slip rate."
# PUBLIC METHODS /////////////////////////////////////////////////////
Modified: short/3D/PyLith/trunk/pylith/faults/EqKinSrc.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/EqKinSrc.py 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/pylith/faults/EqKinSrc.py 2008-06-13 22:50:07 UTC (rev 12199)
@@ -53,9 +53,9 @@
originTime = pyre.inventory.dimensional("origin_time", default=0.0*second)
originTime.meta['tip'] = "Origin time for earthquake rupture."
- from BruneSlipFn import BruneSlipFn
+ from StepSlipFn import StepSlipFn
slipfn = pyre.inventory.facility("slip_function", family="slip_time_fn",
- factory=BruneSlipFn)
+ factory=StepSlipFn)
slipfn.meta['tip'] = "Slip time history function."
Added: short/3D/PyLith/trunk/pylith/faults/StepSlipFn.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/StepSlipFn.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/faults/StepSlipFn.py 2008-06-13 22:50:07 UTC (rev 12199)
@@ -0,0 +1,119 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/faults/StepSlipFn.py
+##
+## @brief Python object for a step-function slip time function.
+##
+## Factory: slip_time_fn
+
+from SlipTimeFn import SlipTimeFn
+
+# StepSlipFn class
+class StepSlipFn(SlipTimeFn):
+ """
+ Python object for a step-function slip time function.
+
+ Factory: slip_time_fn
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(SlipTimeFn.Inventory):
+ """
+ Python object for managing StepSlipFn facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing StepSlipFn facilities and properties.
+ ##
+ ## \b Properties
+ ## @li None
+ ##
+ ## \b Facilities
+ ## @li \b slip Spatial database of final slip.
+ ## @li \b slip_time Spatial database of slip initiation time.
+
+ import pyre.inventory
+
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+
+ slipTime = pyre.inventory.facility("slip_time", family="spatial_database",
+ factory=SimpleDB)
+ slipTime.meta['tip'] = "Spatial database of slip initiation time."
+
+ slip = pyre.inventory.facility("slip", family="spatial_database",
+ factory=SimpleDB)
+ slip.meta['tip'] = "Spatial database of final slip."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="stepslipfn"):
+ """
+ Constructor.
+ """
+ SlipTimeFn.__init__(self, name)
+ self._loggingPrefix = "StSF "
+ return
+
+
+ def initialize(self):
+ """
+ Initialize.
+ """
+ logEvent = "%sinit" % self._loggingPrefix
+ self._logger.eventBegin(logEvent)
+
+ self.slip.initialize()
+ self.slipTime.initialize()
+ assert(None != self.cppHandle)
+
+ self.cppHandle.dbFinalSlip = self.slip.cppHandle
+ self.cppHandle.dbSlipTime = self.slipTime.cppHandle
+
+ self._logger.eventEnd(logEvent)
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ SlipTimeFn._configure(self)
+ self.slip = self.inventory.slip
+ self.slipTime = self.inventory.slipTime
+ return
+
+
+ def _createCppHandle(self):
+ """
+ Create handle to C++ object.
+ """
+ if None == self.cppHandle:
+ import pylith.faults.faults as bindings
+ self.cppHandle = bindings.StepSlipFn()
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def slip_time_fn():
+ """
+ Factory associated with StepSlipFn.
+ """
+ return StepSlipFn()
+
+
+# End of file
Modified: short/3D/PyLith/trunk/pylith/faults/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/__init__.py 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/pylith/faults/__init__.py 2008-06-13 22:50:07 UTC (rev 12199)
@@ -15,12 +15,14 @@
## @brief Python PyLith faults module initialization
__all__ = ['BruneSlipFn',
+ 'ConstRateSlipFn',
'EqKinSrc',
'FaultCohesiveKin',
'FaultCohesive',
'Fault',
'SlipTimeFn',
'SingleRupture',
+ 'StepSlipFn',
]
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am 2008-06-13 22:50:07 UTC (rev 12199)
@@ -23,6 +23,7 @@
testfaults_SOURCES = \
TestBruneSlipFn.cc \
TestConstRateSlipFn.cc \
+ TestStepSlipFn.cc \
TestEqKinSrc.cc \
TestFault.cc \
TestFaultCohesive.cc \
@@ -50,6 +51,7 @@
noinst_HEADERS = \
TestBruneSlipFn.hh \
TestConstRateSlipFn.hh \
+ TestStepSlipFn.hh \
TestEqKinSrc.hh \
TestFault.hh \
TestFaultCohesive.hh \
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.cc 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.cc 2008-06-13 22:50:07 UTC (rev 12199)
@@ -55,10 +55,10 @@
} // testConstructor
// ----------------------------------------------------------------------
-// Test dbFinalSlip().
+// Test dbSlipRate().
void
pylith::faults::TestConstRateSlipFn::testDbSlipRate(void)
-{ // testDbFinalSlip
+{ // testDbSlipRate
const char* label = "database ABC";
ConstRateSlipFn slipfn;
@@ -198,7 +198,7 @@
faultMesh->allocate(slip);
CPPUNIT_ASSERT(!slip.isNull());
- const double t = 2.134;
+ const double t = 1.234;
slipfn.slip(slip, originTime+t, faultMesh);
const double tolerance = 1.0e-06;
@@ -214,8 +214,8 @@
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim) {
- const double slipE =
- slipRateE[iPoint*spaceDim+iDim] * (t - slipTimeE[iPoint]);
+ const double slipE = (t - slipTimeE[iPoint]) > 0.0 ?
+ slipRateE[iPoint*spaceDim+iDim] * (t - slipTimeE[iPoint]) : 0.0;
CPPUNIT_ASSERT_DOUBLES_EQUAL(slipE, vals[iDim], tolerance);
} // for
} // for
Added: short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.cc 2008-06-13 22:50:07 UTC (rev 12199)
@@ -0,0 +1,403 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestStepSlipFn.hh" // Implementation of class methods
+
+#include "pylith/faults/StepSlipFn.hh" // USES StepSlipFn
+
+#include "pylith/faults/CohesiveTopology.hh" // USES CohesiveTopology
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
+
+#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
+#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
+#include "spatialdata/spatialdb/SimpleIOAscii.hh" // USES SimpleIOAscii
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::faults::TestStepSlipFn );
+
+// ----------------------------------------------------------------------
+namespace pylith {
+ namespace faults {
+ namespace _TestStepSlipFn {
+ struct DataStruct {
+ const char* meshFilename;
+ const char* faultLabel;
+ const int faultId;
+ const char* finalSlipFilename;
+ const char* slipTimeFilename;
+ const int* constraintPts;
+ const double* finalSlipE;
+ const double* slipTimeE;
+ const int numConstraintPts;
+ }; // DataStruct
+ } // _TestStepSlipFn
+ } // faults
+} // pylith
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::faults::TestStepSlipFn::testConstructor(void)
+{ // testConstructor
+ StepSlipFn slipfn;
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test dbFinalSlip().
+void
+pylith::faults::TestStepSlipFn::testDbFinalSlip(void)
+{ // testDbFinalSlip
+ const char* label = "database ABC";
+ StepSlipFn slipfn;
+
+ spatialdata::spatialdb::SimpleDB db(label);
+ slipfn.dbFinalSlip(&db);
+
+ CPPUNIT_ASSERT(0 != slipfn._dbFinalSlip);
+ CPPUNIT_ASSERT_EQUAL(std::string(label),
+ std::string(slipfn._dbFinalSlip->label()));
+ CPPUNIT_ASSERT(0 == slipfn._dbSlipTime);
+} // testDbFinalSlip
+
+// ----------------------------------------------------------------------
+// Test dbSlipTime().
+void
+pylith::faults::TestStepSlipFn::testDbSlipTime(void)
+{ // testDbSlipTime
+ const char* label = "database ABCD";
+ StepSlipFn slipfn;
+
+ spatialdata::spatialdb::SimpleDB db(label);
+ slipfn.dbSlipTime(&db);
+
+ CPPUNIT_ASSERT(0 != slipfn._dbSlipTime);
+ CPPUNIT_ASSERT_EQUAL(std::string(label),
+ std::string(slipfn._dbSlipTime->label()));
+ CPPUNIT_ASSERT(0 == slipfn._dbFinalSlip);
+} // testDbSlipTime
+
+// ----------------------------------------------------------------------
+// Test initialize() in 1-D.
+void
+pylith::faults::TestStepSlipFn::testInitialize1D(void)
+{ // testInitialize1D
+ const char* meshFilename = "data/line2.mesh";
+ const char* faultLabel = "fault";
+ const int faultId = 2;
+ const char* finalSlipFilename = "data/line2_finalslip.spatialdb";
+ const char* slipTimeFilename = "data/line2_sliptime.spatialdb";
+ const int constraintPts[] = { 3 };
+ const double finalSlipE[] = { 2.3 };
+ const double slipTimeE[] = { 1.2 };
+ const int numConstraintPts = 1;
+
+ _TestStepSlipFn::DataStruct data = {meshFilename,
+ faultLabel,
+ faultId,
+ finalSlipFilename,
+ slipTimeFilename,
+ constraintPts,
+ finalSlipE,
+ slipTimeE,
+ numConstraintPts};
+ _testInitialize(data);
+} // testInitialize1D
+
+// ----------------------------------------------------------------------
+// Test initialize() in 2-D.
+void
+pylith::faults::TestStepSlipFn::testInitialize2D(void)
+{ // testInitialize2D
+ const char* meshFilename = "data/tri3.mesh";
+ const char* faultLabel = "fault";
+ const int faultId = 2;
+ const char* finalSlipFilename = "data/tri3_finalslip.spatialdb";
+ const char* slipTimeFilename = "data/tri3_sliptime.spatialdb";
+ const int constraintPts[] = { 3, 4 };
+ const double finalSlipE[] = { 2.3, 0.1,
+ 2.4, 0.2 };
+ const double slipTimeE[] = { 1.2, 1.3 };
+ const int numConstraintPts = 2;
+
+ _TestStepSlipFn::DataStruct data = {meshFilename,
+ faultLabel,
+ faultId,
+ finalSlipFilename,
+ slipTimeFilename,
+ constraintPts,
+ finalSlipE,
+ slipTimeE,
+ numConstraintPts};
+ _testInitialize(data);
+} // testInitialize2D
+
+// ----------------------------------------------------------------------
+// Test initialize() in 3-D.
+void
+pylith::faults::TestStepSlipFn::testInitialize3D(void)
+{ // testInitialize3D
+ const char* meshFilename = "data/tet4.mesh";
+ const char* faultLabel = "fault";
+ const int faultId = 2;
+ const char* finalSlipFilename = "data/tet4_finalslip.spatialdb";
+ const char* slipTimeFilename = "data/tet4_sliptime.spatialdb";
+ const int constraintPts[] = { 3, 4, 5 };
+ const double finalSlipE[] = { 2.3, -0.7, 0.1,
+ 2.4, -0.8, 0.2,
+ 2.5, -0.9, 0.3 };
+ const double slipTimeE[] = { 1.2, 1.3, 1.4 };
+ const int numConstraintPts = 3;
+
+ _TestStepSlipFn::DataStruct data = {meshFilename,
+ faultLabel,
+ faultId,
+ finalSlipFilename,
+ slipTimeFilename,
+ constraintPts,
+ finalSlipE,
+ slipTimeE,
+ numConstraintPts};
+ _testInitialize(data);
+} // testInitialize3D
+
+// ----------------------------------------------------------------------
+// Test slip().
+void
+pylith::faults::TestStepSlipFn::testSlip(void)
+{ // testSlip
+ const double slipE[] = { 2.3, 0.1,
+ 0.0, 0.0};
+ const double originTime = 5.064;
+
+ ALE::Obj<Mesh> faultMesh;
+ StepSlipFn slipfn;
+ _initialize(&faultMesh, &slipfn, originTime);
+
+ const int spaceDim = faultMesh->getDimension() + 1;
+ const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
+ const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ ALE::Obj<real_section_type> slip =
+ new real_section_type(faultMesh->comm(), faultMesh->debug());
+ slip->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(),
+ vertices->end()),
+ *std::max_element(vertices->begin(), vertices->end())+1));
+ slip->setFiberDimension(vertices, spaceDim);
+ faultMesh->allocate(slip);
+ CPPUNIT_ASSERT(!slip.isNull());
+
+ const double t = 1.234;
+ slipfn.slip(slip, originTime+t, faultMesh);
+
+ const double tolerance = 1.0e-06;
+ int iPoint = 0;
+ for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != verticesEnd;
+ ++v_iter, ++iPoint) {
+ const int fiberDim = slip->getFiberDimension(*v_iter);
+ CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
+ const real_section_type::value_type* vals =
+ slip->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != vals);
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(slipE[iPoint*spaceDim+iDim], vals[iDim],
+ tolerance);
+ } // for
+} // testSlip
+
+// ----------------------------------------------------------------------
+// Test slipIncr().
+void
+pylith::faults::TestStepSlipFn::testSlipIncr(void)
+{ // testSlipIncr
+ const double slipE[] = { 0.0, 0.0,
+ 2.4, 0.2};
+ const double originTime = 1.064;
+
+ ALE::Obj<Mesh> faultMesh;
+ StepSlipFn slipfn;
+ _initialize(&faultMesh, &slipfn, originTime);
+
+ const int spaceDim = faultMesh->getDimension() + 1;
+ const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
+ const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ ALE::Obj<real_section_type> slip =
+ new real_section_type(faultMesh->comm(), faultMesh->debug());
+ slip->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(),
+ vertices->end()),
+ *std::max_element(vertices->begin(), vertices->end())+1));
+ slip->setFiberDimension(vertices, spaceDim);
+ faultMesh->allocate(slip);
+ CPPUNIT_ASSERT(!slip.isNull());
+
+ const double t0 = 1.234;
+ const double t1 = 3.635;
+ slipfn.slipIncr(slip, originTime+t0, originTime+t1, faultMesh);
+
+ const double tolerance = 1.0e-06;
+ int iPoint = 0;
+ for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != verticesEnd;
+ ++v_iter, ++iPoint) {
+
+ const int fiberDim = slip->getFiberDimension(*v_iter);
+ CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
+ const real_section_type::value_type* vals =
+ slip->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != vals);
+
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(slipE[iPoint*spaceDim+iDim], vals[iDim],
+ tolerance);
+ } // for
+} // testSlipIncr
+
+// ----------------------------------------------------------------------
+// Initialize StepSlipFn.
+void
+pylith::faults::TestStepSlipFn::_initialize(ALE::Obj<Mesh>* faultMesh,
+ StepSlipFn* slipfn,
+ const double originTime)
+{ // _initialize
+ assert(0 != slipfn);
+
+ const char* meshFilename = "data/tri3.mesh";
+ const char* faultLabel = "fault";
+ const int faultId = 2;
+ const char* finalSlipFilename = "data/tri3_finalslip.spatialdb";
+ const char* slipTimeFilename = "data/tri3_sliptime.spatialdb";
+
+ ALE::Obj<Mesh> mesh;
+ meshio::MeshIOAscii meshIO;
+ meshIO.filename(meshFilename);
+ meshIO.debug(false);
+ meshIO.interpolate(false);
+ meshIO.read(&mesh);
+ CPPUNIT_ASSERT(!mesh.isNull());
+ const int spaceDim = mesh->getDimension();
+ spatialdata::geocoords::CSCart cs;
+ cs.setSpaceDim(spaceDim);
+
+ // Create fault mesh
+ const bool useLagrangeConstraints = true;
+ CohesiveTopology::create(faultMesh, mesh,
+ mesh->getIntSection(faultLabel),
+ faultId);
+ CPPUNIT_ASSERT(!faultMesh->isNull());
+ // Need to copy coordinates from mesh to fault mesh since we are not
+ // using create() instead of createParallel().
+ (*faultMesh)->setRealSection("coordinates",
+ mesh->getRealSection("coordinates"));
+
+ // Setup databases
+ spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
+ spatialdata::spatialdb::SimpleIOAscii ioFinalSlip;
+ ioFinalSlip.filename(finalSlipFilename);
+ dbFinalSlip.ioHandler(&ioFinalSlip);
+
+ spatialdata::spatialdb::SimpleDB dbSlipTime("slip time");
+ spatialdata::spatialdb::SimpleIOAscii ioSlipTime;
+ ioSlipTime.filename(slipTimeFilename);
+ dbSlipTime.ioHandler(&ioSlipTime);
+
+ // setup StepSlipFn
+ slipfn->dbFinalSlip(&dbFinalSlip);
+ slipfn->dbSlipTime(&dbSlipTime);
+
+ slipfn->initialize(*faultMesh, &cs, originTime);
+} // _initialize
+
+// ----------------------------------------------------------------------
+// Test initialize().
+void
+pylith::faults::TestStepSlipFn::_testInitialize(const _TestStepSlipFn::DataStruct& data)
+{ // _testInitialize
+ typedef std::set<Mesh::point_type>::const_iterator vert_iterator;
+
+ // Setup mesh
+ ALE::Obj<Mesh> mesh;
+ meshio::MeshIOAscii meshIO;
+ meshIO.filename(data.meshFilename);
+ meshIO.debug(false);
+ meshIO.interpolate(false);
+ meshIO.read(&mesh);
+ CPPUNIT_ASSERT(!mesh.isNull());
+ const int spaceDim = mesh->getDimension();
+ spatialdata::geocoords::CSCart cs;
+ cs.setSpaceDim(spaceDim);
+
+ // Create fault mesh
+ ALE::Obj<Mesh> faultMesh;
+ const bool useLagrangeConstraints = true;
+ CohesiveTopology::create(&faultMesh, mesh,
+ mesh->getIntSection(data.faultLabel),
+ data.faultId);
+ CPPUNIT_ASSERT(!faultMesh.isNull());
+ // Need to copy coordinates from mesh to fault mesh since we are not
+ // using create() instead of createParallel().
+ faultMesh->setRealSection("coordinates",
+ mesh->getRealSection("coordinates"));
+
+ // Setup databases
+ spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
+ spatialdata::spatialdb::SimpleIOAscii ioFinalSlip;
+ ioFinalSlip.filename(data.finalSlipFilename);
+ dbFinalSlip.ioHandler(&ioFinalSlip);
+
+ spatialdata::spatialdb::SimpleDB dbSlipTime("slip time");
+ spatialdata::spatialdb::SimpleIOAscii ioSlipTime;
+ ioSlipTime.filename(data.slipTimeFilename);
+ dbSlipTime.ioHandler(&ioSlipTime);
+
+ // setup StepSlipFn
+ StepSlipFn slipfn;
+ slipfn.dbFinalSlip(&dbFinalSlip);
+ slipfn.dbSlipTime(&dbSlipTime);
+
+ const double originTime = 5.353;
+
+ slipfn.initialize(faultMesh, &cs, originTime);
+
+ const double tolerance = 1.0e-06;
+
+ const ALE::Obj<Mesh::label_sequence>& vertices =
+ faultMesh->depthStratum(0);
+ const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+
+ int iPoint = 0;
+ for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != verticesEnd;
+ ++v_iter, ++iPoint) {
+ const int fiberDim = slipfn._parameters->getFiberDimension(*v_iter);
+ CPPUNIT_ASSERT_EQUAL(spaceDim+1, fiberDim);
+
+ const real_section_type::value_type* vals =
+ slipfn._parameters->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != vals);
+
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(data.finalSlipE[iPoint*spaceDim+iDim],
+ vals[iDim],
+ tolerance);
+
+ const double slipTime = vals[spaceDim];
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipTimeE[iPoint]+originTime,
+ slipTime, tolerance);
+ } // for
+} // _testInitialize
+
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.hh 2008-06-13 22:50:07 UTC (rev 12199)
@@ -0,0 +1,111 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/faults/TestStepSlipFn.hh
+ *
+ * @brief C++ TestStepSlipFn object
+ *
+ * C++ unit testing for StepSlipFn.
+ */
+
+#if !defined(pylith_faults_teststepslipfn_hh)
+#define pylith_faults_teststepslipfn_hh
+
+#include "pylith/utils/sievetypes.hh" // USES Mesh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace faults {
+ class TestStepSlipFn;
+ class StepSlipFn;
+
+ namespace _TestStepSlipFn {
+ struct DataStruct;
+ } // _StepSlipTimeFn
+ } // faults
+} // pylith
+
+/// C++ unit testing for StepSlipFn
+class pylith::faults::TestStepSlipFn : public CppUnit::TestFixture
+{ // class TestStepSlipFn
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestStepSlipFn );
+
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testDbFinalSlip );
+ CPPUNIT_TEST( testDbSlipTime );
+ CPPUNIT_TEST( testInitialize1D );
+ CPPUNIT_TEST( testInitialize2D );
+ CPPUNIT_TEST( testInitialize3D );
+ CPPUNIT_TEST( testSlip );
+ CPPUNIT_TEST( testSlipIncr );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Test constructor.
+ void testConstructor(void);
+
+ /// Test dbFinalSlip().
+ void testDbFinalSlip(void);
+
+ /// Test dbSlipTime().
+ void testDbSlipTime(void);
+
+ /// Test initialize() in 1-D.
+ void testInitialize1D(void);
+
+ /// Test initialize() in 2-D.
+ void testInitialize2D(void);
+
+ /// Test initialize() in 3-D.
+ void testInitialize3D(void);
+
+ /// Test slip().
+ void testSlip(void);
+
+ /// Test slipIncr().
+ void testSlipIncr(void);
+
+ // PRIVATE METHODS ////////////////////////////////////////////////////
+private :
+
+ /** Initialize StepSlipFn.
+ *
+ * @param faultMesh Fault mesh.
+ * @param slipfn Step slip function.
+ * @param originTime Origin time for earthquake rupture.
+ */
+ static
+ void _initialize(ALE::Obj<Mesh>* faultMesh,
+ StepSlipFn* slipfn,
+ const double originTime);
+
+ /** Test intialize().
+ *
+ * @param data Data for initialization and testing of StepSlipFn.
+ */
+ static
+ void _testInitialize(const _TestStepSlipFn::DataStruct& data);
+
+}; // class TestStepSlipFn
+
+#endif // pylith_faults_teststepslipfn_hh
+
+
+// End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/faults/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/Makefile.am 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/Makefile.am 2008-06-13 22:50:07 UTC (rev 12199)
@@ -26,7 +26,8 @@
TestFault.py \
TestFaultCohesive.py \
TestFaultCohesiveKin.py \
- TestEqKinSrc.py
+ TestEqKinSrc.py \
+ TestStepSlipFn.py
# End of file
Added: short/3D/PyLith/trunk/unittests/pytests/faults/TestStepSlipFn.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/TestStepSlipFn.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/TestStepSlipFn.py 2008-06-13 22:50:07 UTC (rev 12199)
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/faults/TestStepSlipFn.py
+
+## @brief Unit testing of StepSlipFn object.
+
+import unittest
+
+from pylith.faults.StepSlipFn import StepSlipFn
+
+# ----------------------------------------------------------------------
+class TestStepSlipFn(unittest.TestCase):
+ """
+ Unit testing of StepSlipFn object.
+ """
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ slipFn = StepSlipFn()
+ slipFn._createCppHandle()
+ self.failIfEqual(None, slipFn.cppHandle)
+ return
+
+
+ def test_initialize(self):
+ """
+ Test initialize().
+ """
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+ from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
+
+ ioFinalSlip = SimpleIOAscii()
+ ioFinalSlip.filename = "finalslip.spatialdb"
+ dbFinalSlip = SimpleDB()
+ dbFinalSlip.iohandler = ioFinalSlip
+ dbFinalSlip.label = "final slip"
+
+ ioSlipTime = SimpleIOAscii()
+ ioSlipTime.filename = "sliptime.spatialdb"
+ dbSlipTime = SimpleDB()
+ dbSlipTime.iohandler = ioSlipTime
+ dbSlipTime.label = "slip time"
+
+ slipFn = StepSlipFn()
+ slipFn.slip = dbFinalSlip
+ slipFn.slipTime = dbSlipTime
+ slipFn.preinitialize()
+ slipFn.initialize()
+ return
+
+
+# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py 2008-06-13 22:44:21 UTC (rev 12198)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py 2008-06-13 22:50:07 UTC (rev 12199)
@@ -62,6 +62,9 @@
from TestConstRateSlipFn import TestConstRateSlipFn
suite.addTest(unittest.makeSuite(TestConstRateSlipFn))
+ from TestStepSlipFn import TestStepSlipFn
+ suite.addTest(unittest.makeSuite(TestStepSlipFn))
+
from TestEqKinSrc import TestEqKinSrc
suite.addTest(unittest.makeSuite(TestEqKinSrc))
More information about the cig-commits
mailing list