[cig-commits] r14612 - in short/3D/PyLith/branches/pylith-swig: libsrc/faults unittests/libtests/faults
brad at geodynamics.org
brad at geodynamics.org
Mon Apr 6 22:03:17 PDT 2009
Author: brad
Date: 2009-04-06 22:03:16 -0700 (Mon, 06 Apr 2009)
New Revision: 14612
Modified:
short/3D/PyLith/branches/pylith-swig/libsrc/faults/ConstRateSlipFn.cc
short/3D/PyLith/branches/pylith-swig/libsrc/faults/LiuCosSlipFn.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/Makefile.am
short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestBruneSlipFn.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestBruneSlipFn.hh
short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestConstRateSlipFn.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestConstRateSlipFn.hh
short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestLiuCosSlipFn.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestLiuCosSlipFn.hh
short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestStepSlipFn.cc
Log:
More work on updating dault unit tests.
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/faults/ConstRateSlipFn.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/faults/ConstRateSlipFn.cc 2009-04-07 03:23:33 UTC (rev 14611)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/faults/ConstRateSlipFn.cc 2009-04-07 05:03:16 UTC (rev 14612)
@@ -194,7 +194,7 @@
// Get sections
const topology::Field<topology::SubMesh>& slipRate =
- _parameters->get("final slip");
+ _parameters->get("slip rate");
const ALE::Obj<RealSection>& slipRateSection = slipRate.section();
assert(!slipRateSection.isNull());
const topology::Field<topology::SubMesh>& slipTime =
@@ -242,7 +242,7 @@
// Get sections
const topology::Field<topology::SubMesh>& slipRate =
- _parameters->get("final slip");
+ _parameters->get("slip rate");
const ALE::Obj<RealSection>& slipRateSection = slipRate.section();
assert(!slipRateSection.isNull());
const topology::Field<topology::SubMesh>& slipTime =
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/faults/LiuCosSlipFn.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/faults/LiuCosSlipFn.cc 2009-04-07 03:23:33 UTC (rev 14611)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/faults/LiuCosSlipFn.cc 2009-04-07 05:03:16 UTC (rev 14612)
@@ -36,6 +36,7 @@
pylith::faults::LiuCosSlipFn::LiuCosSlipFn(void) :
_slipTimeVertex(0),
_riseTimeVertex(0),
+ _parameters(0),
_dbFinalSlip(0),
_dbSlipTime(0),
_dbRiseTime(0)
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/Makefile.am 2009-04-07 03:23:33 UTC (rev 14611)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/Makefile.am 2009-04-07 05:03:16 UTC (rev 14612)
@@ -23,12 +23,12 @@
testfaults_SOURCES = \
TestFaultCohesive.cc \
TestStepSlipFn.cc \
+ TestConstRateSlipFn.cc \
+ TestBruneSlipFn.cc \
+ TestLiuCosSlipFn.cc \
TestEqKinSrc.cc \
test_faults.cc
-# TestBruneSlipFn.cc \
-# TestLiuCosSlipFn.cc \
-# TestConstRateSlipFn.cc \
# TestFault.cc \
# TestFaultCohesiveKin.cc \
# TestFaultCohesiveKinLine2.cc \
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestBruneSlipFn.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestBruneSlipFn.cc 2009-04-07 03:23:33 UTC (rev 14611)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestBruneSlipFn.cc 2009-04-07 05:03:16 UTC (rev 14612)
@@ -17,8 +17,11 @@
#include "pylith/faults/BruneSlipFn.hh" // USES BruneSlipFn
#include "pylith/faults/CohesiveTopology.hh" // USES CohesiveTopology
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
#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
@@ -38,11 +41,11 @@
const int faultId;
const char* finalSlipFilename;
const char* slipTimeFilename;
- const char* peakRateFilename;
+ const char* riseTimeFilename;
const int* constraintPts;
const double* finalSlipE;
const double* slipTimeE;
- const double* peakRateE;
+ const double* riseTimeE;
const int numConstraintPts;
}; // DataStruct
} // _TestBruneSlipFn
@@ -50,6 +53,11 @@
} // pylith
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::SieveSubMesh SieveSubMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
// Test constructor.
void
pylith::faults::TestBruneSlipFn::testConstructor(void)
@@ -72,7 +80,7 @@
CPPUNIT_ASSERT_EQUAL(std::string(label),
std::string(slipfn._dbFinalSlip->label()));
CPPUNIT_ASSERT(0 == slipfn._dbSlipTime);
- CPPUNIT_ASSERT(0 == slipfn._dbPeakRate);
+ CPPUNIT_ASSERT(0 == slipfn._dbRiseTime);
} // testDbFinalSlip
// ----------------------------------------------------------------------
@@ -90,26 +98,26 @@
CPPUNIT_ASSERT_EQUAL(std::string(label),
std::string(slipfn._dbSlipTime->label()));
CPPUNIT_ASSERT(0 == slipfn._dbFinalSlip);
- CPPUNIT_ASSERT(0 == slipfn._dbPeakRate);
+ CPPUNIT_ASSERT(0 == slipfn._dbRiseTime);
} // testDbSlipTime
// ----------------------------------------------------------------------
-// Test dbPeakRate().
+// Test dbRiseTime().
void
-pylith::faults::TestBruneSlipFn::testDbPeakRate(void)
-{ // testDbPeakRate
+pylith::faults::TestBruneSlipFn::testDbRiseTime(void)
+{ // testDbRiseTime
const char* label = "database ABCDE";
BruneSlipFn slipfn;
spatialdata::spatialdb::SimpleDB db(label);
- slipfn.dbPeakRate(&db);
+ slipfn.dbRiseTime(&db);
- CPPUNIT_ASSERT(0 != slipfn._dbPeakRate);
+ CPPUNIT_ASSERT(0 != slipfn._dbRiseTime);
CPPUNIT_ASSERT_EQUAL(std::string(label),
- std::string(slipfn._dbPeakRate->label()));
+ std::string(slipfn._dbRiseTime->label()));
CPPUNIT_ASSERT(0 == slipfn._dbFinalSlip);
CPPUNIT_ASSERT(0 == slipfn._dbSlipTime);
-} // testDbPeakRate
+} // testDbRiseTime
// ----------------------------------------------------------------------
// Test initialize() in 1-D.
@@ -121,11 +129,11 @@
const int faultId = 2;
const char* finalSlipFilename = "data/line2_finalslip.spatialdb";
const char* slipTimeFilename = "data/line2_sliptime.spatialdb";
- const char* peakRateFilename = "data/line2_peakrate.spatialdb";
+ const char* riseTimeFilename = "data/line2_risetime.spatialdb";
const int constraintPts[] = { 3 };
const double finalSlipE[] = { 2.3 };
const double slipTimeE[] = { 1.2 };
- const double peakRateE[] = { 1.4 };
+ const double riseTimeE[] = { 1.4 };
const int numConstraintPts = 1;
_TestBruneSlipFn::DataStruct data = {meshFilename,
@@ -133,11 +141,11 @@
faultId,
finalSlipFilename,
slipTimeFilename,
- peakRateFilename,
+ riseTimeFilename,
constraintPts,
finalSlipE,
slipTimeE,
- peakRateE,
+ riseTimeE,
numConstraintPts};
_testInitialize(data);
} // testInitialize1D
@@ -152,12 +160,12 @@
const int faultId = 2;
const char* finalSlipFilename = "data/tri3_finalslip.spatialdb";
const char* slipTimeFilename = "data/tri3_sliptime.spatialdb";
- const char* peakRateFilename = "data/tri3_peakrate.spatialdb";
+ const char* riseTimeFilename = "data/tri3_risetime.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 double peakRateE[] = { 1.4, 1.5 };
+ const double riseTimeE[] = { 1.4, 1.5 };
const int numConstraintPts = 2;
_TestBruneSlipFn::DataStruct data = {meshFilename,
@@ -165,11 +173,11 @@
faultId,
finalSlipFilename,
slipTimeFilename,
- peakRateFilename,
+ riseTimeFilename,
constraintPts,
finalSlipE,
slipTimeE,
- peakRateE,
+ riseTimeE,
numConstraintPts};
_testInitialize(data);
} // testInitialize2D
@@ -184,13 +192,13 @@
const int faultId = 2;
const char* finalSlipFilename = "data/tet4_finalslip.spatialdb";
const char* slipTimeFilename = "data/tet4_sliptime.spatialdb";
- const char* peakRateFilename = "data/tet4_peakrate.spatialdb";
+ const char* riseTimeFilename = "data/tet4_risetime.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 double peakRateE[] = { 1.5, 1.6, 1.7 };
+ const double riseTimeE[] = { 1.5, 1.6, 1.7 };
const int numConstraintPts = 3;
_TestBruneSlipFn::DataStruct data = {meshFilename,
@@ -198,11 +206,11 @@
faultId,
finalSlipFilename,
slipTimeFilename,
- peakRateFilename,
+ riseTimeFilename,
constraintPts,
finalSlipE,
slipTimeE,
- peakRateE,
+ riseTimeE,
numConstraintPts};
_testInitialize(data);
} // testInitialize3D
@@ -215,46 +223,49 @@
const double finalSlipE[] = { 2.3, 0.1,
0.0, 0.0};
const double slipTimeE[] = { 1.2, 1.3 };
- const double peakRateE[] = { 1.4, 1.5 };
+ const double riseTimeE[] = { 1.4, 1.5 };
const double originTime = 5.064;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
BruneSlipFn slipfn;
- _initialize(&faultMesh, &slipfn, originTime);
+ _initialize(&mesh, &faultMesh, &slipfn, originTime);
- const int spaceDim = faultMesh->getDimension() + 1;
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
- 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 int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
const double t = 2.134;
- slipfn.slip(slip, originTime+t, faultMesh);
+ slipfn.slip(&slip, originTime+t);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
double slipMag = 0.0;
for (int iDim=0; iDim < spaceDim; ++iDim)
slipMag += pow(finalSlipE[iPoint*spaceDim+iDim], 2);
slipMag = sqrt(slipMag);
+ const double peakRate = slipMag / riseTimeE[iPoint] * 1.745;
const double tau =
- (slipMag > 0.0) ? slipMag / (exp(1.0) * peakRateE[iPoint]) : 1.0;
+ (slipMag > 0.0) ? slipMag / (exp(1.0) * peakRate) : 1.0;
const double t0 = slipTimeE[iPoint];
const double slipNorm = 1.0 - exp(-(t-t0)/tau) * (1.0 + (t-t0)/tau);
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim) {
@@ -272,51 +283,54 @@
const double finalSlipE[] = { 2.3, 0.1,
0.0, 0.0};
const double slipTimeE[] = { 1.2, 1.3 };
- const double peakRateE[] = { 1.4, 1.5 };
+ const double riseTimeE[] = { 1.4, 1.5 };
const double originTime = 1.064;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
BruneSlipFn slipfn;
- _initialize(&faultMesh, &slipfn, originTime);
+ _initialize(&mesh, &faultMesh, &slipfn, originTime);
- const int spaceDim = faultMesh->getDimension() + 1;
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
- 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 int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
const double t0 = 1.234;
const double t1 = 3.635;
- slipfn.slipIncr(slip, originTime+t0, originTime+t1, faultMesh);
+ slipfn.slipIncr(&slip, originTime+t0, originTime+t1);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
double slipMag = 0.0;
for (int iDim=0; iDim < spaceDim; ++iDim)
slipMag += pow(finalSlipE[iPoint*spaceDim+iDim], 2);
slipMag = sqrt(slipMag);
+ const double peakRate = slipMag / riseTimeE[iPoint] * 1.745;
const double tau =
- (slipMag > 0.0) ? slipMag / (exp(1.0) * peakRateE[iPoint]) : 1.0;
+ (slipMag > 0.0) ? slipMag / (exp(1.0) * peakRate) : 1.0;
const double tRef = slipTimeE[iPoint];
const double slipNorm0 =
(t0 > tRef) ? 1.0 - exp(-(t0-tRef)/tau) * (1.0 + (t0-tRef)/tau) : 0.0;
const double slipNorm1 =
(t1 > tRef) ? 1.0 - exp(-(t1-tRef)/tau) * (1.0 + (t1-tRef)/tau) : 0.0;
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim) {
@@ -334,66 +348,72 @@
{ // testSlipTH
const double t = 0.734;
const double finalSlip = 4.64;
- const double peakRate = 3.23;
+ const double riseTime = 3.23;
+ const double peakRate = finalSlip / riseTime * 1.745;
const double tau = finalSlip / (exp(1.0) * peakRate);
const double slipE = finalSlip * (1.0 - exp(-t/tau) * (1.0 + t/tau));
- double slip = BruneSlipFn::_slipFn(t, finalSlip, peakRate);
+ double slip = BruneSlipFn::_slipFn(t, finalSlip, riseTime);
const double tolerance = 1.0e-06;
CPPUNIT_ASSERT_DOUBLES_EQUAL(slipE, slip, tolerance);
- slip = BruneSlipFn::_slipFn(-0.5, finalSlip, peakRate);
+ slip = BruneSlipFn::_slipFn(-0.5, finalSlip, riseTime);
CPPUNIT_ASSERT_EQUAL(0.0, slip);
- slip = BruneSlipFn::_slipFn(1.0e+10, finalSlip, peakRate);
+ slip = BruneSlipFn::_slipFn(1.0e+10, finalSlip, riseTime);
CPPUNIT_ASSERT_DOUBLES_EQUAL(finalSlip, slip, tolerance);
} // testSlipTH
// ----------------------------------------------------------------------
// Initialize BruneSlipFn.
void
-pylith::faults::TestBruneSlipFn::_initialize(ALE::Obj<Mesh>* faultMesh,
+pylith::faults::TestBruneSlipFn::_initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
BruneSlipFn* slipfn,
const double originTime)
{ // _initialize
- assert(0 != slipfn);
+ CPPUNIT_ASSERT(0 != mesh);
+ CPPUNIT_ASSERT(0 != faultMesh);
+ CPPUNIT_ASSERT(0 != slipfn);
const char* meshFilename = "data/tri3.mesh";
const char* faultLabel = "fault";
const int faultId = 2;
const char* finalSlipFilename = "data/tri3_finalslipB.spatialdb";
const char* slipTimeFilename = "data/tri3_sliptime.spatialdb";
- const char* peakRateFilename = "data/tri3_peakrate.spatialdb";
+ const char* riseTimeFilename = "data/tri3_risetime.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();
+ meshIO.read(mesh);
+
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim(spaceDim);
+ cs.setSpaceDim(mesh->dimension());
+ cs.initialize();
+ mesh->coordsys(&cs);
// Create fault mesh
const bool useLagrangeConstraints = true;
- (*faultMesh) = new Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh> faultBd = NULL;
- CohesiveTopology::createFault(*faultMesh, faultBd,
- mesh,
- mesh->getIntSection(faultLabel));
- CohesiveTopology::create(*faultMesh, faultBd, mesh,
- mesh->getIntSection(faultLabel),
+ ALE::Obj<ALE::Mesh> faultBoundary = 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CohesiveTopology::createFault(faultMesh, faultBoundary,
+ *mesh, sieveMesh->getIntSection(faultLabel));
+ CohesiveTopology::create(mesh, *faultMesh, faultBoundary,
+ sieveMesh->getIntSection(faultLabel),
faultId,
useLagrangeConstraints);
- 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"));
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh->sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
// Setup databases
spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
@@ -406,19 +426,19 @@
ioSlipTime.filename(slipTimeFilename);
dbSlipTime.ioHandler(&ioSlipTime);
- spatialdata::spatialdb::SimpleDB dbPeakRate("peak rate");
- spatialdata::spatialdb::SimpleIOAscii ioPeakRate;
- ioPeakRate.filename(peakRateFilename);
- dbPeakRate.ioHandler(&ioPeakRate);
+ spatialdata::spatialdb::SimpleDB dbRiseTime("rise time");
+ spatialdata::spatialdb::SimpleIOAscii ioRiseTime;
+ ioRiseTime.filename(riseTimeFilename);
+ dbRiseTime.ioHandler(&ioRiseTime);
spatialdata::units::Nondimensional normalizer;
// setup BruneSlipFn
slipfn->dbFinalSlip(&dbFinalSlip);
slipfn->dbSlipTime(&dbSlipTime);
- slipfn->dbPeakRate(&dbPeakRate);
+ slipfn->dbRiseTime(&dbRiseTime);
- slipfn->initialize(*faultMesh, &cs, normalizer, originTime);
+ slipfn->initialize(*faultMesh, normalizer, originTime);
} // _initialize
// ----------------------------------------------------------------------
@@ -429,34 +449,38 @@
typedef std::set<Mesh::point_type>::const_iterator vert_iterator;
// Setup mesh
- ALE::Obj<Mesh> mesh;
+ topology::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();
+
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
+ const int spaceDim = mesh.dimension();
cs.setSpaceDim(spaceDim);
+ cs.initialize();
+ mesh.coordsys(&cs);
// Create fault mesh
- ALE::Obj<Mesh> faultMesh =
- new Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh> faultBd = NULL;
+ topology::SubMesh faultMesh;
const bool useLagrangeConstraints = true;
- CohesiveTopology::createFault(faultMesh, faultBd,
- mesh,
- mesh->getIntSection(data.faultLabel));
- CohesiveTopology::create(faultMesh, faultBd, mesh,
- mesh->getIntSection(data.faultLabel),
+ ALE::Obj<ALE::Mesh> faultBoundary = 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CohesiveTopology::createFault(&faultMesh, faultBoundary,
+ mesh, sieveMesh->getIntSection(data.faultLabel));
+ CohesiveTopology::create(&mesh, faultMesh, faultBoundary,
+ sieveMesh->getIntSection(data.faultLabel),
data.faultId,
useLagrangeConstraints);
- CPPUNIT_ASSERT(!faultMesh.isNull());
- // Need to copy coordinates from mesh to fault mesh since we are
+ // Need to copy coordinates from mesh to fault mesh since we are not
// using create() instead of createParallel().
- faultMesh->setRealSection("coordinates",
- mesh->getRealSection("coordinates"));
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
// Setup databases
spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
@@ -469,51 +493,61 @@
ioSlipTime.filename(data.slipTimeFilename);
dbSlipTime.ioHandler(&ioSlipTime);
- spatialdata::spatialdb::SimpleDB dbPeakRate("peak rate");
- spatialdata::spatialdb::SimpleIOAscii ioPeakRate;
- ioPeakRate.filename(data.peakRateFilename);
- dbPeakRate.ioHandler(&ioPeakRate);
+ spatialdata::spatialdb::SimpleDB dbRiseTime("rise time");
+ spatialdata::spatialdb::SimpleIOAscii ioRiseTime;
+ ioRiseTime.filename(data.riseTimeFilename);
+ dbRiseTime.ioHandler(&ioRiseTime);
- spatialdata::units::Nondimensional normalizer;
-
// setup BruneSlipFn
BruneSlipFn slipfn;
slipfn.dbFinalSlip(&dbFinalSlip);
slipfn.dbSlipTime(&dbSlipTime);
- slipfn.dbPeakRate(&dbPeakRate);
+ slipfn.dbRiseTime(&dbRiseTime);
+ spatialdata::units::Nondimensional normalizer;
const double originTime = 5.353;
- slipfn.initialize(faultMesh, &cs, normalizer, originTime);
+ slipfn.initialize(faultMesh, normalizer, originTime);
- const double tolerance = 1.0e-06;
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
- const ALE::Obj<Mesh::label_sequence>& vertices =
- faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ CPPUNIT_ASSERT(0 != slipfn._parameters);
+ const ALE::Obj<RealSection>& finalSlipSection =
+ slipfn._parameters->get("final slip").section();
+ CPPUNIT_ASSERT(!finalSlipSection.isNull());
+ const ALE::Obj<RealSection>& slipTimeSection =
+ slipfn._parameters->get("slip time").section();
+ CPPUNIT_ASSERT(!slipTimeSection.isNull());
+ const ALE::Obj<RealSection>& riseTimeSection =
+ slipfn._parameters->get("rise time").section();
+ CPPUNIT_ASSERT(!riseTimeSection.isNull());
+ const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveMesh::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+2, fiberDim);
-
- const real_section_type::value_type* vals =
- slipfn._parameters->restrictPoint(*v_iter);
- CPPUNIT_ASSERT(0 != vals);
-
+ CPPUNIT_ASSERT_EQUAL(spaceDim, finalSlipSection->getFiberDimension(*v_iter));
+ const double* finalSlipVertex = finalSlipSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != finalSlipVertex);
for (int iDim=0; iDim < spaceDim; ++iDim)
CPPUNIT_ASSERT_DOUBLES_EQUAL(data.finalSlipE[iPoint*spaceDim+iDim],
- vals[iDim],
+ finalSlipVertex[iDim],
tolerance);
- const double peakRate = vals[spaceDim ];
- const double slipTime = vals[spaceDim+1];
+ CPPUNIT_ASSERT_EQUAL(1, slipTimeSection->getFiberDimension(*v_iter));
+ const double* slipTimeVertex = slipTimeSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != slipTimeVertex);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipTimeE[iPoint]+originTime,
+ slipTimeVertex[0], tolerance);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(data.peakRateE[iPoint], peakRate, tolerance);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipTimeE[iPoint]+originTime,
- slipTime, tolerance);
+ CPPUNIT_ASSERT_EQUAL(1, riseTimeSection->getFiberDimension(*v_iter));
+ const double* riseTimeVertex = riseTimeSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != riseTimeVertex);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(data.riseTimeE[iPoint],
+ riseTimeVertex[0], tolerance);
} // for
} // _testInitialize
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestBruneSlipFn.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestBruneSlipFn.hh 2009-04-07 03:23:33 UTC (rev 14611)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestBruneSlipFn.hh 2009-04-07 05:03:16 UTC (rev 14612)
@@ -21,7 +21,8 @@
#if !defined(pylith_faults_testbruneslipfn_hh)
#define pylith_faults_testbruneslipfn_hh
-#include "pylith/utils/sievetypes.hh" // USES Mesh
+#include "pylith/faults/faultsfwd.hh" // USES BruneSlipFn
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, SubMesh
#include <cppunit/extensions/HelperMacros.h>
@@ -29,7 +30,6 @@
namespace pylith {
namespace faults {
class TestBruneSlipFn;
- class BruneSlipFn;
namespace _TestBruneSlipFn {
struct DataStruct;
@@ -47,7 +47,7 @@
CPPUNIT_TEST( testConstructor );
CPPUNIT_TEST( testDbFinalSlip );
CPPUNIT_TEST( testDbSlipTime );
- CPPUNIT_TEST( testDbPeakRate );
+ CPPUNIT_TEST( testDbRiseTime );
CPPUNIT_TEST( testInitialize1D );
CPPUNIT_TEST( testInitialize2D );
CPPUNIT_TEST( testInitialize3D );
@@ -69,8 +69,8 @@
/// Test dbSlipTime().
void testDbSlipTime(void);
- /// Test dbPeakRate().
- void testDbPeakRate(void);
+ /// Test dbRiseTime().
+ void testDbRiseTime(void);
/// Test initialize() in 1-D.
void testInitialize1D(void);
@@ -95,12 +95,14 @@
/** Initialize BruneSlipFn.
*
- * @param faultMesh Fault mesh.
- * @param slipfn Brune slip function.
+ * @param mesh Finite-element mesh of domain.
+ * @param faultMesh Finite-element mesh of fault.
+ * @param slipfn Step slip function.
* @param originTime Origin time for earthquake rupture.
*/
static
- void _initialize(ALE::Obj<Mesh>* faultMesh,
+ void _initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
BruneSlipFn* slipfn,
const double originTime);
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestConstRateSlipFn.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestConstRateSlipFn.cc 2009-04-07 03:23:33 UTC (rev 14611)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestConstRateSlipFn.cc 2009-04-07 05:03:16 UTC (rev 14612)
@@ -17,8 +17,11 @@
#include "pylith/faults/ConstRateSlipFn.hh" // USES ConstRateSlipFn
#include "pylith/faults/CohesiveTopology.hh" // USES CohesiveTopology
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
#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
@@ -48,6 +51,11 @@
} // pylith
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::SieveSubMesh SieveSubMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
// Test constructor.
void
pylith::faults::TestConstRateSlipFn::testConstructor(void)
@@ -183,35 +191,38 @@
const double slipTimeE[] = { 1.2, 1.3 };
const double originTime = 5.064;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
ConstRateSlipFn slipfn;
- _initialize(&faultMesh, &slipfn, originTime);
+ _initialize(&mesh, &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 spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
+ const int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
+
const double t = 1.234;
- slipfn.slip(slip, originTime+t, faultMesh);
+ slipfn.slip(&slip, originTime+t);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
const double t0 = slipTimeE[iPoint];
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim) {
@@ -232,36 +243,38 @@
const double slipTimeE[] = { 1.2, 1.3 };
const double originTime = 1.064;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
ConstRateSlipFn slipfn;
- _initialize(&faultMesh, &slipfn, originTime);
+ _initialize(&mesh, &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 spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
+ const int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
+
const double t0 = 1.234;
const double t1 = 3.635;
- slipfn.slipIncr(slip, originTime+t0, originTime+t1, faultMesh);
+ slipfn.slipIncr(&slip, originTime+t0, originTime+t1);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
-
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim) {
@@ -276,11 +289,14 @@
// ----------------------------------------------------------------------
// Initialize ConstRateSlipFn.
void
-pylith::faults::TestConstRateSlipFn::_initialize(ALE::Obj<Mesh>* faultMesh,
- ConstRateSlipFn* slipfn,
+pylith::faults::TestConstRateSlipFn::_initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
+ ConstRateSlipFn* slipfn,
const double originTime)
{ // _initialize
- assert(0 != slipfn);
+ CPPUNIT_ASSERT(0 != mesh);
+ CPPUNIT_ASSERT(0 != faultMesh);
+ CPPUNIT_ASSERT(0 != slipfn);
const char* meshFilename = "data/tri3.mesh";
const char* faultLabel = "fault";
@@ -288,33 +304,35 @@
const char* slipRateFilename = "data/tri3_sliprate.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();
+ meshIO.read(mesh);
+
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim(spaceDim);
+ cs.setSpaceDim(mesh->dimension());
+ cs.initialize();
+ mesh->coordsys(&cs);
// Create fault mesh
const bool useLagrangeConstraints = true;
- (*faultMesh) = new Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh> faultBd = NULL;
- CohesiveTopology::createFault(*faultMesh, faultBd,
- mesh,
- mesh->getIntSection(faultLabel));
- CohesiveTopology::create(*faultMesh, faultBd, mesh,
- mesh->getIntSection(faultLabel),
+ ALE::Obj<ALE::Mesh> faultBoundary = 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CohesiveTopology::createFault(faultMesh, faultBoundary,
+ *mesh, sieveMesh->getIntSection(faultLabel));
+ CohesiveTopology::create(mesh, *faultMesh, faultBoundary,
+ sieveMesh->getIntSection(faultLabel),
faultId,
useLagrangeConstraints);
- 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"));
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh->sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
// Setup databases
spatialdata::spatialdb::SimpleDB dbSlipRate("slip rate");
@@ -333,7 +351,7 @@
slipfn->dbSlipRate(&dbSlipRate);
slipfn->dbSlipTime(&dbSlipTime);
- slipfn->initialize(*faultMesh, &cs, normalizer, originTime);
+ slipfn->initialize(*faultMesh, normalizer, originTime);
} // _initialize
// ----------------------------------------------------------------------
@@ -344,33 +362,38 @@
typedef std::set<Mesh::point_type>::const_iterator vert_iterator;
// Setup mesh
- ALE::Obj<Mesh> mesh;
+ topology::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();
+
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
+ const int spaceDim = mesh.dimension();
cs.setSpaceDim(spaceDim);
+ cs.initialize();
+ mesh.coordsys(&cs);
// Create fault mesh
- ALE::Obj<Mesh> faultMesh = new Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh> faultBd = NULL;
+ topology::SubMesh faultMesh;
const bool useLagrangeConstraints = true;
- CohesiveTopology::createFault(faultMesh, faultBd,
- mesh,
- mesh->getIntSection(data.faultLabel));
- CohesiveTopology::create(faultMesh, faultBd, mesh,
- mesh->getIntSection(data.faultLabel),
+ ALE::Obj<ALE::Mesh> faultBoundary = 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CohesiveTopology::createFault(&faultMesh, faultBoundary,
+ mesh, sieveMesh->getIntSection(data.faultLabel));
+ CohesiveTopology::create(&mesh, faultMesh, faultBoundary,
+ sieveMesh->getIntSection(data.faultLabel),
data.faultId,
useLagrangeConstraints);
- 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"));
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
// Setup databases
spatialdata::spatialdb::SimpleDB dbSlipRate("slip rate");
@@ -389,37 +412,40 @@
slipfn.dbSlipTime(&dbSlipTime);
spatialdata::units::Nondimensional normalizer;
-
const double originTime = 5.353;
- slipfn.initialize(faultMesh, &cs, normalizer, originTime);
+ slipfn.initialize(faultMesh, normalizer, originTime);
- const double tolerance = 1.0e-06;
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
- const ALE::Obj<Mesh::label_sequence>& vertices =
- faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ CPPUNIT_ASSERT(0 != slipfn._parameters);
+ const ALE::Obj<RealSection>& slipRateSection =
+ slipfn._parameters->get("slip rate").section();
+ CPPUNIT_ASSERT(!slipRateSection.isNull());
+ const ALE::Obj<RealSection>& slipTimeSection =
+ slipfn._parameters->get("slip time").section();
+ CPPUNIT_ASSERT(!slipTimeSection.isNull());
+ const double tolerance = 1.0e-06;\
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveMesh::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);
-
+ CPPUNIT_ASSERT_EQUAL(spaceDim, slipRateSection->getFiberDimension(*v_iter));
+ const double* slipRateVertex = slipRateSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != slipRateVertex);
for (int iDim=0; iDim < spaceDim; ++iDim)
CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipRateE[iPoint*spaceDim+iDim],
- vals[iDim],
+ slipRateVertex[iDim],
tolerance);
- const double slipTime = vals[spaceDim];
-
+ CPPUNIT_ASSERT_EQUAL(1, slipTimeSection->getFiberDimension(*v_iter));
+ const double* slipTimeVertex = slipTimeSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != slipTimeVertex);
CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipTimeE[iPoint]+originTime,
- slipTime, tolerance);
+ slipTimeVertex[0], tolerance);
} // for
} // _testInitialize
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestConstRateSlipFn.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestConstRateSlipFn.hh 2009-04-07 03:23:33 UTC (rev 14611)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestConstRateSlipFn.hh 2009-04-07 05:03:16 UTC (rev 14612)
@@ -21,7 +21,8 @@
#if !defined(pylith_faults_testconstrateslipfn_hh)
#define pylith_faults_testconstrateslipfn_hh
-#include "pylith/utils/sievetypes.hh" // USES Mesh
+#include "pylith/faults/faultsfwd.hh" // USES ConstRateSlipFn
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, SubMesh
#include <cppunit/extensions/HelperMacros.h>
@@ -29,7 +30,6 @@
namespace pylith {
namespace faults {
class TestConstRateSlipFn;
- class ConstRateSlipFn;
namespace _TestConstRateSlipFn {
struct DataStruct;
@@ -87,12 +87,14 @@
/** Initialize ConstRateSlipFn.
*
- * @param faultMesh Fault mesh.
- * @param slipfn ConstRate slip function.
+ * @param mesh Finite-element mesh of domain.
+ * @param faultMesh Finite-element mesh of fault.
+ * @param slipfn Step slip function.
* @param originTime Origin time for earthquake rupture.
*/
static
- void _initialize(ALE::Obj<Mesh>* faultMesh,
+ void _initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
ConstRateSlipFn* slipfn,
const double originTime);
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestLiuCosSlipFn.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestLiuCosSlipFn.cc 2009-04-07 03:23:33 UTC (rev 14611)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestLiuCosSlipFn.cc 2009-04-07 05:03:16 UTC (rev 14612)
@@ -17,8 +17,11 @@
#include "pylith/faults/LiuCosSlipFn.hh" // USES LiuCosSlipFn
#include "pylith/faults/CohesiveTopology.hh" // USES CohesiveTopology
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
#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
@@ -29,6 +32,11 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::faults::TestLiuCosSlipFn );
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::SieveSubMesh SieveSubMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
namespace pylith {
namespace faults {
namespace _TestLiuCosSlipFn {
@@ -218,29 +226,32 @@
const double riseTimeE[] = { 1.4, 1.5 };
const double originTime = 5.064;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
LiuCosSlipFn slipfn;
- _initialize(&faultMesh, &slipfn, originTime);
+ _initialize(&mesh, &faultMesh, &slipfn, originTime);
- const int spaceDim = faultMesh->getDimension() + 1;
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
- 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 int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
const double t = 2.134;
- slipfn.slip(slip, originTime+t, faultMesh);
+ slipfn.slip(&slip, originTime+t);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
double slipMag = 0.0;
@@ -248,13 +259,13 @@
slipMag += pow(finalSlipE[iPoint*spaceDim+iDim], 2);
slipMag = sqrt(slipMag);
- const double slipNorm =
- _slipFn(t - slipTimeE[iPoint], slipMag, riseTimeE[iPoint]) / slipMag;
+ const double slipNorm = (slipMag > 0.0) ?
+ _slipFn(t - slipTimeE[iPoint], slipMag, riseTimeE[iPoint]) / slipMag :
+ 0.0;
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim) {
@@ -275,30 +286,33 @@
const double riseTimeE[] = { 1.4, 1.5 };
const double originTime = 1.064;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
LiuCosSlipFn slipfn;
- _initialize(&faultMesh, &slipfn, originTime);
+ _initialize(&mesh, &faultMesh, &slipfn, originTime);
- const int spaceDim = faultMesh->getDimension() + 1;
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
- 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 int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
const double t0 = 1.234;
const double t1 = 3.635;
- slipfn.slipIncr(slip, originTime+t0, originTime+t1, faultMesh);
+ slipfn.slipIncr(&slip, originTime+t0, originTime+t1);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
double slipMag = 0.0;
@@ -306,15 +320,16 @@
slipMag += pow(finalSlipE[iPoint*spaceDim+iDim], 2);
slipMag = sqrt(slipMag);
- const double slipNorm0 =
- _slipFn(t0 - slipTimeE[iPoint], slipMag, riseTimeE[iPoint]) / slipMag;
- const double slipNorm1 =
- _slipFn(t1 - slipTimeE[iPoint], slipMag, riseTimeE[iPoint]) / slipMag;
+ const double slipNorm0 = (slipMag > 0.0) ?
+ _slipFn(t0 - slipTimeE[iPoint], slipMag, riseTimeE[iPoint]) / slipMag :
+ 0.0;
+ const double slipNorm1 = (slipMag > 0.0) ?
+ _slipFn(t1 - slipTimeE[iPoint], slipMag, riseTimeE[iPoint]) / slipMag :
+ 0.0;
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim) {
@@ -351,9 +366,10 @@
// ----------------------------------------------------------------------
// Initialize LiuCosSlipFn.
void
-pylith::faults::TestLiuCosSlipFn::_initialize(ALE::Obj<Mesh>* faultMesh,
- LiuCosSlipFn* slipfn,
- const double originTime)
+pylith::faults::TestLiuCosSlipFn::_initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
+ LiuCosSlipFn* slipfn,
+ const double originTime)
{ // _initialize
assert(0 != slipfn);
@@ -364,33 +380,35 @@
const char* slipTimeFilename = "data/tri3_sliptime.spatialdb";
const char* riseTimeFilename = "data/tri3_risetime.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();
+ meshIO.read(mesh);
+
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim(spaceDim);
+ cs.setSpaceDim(mesh->dimension());
+ cs.initialize();
+ mesh->coordsys(&cs);
// Create fault mesh
const bool useLagrangeConstraints = true;
- (*faultMesh) = new Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh> faultBd = NULL;
- CohesiveTopology::createFault(*faultMesh, faultBd,
- mesh,
- mesh->getIntSection(faultLabel));
- CohesiveTopology::create(*faultMesh, faultBd, mesh,
- mesh->getIntSection(faultLabel),
+ ALE::Obj<ALE::Mesh> faultBoundary = 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CohesiveTopology::createFault(faultMesh, faultBoundary,
+ *mesh, sieveMesh->getIntSection(faultLabel));
+ CohesiveTopology::create(mesh, *faultMesh, faultBoundary,
+ sieveMesh->getIntSection(faultLabel),
faultId,
useLagrangeConstraints);
- 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"));
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh->sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
// Setup databases
spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
@@ -415,7 +433,7 @@
slipfn->dbSlipTime(&dbSlipTime);
slipfn->dbRiseTime(&dbRiseTime);
- slipfn->initialize(*faultMesh, &cs, normalizer, originTime);
+ slipfn->initialize(*faultMesh, normalizer, originTime);
} // _initialize
// ----------------------------------------------------------------------
@@ -426,33 +444,38 @@
typedef std::set<Mesh::point_type>::const_iterator vert_iterator;
// Setup mesh
- ALE::Obj<Mesh> mesh;
+ topology::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();
+
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
+ const int spaceDim = mesh.dimension();
cs.setSpaceDim(spaceDim);
+ cs.initialize();
+ mesh.coordsys(&cs);
// Create fault mesh
- ALE::Obj<Mesh> faultMesh = new Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh> faultBd = NULL;
+ topology::SubMesh faultMesh;
const bool useLagrangeConstraints = true;
- CohesiveTopology::createFault(faultMesh, faultBd,
- mesh,
- mesh->getIntSection(data.faultLabel));
- CohesiveTopology::create(faultMesh, faultBd, mesh,
- mesh->getIntSection(data.faultLabel),
+ ALE::Obj<ALE::Mesh> faultBoundary = 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CohesiveTopology::createFault(&faultMesh, faultBoundary,
+ mesh, sieveMesh->getIntSection(data.faultLabel));
+ CohesiveTopology::create(&mesh, faultMesh, faultBoundary,
+ sieveMesh->getIntSection(data.faultLabel),
data.faultId,
useLagrangeConstraints);
- 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"));
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
// Setup databases
spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
@@ -477,39 +500,49 @@
slipfn.dbRiseTime(&dbRiseTime);
spatialdata::units::Nondimensional normalizer;
-
const double originTime = 5.353;
- slipfn.initialize(faultMesh, &cs, normalizer, originTime);
+ slipfn.initialize(faultMesh, normalizer, originTime);
- const double tolerance = 1.0e-06;
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
- const ALE::Obj<Mesh::label_sequence>& vertices =
- faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ CPPUNIT_ASSERT(0 != slipfn._parameters);
+ const ALE::Obj<RealSection>& finalSlipSection =
+ slipfn._parameters->get("final slip").section();
+ CPPUNIT_ASSERT(!finalSlipSection.isNull());
+ const ALE::Obj<RealSection>& slipTimeSection =
+ slipfn._parameters->get("slip time").section();
+ CPPUNIT_ASSERT(!slipTimeSection.isNull());
+ const ALE::Obj<RealSection>& riseTimeSection =
+ slipfn._parameters->get("rise time").section();
+ CPPUNIT_ASSERT(!riseTimeSection.isNull());
+ const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveMesh::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+2, fiberDim);
-
- const real_section_type::value_type* vals =
- slipfn._parameters->restrictPoint(*v_iter);
- CPPUNIT_ASSERT(0 != vals);
-
+ CPPUNIT_ASSERT_EQUAL(spaceDim, finalSlipSection->getFiberDimension(*v_iter));
+ const double* finalSlipVertex = finalSlipSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != finalSlipVertex);
for (int iDim=0; iDim < spaceDim; ++iDim)
CPPUNIT_ASSERT_DOUBLES_EQUAL(data.finalSlipE[iPoint*spaceDim+iDim],
- vals[iDim],
+ finalSlipVertex[iDim],
tolerance);
- const double riseTime = vals[spaceDim ];
- const double slipTime = vals[spaceDim+1];
+ CPPUNIT_ASSERT_EQUAL(1, slipTimeSection->getFiberDimension(*v_iter));
+ const double* slipTimeVertex = slipTimeSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != slipTimeVertex);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipTimeE[iPoint]+originTime,
+ slipTimeVertex[0], tolerance);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(data.riseTimeE[iPoint], riseTime, tolerance);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipTimeE[iPoint]+originTime,
- slipTime, tolerance);
+ CPPUNIT_ASSERT_EQUAL(1, riseTimeSection->getFiberDimension(*v_iter));
+ const double* riseTimeVertex = riseTimeSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != riseTimeVertex);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(data.riseTimeE[iPoint],
+ riseTimeVertex[0], tolerance);
} // for
} // _testInitialize
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestLiuCosSlipFn.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestLiuCosSlipFn.hh 2009-04-07 03:23:33 UTC (rev 14611)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestLiuCosSlipFn.hh 2009-04-07 05:03:16 UTC (rev 14612)
@@ -21,7 +21,8 @@
#if !defined(pylith_faults_testliucosslipfn_hh)
#define pylith_faults_testliucosslipfn_hh
-#include "pylith/utils/sievetypes.hh" // USES Mesh
+#include "pylith/faults/faultsfwd.hh" // USES LiuCosSlipFn
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, SubMesh
#include <cppunit/extensions/HelperMacros.h>
@@ -29,7 +30,6 @@
namespace pylith {
namespace faults {
class TestLiuCosSlipFn;
- class LiuCosSlipFn;
namespace _TestLiuCosSlipFn {
struct DataStruct;
@@ -95,12 +95,14 @@
/** Initialize LiuCosSlipFn.
*
- * @param faultMesh Fault mesh.
- * @param slipfn LiuCos slip function.
+ * @param mesh Finite-element mesh of domain.
+ * @param faultMesh Finite-element mesh of fault.
+ * @param slipfn Step slip function.
* @param originTime Origin time for earthquake rupture.
*/
static
- void _initialize(ALE::Obj<Mesh>* faultMesh,
+ void _initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
LiuCosSlipFn* slipfn,
const double originTime);
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestStepSlipFn.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestStepSlipFn.cc 2009-04-07 03:23:33 UTC (rev 14611)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/TestStepSlipFn.cc 2009-04-07 05:03:16 UTC (rev 14612)
@@ -213,7 +213,6 @@
const double tolerance = 1.0e-06;
int iPoint = 0;
-
const ALE::Obj<RealSection>& slipSection = slip.section();
CPPUNIT_ASSERT(!slipSection.isNull());
for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
More information about the CIG-COMMITS
mailing list