[cig-commits] r14821 - in short/3D/PyLith/branches/pylith-swig: . libsrc/faults modulesrc/bc modulesrc/faults modulesrc/include modulesrc/topology pylith/faults pylith/meshio unittests/pytests/faults
brad at geodynamics.org
brad at geodynamics.org
Wed Apr 29 17:11:42 PDT 2009
Author: brad
Date: 2009-04-29 17:11:39 -0700 (Wed, 29 Apr 2009)
New Revision: 14821
Added:
short/3D/PyLith/branches/pylith-swig/modulesrc/include/eqkinsrcarray.i
short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestLiuCosSlipFn.py
Removed:
short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestFault.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestFaultCohesive.py
Modified:
short/3D/PyLith/branches/pylith-swig/TODO
short/3D/PyLith/branches/pylith-swig/libsrc/faults/Fault.hh
short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveDyn.cc
short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveDyn.hh
short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveKin.cc
short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveKin.hh
short/3D/PyLith/branches/pylith-swig/modulesrc/bc/AbsorbingDampers.i
short/3D/PyLith/branches/pylith-swig/modulesrc/bc/Neumann.i
short/3D/PyLith/branches/pylith-swig/modulesrc/bc/bc.i
short/3D/PyLith/branches/pylith-swig/modulesrc/faults/Fault.i
short/3D/PyLith/branches/pylith-swig/modulesrc/faults/FaultCohesiveDyn.i
short/3D/PyLith/branches/pylith-swig/modulesrc/faults/FaultCohesiveKin.i
short/3D/PyLith/branches/pylith-swig/modulesrc/faults/Makefile.am
short/3D/PyLith/branches/pylith-swig/modulesrc/faults/faults.i
short/3D/PyLith/branches/pylith-swig/modulesrc/topology/SubMesh.i
short/3D/PyLith/branches/pylith-swig/pylith/faults/BruneSlipFn.py
short/3D/PyLith/branches/pylith-swig/pylith/faults/ConstRateSlipFn.py
short/3D/PyLith/branches/pylith-swig/pylith/faults/EqKinSrc.py
short/3D/PyLith/branches/pylith-swig/pylith/faults/Fault.py
short/3D/PyLith/branches/pylith-swig/pylith/faults/FaultCohesive.py
short/3D/PyLith/branches/pylith-swig/pylith/faults/FaultCohesiveKin.py
short/3D/PyLith/branches/pylith-swig/pylith/faults/LiuCosSlipFn.py
short/3D/PyLith/branches/pylith-swig/pylith/faults/SingleRupture.py
short/3D/PyLith/branches/pylith-swig/pylith/faults/SlipTimeFn.py
short/3D/PyLith/branches/pylith-swig/pylith/faults/StepSlipFn.py
short/3D/PyLith/branches/pylith-swig/pylith/meshio/OutputFaultKin.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestBruneSlipFn.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestConstRateSlipFn.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestEqKinSrc.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestFaultCohesiveKin.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestStepSlipFn.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/testfaults.py
Log:
Worked on updating fault Python code and module.
Modified: short/3D/PyLith/branches/pylith-swig/TODO
===================================================================
--- short/3D/PyLith/branches/pylith-swig/TODO 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/TODO 2009-04-30 00:11:39 UTC (rev 14821)
@@ -43,6 +43,9 @@
FaultCohesiveKin
DataWriterVTK
+ pytests
+ test_configure
+
Switch Components to PetscComponents.
Add _cleanup() to components to deallocate local data structures.
Add cleanup() to non-components to deallocate local data structures.
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/faults/Fault.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/faults/Fault.hh 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/faults/Fault.hh 2009-04-30 00:11:39 UTC (rev 14821)
@@ -78,7 +78,7 @@
* @param mesh PETSc mesh
*/
virtual
- void adjustTopology(topology::Mesh* mesh,
+ void adjustTopology(topology::Mesh* const mesh,
const bool flipFault =false) = 0;
/** Initialize fault. Determine orientation and setup boundary
@@ -116,7 +116,7 @@
virtual
const topology::Field<topology::SubMesh>&
vertexField(const char* name,
- const topology::SolutionFields& fields) = 0;
+ const topology::SolutionFields* fields =0) = 0;
/** Get cell field associated with integrator.
*
@@ -127,7 +127,7 @@
virtual
const topology::Field<topology::SubMesh>&
cellField(const char* name,
- const topology::SolutionFields& fields) = 0;
+ const topology::SolutionFields* fields =0) = 0;
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveDyn.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveDyn.cc 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveDyn.cc 2009-04-30 00:11:39 UTC (rev 14821)
@@ -121,7 +121,7 @@
const pylith::topology::Field<pylith::topology::SubMesh>&
pylith::faults::FaultCohesiveDyn::vertexField(
const char* name,
- const topology::SolutionFields& fields)
+ const topology::SolutionFields* fields)
{ // vertexField
throw std::logic_error("FaultCohesiveDyn::vertexField() not implemented.");
} // vertexField
@@ -131,7 +131,7 @@
const pylith::topology::Field<pylith::topology::SubMesh>&
pylith::faults::FaultCohesiveDyn::cellField(
const char* name,
- const topology::SolutionFields& fields)
+ const topology::SolutionFields* fields)
{ // cellField
throw std::logic_error("FaultCohesiveDyn::vertexField() not implemented.");
} // cellField
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveDyn.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveDyn.hh 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveDyn.hh 2009-04-30 00:11:39 UTC (rev 14821)
@@ -100,7 +100,7 @@
*/
const topology::Field<topology::SubMesh>&
vertexField(const char* name,
- const topology::SolutionFields& fields);
+ const topology::SolutionFields* fields =0);
/** Get cell field associated with integrator.
*
@@ -111,7 +111,7 @@
*/
const topology::Field<topology::SubMesh>&
cellField(const char* name,
- const topology::SolutionFields& fields);
+ const topology::SolutionFields* fields =0);
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveKin.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveKin.cc 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveKin.cc 2009-04-30 00:11:39 UTC (rev 14821)
@@ -47,7 +47,9 @@
// ----------------------------------------------------------------------
// Default constructor.
pylith::faults::FaultCohesiveKin::FaultCohesiveKin(void) :
- _fields(0)
+ _fields(0),
+ _bufferVectorField(0),
+ _bufferScalarField(0)
{ // constructor
} // constructor
@@ -56,16 +58,21 @@
pylith::faults::FaultCohesiveKin::~FaultCohesiveKin(void)
{ // destructor
delete _fields; _fields = 0;
+ delete _bufferVectorField; _bufferVectorField = 0;
+ delete _bufferScalarField; _bufferScalarField = 0;
// :TODO: Use shared pointers for earthquake sources
} // destructor
// ----------------------------------------------------------------------
// Set kinematic earthquake source.
void
-pylith::faults::FaultCohesiveKin::eqsrcs(const char** names,
+pylith::faults::FaultCohesiveKin::eqsrcs(const char* const* names,
+ const int numNames,
EqKinSrc** sources,
const int numSources)
{ // eqsrcs
+ assert(numNames == numSources);
+
// :TODO: Use shared pointers for earthquake sources
_eqSrcs.clear();
for (int i=0; i < numSources; ++i) {
@@ -644,14 +651,13 @@
const pylith::topology::Field<pylith::topology::SubMesh>&
pylith::faults::FaultCohesiveKin::vertexField(
const char* name,
- const topology::SolutionFields& fields)
+ const topology::SolutionFields* fields)
{ // vertexField
#if 0
- assert(!_faultMesh.isNull());
- assert(!_orientation.isNull());
+ assert(0 != fields);
assert(0 != _normalizer);
- const int cohesiveDim = _faultMesh->getDimension();
+ const int cohesiveDim = _faultMesh.dimension();
const int spaceDim = _quadrature->spaceDim();
const int slipStrLen = strlen("final_slip");
@@ -660,17 +666,20 @@
double scale = 0.0;
int fiberDim = 0;
if (0 == strcasecmp("slip", name)) {
- *fieldType = VECTOR_FIELD;
- assert(!_cumSlip.isNull());
- _allocateBufferVertexVector();
- topology::FieldOps::copyValues(_bufferVertexVector, _cumSlip);
- _bufferTmp = _bufferVertexVector;
- scale = _normalizer->lengthScale();
- fiberDim = spaceDim;
+ const topology::Field<topology::SubMesh>& cumSlip =
+ fields->get("cumulative slip");
+ return cumSlip;
} else if (cohesiveDim > 0 && 0 == strcasecmp("strike_dir", name)) {
- *fieldType = VECTOR_FIELD;
- _bufferTmp = _orientation->getFibration(0);
+ const ALE::Obj<RealSection>& orientationSection =
+ fields->get("orientation").section();
+ assert(!orientationSection.isNull());
+ strikeSection = orientationSection->getFibration(0);
+ _allocateBufferVectorField();
+ assert(0 != _bufferVectorField);
+ const ALE::Obj<RealSection>& bufferSection =
+ _bufferVectorField->section();
+ bufferSection.values(strikeSection.values());
scale = 0.0;
fiberDim = spaceDim;
@@ -753,9 +762,8 @@
const pylith::topology::Field<pylith::topology::SubMesh>&
pylith::faults::FaultCohesiveKin::cellField(
const char* name,
- const topology::SolutionFields& fields)
+ const topology::SolutionFields* fields)
{ // cellField
-#if 0
// Should not reach this point if requested field was found
std::ostringstream msg;
msg << "Request for unknown cell field '" << name
@@ -763,8 +771,7 @@
throw std::runtime_error(msg.str());
// Return generic section to satisfy member function definition.
- //return _outputCellVector;
-#endif
+ return *_bufferVectorField;
} // cellField
// ----------------------------------------------------------------------
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveKin.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveKin.hh 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/faults/FaultCohesiveKin.hh 2009-04-30 00:11:39 UTC (rev 14821)
@@ -66,10 +66,12 @@
/** Set kinematic earthquake sources.
*
* @param names Array of kinematic earthquake source names.
+ * @param numNames Number of earthquake sources.
* @param sources Array of kinematic earthquake sources.
- * @param numSources Number of earthquake sources
+ * @param numSources Number of earthquake sources.
*/
- void eqsrcs(const char** names,
+ void eqsrcs(const char* const* names,
+ const int numNames,
EqKinSrc** sources,
const int numSources);
@@ -149,7 +151,7 @@
*/
const topology::Field<topology::SubMesh>&
vertexField(const char* name,
- const topology::SolutionFields& fields);
+ const topology::SolutionFields* fields =0);
/** Get cell field associated with integrator.
*
@@ -159,7 +161,7 @@
*/
const topology::Field<topology::SubMesh>&
cellField(const char* name,
- const topology::SolutionFields& fields);
+ const topology::SolutionFields* fields =0);
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
@@ -225,9 +227,16 @@
private :
srcs_type _eqSrcs; ///< Array of kinematic earthquake sources.
-
+
+ /// Fields for fault information.
topology::Fields<topology::Field<topology::SubMesh> >* _fields;
+ /// Buffer for vector field over fault vertices.
+ topology::Field<topology::SubMesh>* _bufferVectorField;
+
+ /// Buffer for scalar field over fault vertices.
+ topology::Field<topology::SubMesh>* _bufferScalarField;
+
/// Map label of cohesive cell to label of cells in fault mesh.
std::map<topology::Mesh::SieveMesh::point_type,
topology::SubMesh::SieveMesh::point_type> _cohesiveToFault;
Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/bc/AbsorbingDampers.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/bc/AbsorbingDampers.i 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/bc/AbsorbingDampers.i 2009-04-30 00:11:39 UTC (rev 14821)
@@ -15,8 +15,6 @@
* @brief Python interface to C++ AbsorbingDampers object.
*/
-%template(SubMeshIntegrator) pylith::feassemble::Integrator<pylith::feassemble::Quadrature<pylith::topology::SubMesh> >;
-
namespace pylith {
namespace bc {
Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/bc/Neumann.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/bc/Neumann.i 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/bc/Neumann.i 2009-04-30 00:11:39 UTC (rev 14821)
@@ -15,8 +15,6 @@
* @brief Python interface to C++ Neumann object.
*/
-%template(SubMeshIntegrator) pylith::feassemble::Integrator<pylith::feassemble::Quadrature<pylith::topology::SubMesh> >;
-
namespace pylith {
namespace bc {
Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/bc/bc.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/bc/bc.i 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/bc/bc.i 2009-04-30 00:11:39 UTC (rev 14821)
@@ -48,6 +48,9 @@
%include "../feassemble/Quadrature.i" // ISA Quadrature
%include "../feassemble/Integrator.i" // ISA Integrator
+// template instantiation
+%template(SubMeshIntegrator) pylith::feassemble::Integrator<pylith::feassemble::Quadrature<pylith::topology::SubMesh> >;
+
%include "BoundaryCondition.i"
%include "DirichletBC.i"
%include "DirichletBoundary.i"
Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/faults/Fault.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/faults/Fault.i 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/faults/Fault.i 2009-04-30 00:11:39 UTC (rev 14821)
@@ -60,7 +60,7 @@
* @param mesh PETSc mesh
*/
virtual
- void adjustTopology(pylith::topology::Mesh* mesh,
+ void adjustTopology(pylith::topology::Mesh* const mesh,
const bool flipFault =false) = 0;
/** Initialize fault. Determine orientation and setup boundary
@@ -98,7 +98,7 @@
virtual
const pylith::topology::Field<pylith::topology::SubMesh>&
vertexField(const char* name,
- const pylith::topology::SolutionFields& fields) = 0;
+ const pylith::topology::SolutionFields* fields =0) = 0;
/** Get cell field associated with integrator.
*
@@ -109,7 +109,7 @@
virtual
const pylith::topology::Field<pylith::topology::SubMesh>&
cellField(const char* name,
- const pylith::topology::SolutionFields& fields) = 0;
+ const pylith::topology::SolutionFields* fields =0) = 0;
}; // class Fault
Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/faults/FaultCohesiveDyn.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/faults/FaultCohesiveDyn.i 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/faults/FaultCohesiveDyn.i 2009-04-30 00:11:39 UTC (rev 14821)
@@ -86,7 +86,7 @@
*/
const pylith::topology::Field<pylith::topology::SubMesh>&
vertexField(const char* name,
- const pylith::topology::SolutionFields& fields);
+ const pylith::topology::SolutionFields* fields =0);
/** Get cell field associated with integrator.
*
@@ -97,8 +97,18 @@
*/
const pylith::topology::Field<pylith::topology::SubMesh>&
cellField(const char* name,
- const pylith::topology::SolutionFields& fields);
+ const pylith::topology::SolutionFields* fields =0);
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /** Cohesive cells use Lagrange multiplier constraints?
+ *
+ * @returns True if implementation using Lagrange multiplier
+ * constraints, false otherwise.
+ */
+ bool _useLagrangeConstraints(void) const;
+
}; // class FaultCohesiveDyn
} // faults
Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/faults/FaultCohesiveKin.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/faults/FaultCohesiveKin.i 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/faults/FaultCohesiveKin.i 2009-04-30 00:11:39 UTC (rev 14821)
@@ -35,10 +35,16 @@
/** Set kinematic earthquake sources.
*
* @param names Array of kinematic earthquake source names.
+ * @param numNames Number of earthquake sources.
* @param sources Array of kinematic earthquake sources.
- * @param numSources Number of earthquake sources
+ * @param numSources Number of earthquake sources.
*/
- void eqsrcs(const char** names,
+ %apply(const char* const* string_list, const int list_len){
+ (const char* const* names,
+ const int numNames)
+ };
+ void eqsrcs(const char* const* names,
+ const int numNames,
EqKinSrc** sources,
const int numSources);
@@ -118,7 +124,7 @@
*/
const pylith::topology::Field<pylith::topology::SubMesh>&
vertexField(const char* name,
- const pylith::topology::SolutionFields& fields);
+ const pylith::topology::SolutionFields* fields =0);
/** Get cell field associated with integrator.
*
@@ -128,8 +134,18 @@
*/
const pylith::topology::Field<pylith::topology::SubMesh>&
cellField(const char* name,
- const pylith::topology::SolutionFields& fields);
+ const pylith::topology::SolutionFields* fields =0);
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /** Cohesive cells use Lagrange multiplier constraints?
+ *
+ * @returns True if implementation using Lagrange multiplier
+ * constraints, false otherwise.
+ */
+ bool _useLagrangeConstraints(void) const;
+
}; // class FaultCohesiveKin
} // faults
Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/faults/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/faults/Makefile.am 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/faults/Makefile.am 2009-04-30 00:11:39 UTC (rev 14821)
@@ -29,6 +29,8 @@
FaultCohesive.i \
FaultCohesiveDyn.i \
FaultCohesiveKin.i \
+ ../topology/SubMesh.i \
+ ../feassemble/Quadrature.i \
../feassemble/Integrator.i
swig_generated = \
Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/faults/faults.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/faults/faults.i 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/faults/faults.i 2009-04-30 00:11:39 UTC (rev 14821)
@@ -25,6 +25,10 @@
#include "pylith/faults/FaultCohesive.hh"
#include "pylith/faults/FaultCohesiveDyn.hh"
#include "pylith/faults/FaultCohesiveKin.hh"
+
+#include "pylith/topology/SubMesh.hh"
+#include "pylith/feassemble/Quadrature.hh"
+#include "pylith/feassemble/Integrator.hh"
%}
%include "exception.i"
@@ -38,6 +42,8 @@
%include "typemaps.i"
%include "../include/doublearray.i"
+%include "../include/chararray.i"
+%include "../include/eqkinsrcarray.i"
// Numpy interface stuff
%{
@@ -49,9 +55,13 @@
%}
// Interfaces
-%include "../feassemble/Quadrature.i" // ISA Quadrature
-%include "../feassemble/Integrator.i" // ISA Integrator
+%include "../topology/SubMesh.i" // ISA Integrator<Quadrature<SubMesh> >
+%include "../feassemble/Quadrature.i" // ISA Integrator<Quadrature<SubMesh> >
+%include "../feassemble/Integrator.i" // ISA Integrator<Quadrature<SubMesh> >
+// Template instatiation
+%template(SubMeshIntegrator) pylith::feassemble::Integrator<pylith::feassemble::Quadrature<pylith::topology::SubMesh > >;
+
%include "SlipTimeFn.i"
%include "StepSlipFn.i"
%include "ConstRateSlipFn.i"
@@ -63,6 +73,5 @@
%include "FaultCohesiveDyn.i"
%include "FaultCohesiveKin.i"
-
// End of file
Added: short/3D/PyLith/branches/pylith-swig/modulesrc/include/eqkinsrcarray.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/include/eqkinsrcarray.i (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/include/eqkinsrcarray.i 2009-04-30 00:11:39 UTC (rev 14821)
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// ----------------------------------------------------------------------
+// List of earthquake sources.
+%typemap(in) (pylith::faults::EqKinSrc** sources,
+ const int numSources)
+{
+ // Check to make sure input is a list.
+ if (PyList_Check($input)) {
+ const int size = PyList_Size($input);
+ $2 = size;
+ $1 = (size > 0) ? new pylith::faults::EqKinSrc*[size] : 0;
+ for (int i = 0; i < size; i++) {
+ PyObject* s = PyList_GetItem($input,i);
+ pylith::faults::EqKinSrc** src = 0;
+ int err = SWIG_ConvertPtr(s, (void**) &src,
+ $descriptor(pylith::faults::EqKinSrc*),
+ 0);
+ if (SWIG_IsOK(err))
+ $1[i] = (pylith::faults::EqKinSrc*) src;
+ else {
+ PyErr_SetString(PyExc_TypeError,
+ "List must contain kinematic earthquake sources.");
+ delete[] $1;
+ return NULL;
+ } // if
+ } // for
+ } else {
+ PyErr_SetString(PyExc_TypeError,
+ "Expected list of kinematic earthquake sources.");
+ return NULL;
+ } // if/else
+} // typemap(in) [List of kinematic earthquake sources.]
+
+// This cleans up the array we malloc'd before the function call
+%typemap(freearg) (pylith::faults::EqKinsrc** sources,
+ const int numSources) {
+ delete[] $1;
+}
+
+
+// End of file
Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/topology/SubMesh.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/topology/SubMesh.i 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/topology/SubMesh.i 2009-04-30 00:11:39 UTC (rev 14821)
@@ -33,7 +33,7 @@
* @param mesh Finite-element mesh over domain.
* @param label Label for vertices marking boundary.
*/
- SubMesh(const Mesh& mesh,
+ SubMesh(const pylith::topology::Mesh& mesh,
const char* label);
/// Default destructor
@@ -44,7 +44,7 @@
* @param mesh Finite-element mesh over domain.
* @param label Label for vertices marking boundary.
*/
- void createSubMesh(const Mesh& mesh,
+ void createSubMesh(const pylith::topology::Mesh& mesh,
const char* label);
/** Get coordinate system.
Modified: short/3D/PyLith/branches/pylith-swig/pylith/faults/BruneSlipFn.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/faults/BruneSlipFn.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/pylith/faults/BruneSlipFn.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -18,49 +18,44 @@
## Factory: slip_time_fn
from SlipTimeFn import SlipTimeFn
+from faults import BruneSlipFn as ModuleBruneSlipFn
# BruneSlipFn class
-class BruneSlipFn(SlipTimeFn):
+class BruneSlipFn(SlipTimeFn, ModuleBruneSlipFn):
"""
Python object for slip time function that follows the integral of
Brune's (1970) far-field time function.
+ Inventory
+
+ \b Properties
+ @li None
+
+ \b Facilities
+ @li \b slip Spatial database of final slip
+ @li \b slip_time Spatial database of slip initiation time
+ @li \b rise_time Spatial database of rise time
+
Factory: slip_time_fn
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(SlipTimeFn.Inventory):
- """
- Python object for managing BruneSlipFn facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing BruneSlipFn 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
- ## @li \b slip_rate Spatial database of peak slip rate
+ import pyre.inventory
- import pyre.inventory
-
- from spatialdata.spatialdb.SimpleDB import SimpleDB
-
- slip = pyre.inventory.facility("slip", family="spatial_database",
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+
+ dbSlip = pyre.inventory.facility("slip", family="spatial_database",
factory=SimpleDB)
- slip.meta['tip'] = "Spatial database of slip."
-
- slipTime = pyre.inventory.facility("slip_time", family="spatial_database",
+ dbSlip.meta['tip'] = "Spatial database of slip."
+
+ dbSlipTime = pyre.inventory.facility("slip_time", family="spatial_database",
factory=SimpleDB)
- slipTime.meta['tip'] = "Spatial database of slip initiation time."
-
- slipRate = pyre.inventory.facility("slip_rate", family="spatial_database",
+ dbSlipTime.meta['tip'] = "Spatial database of slip initiation time."
+
+ dbRiseTime = pyre.inventory.facility("rise_time", family="spatial_database",
factory=SimpleDB)
- slipRate.meta['tip'] = "Spatial database of peak slip rate."
+ dbRiseTime.meta['tip'] = "Spatial database of rise time."
# PUBLIC METHODS /////////////////////////////////////////////////////
@@ -70,30 +65,11 @@
Constructor.
"""
SlipTimeFn.__init__(self, name)
+ ModuleBruneSlipFn.__init__(self)
self._loggingPrefix = "BrSF "
return
- def initialize(self):
- """
- Initialize.
- """
- logEvent = "%sinit" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- self.slip.initialize()
- self.slipTime.initialize()
- self.slipRate.initialize()
- assert(None != self.cppHandle)
-
- self.cppHandle.dbFinalSlip = self.slip.cppHandle
- self.cppHandle.dbSlipTime = self.slipTime.cppHandle
- self.cppHandle.dbPeakRate = self.slipRate.cppHandle
-
- self._logger.eventEnd(logEvent)
- return
-
-
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
@@ -101,22 +77,12 @@
Setup members using inventory.
"""
SlipTimeFn._configure(self)
- self.slip = self.inventory.slip
- self.slipTime = self.inventory.slipTime
- self.slipRate = self.inventory.slipRate
+ ModuleBruneSlipFn.dbFinalSlip(self, self.inventory.dbSlip)
+ ModuleBruneSlipFn.dbSlipTime(self, self.inventory.dbSlipTime)
+ ModuleBruneSlipFn.dbRiseTime(self, self.inventory.dbRiseTime)
return
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- if None == self.cppHandle:
- import pylith.faults.faults as bindings
- self.cppHandle = bindings.BruneSlipFn()
- return
-
-
# FACTORIES ////////////////////////////////////////////////////////////
def slip_time_fn():
Modified: short/3D/PyLith/branches/pylith-swig/pylith/faults/ConstRateSlipFn.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/faults/ConstRateSlipFn.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/pylith/faults/ConstRateSlipFn.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -17,43 +17,38 @@
## Factory: slip_time_fn
from SlipTimeFn import SlipTimeFn
+from faults import ConstRateSlipFn as ModuleConstRateSlipFn
# ConstRateSlipFn class
-class ConstRateSlipFn(SlipTimeFn):
+class ConstRateSlipFn(SlipTimeFn, ModuleConstRateSlipFn):
"""
Python object for a constant slip rate slip time function.
+ Inventory
+
+ \b Properties
+ @li None
+
+ \b Facilities
+ @li \b slip_rate Spatial database of slip rate
+ @li \b slip_time Spatial database of slip initiation time
+
Factory: slip_time_fn
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(SlipTimeFn.Inventory):
- """
- Python object for managing ConstRateSlipFn facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing ConstRateSlipFn facilities and properties.
- ##
- ## \b Properties
- ## @li None
- ##
- ## \b Facilities
- ## @li \b slip_rate Spatial database of slip rate
- ## @li \b slip_time Spatial database of slip initiation time
+ import pyre.inventory
- import pyre.inventory
-
- from spatialdata.spatialdb.SimpleDB import SimpleDB
-
- slipTime = pyre.inventory.facility("slip_time", family="spatial_database",
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+
+ dbSlipTime = pyre.inventory.facility("slip_time", family="spatial_database",
factory=SimpleDB)
- slipTime.meta['tip'] = "Spatial database of slip initiation time."
-
- slipRate = pyre.inventory.facility("slip_rate", family="spatial_database",
+ dbSlipTime.meta['tip'] = "Spatial database of slip initiation time."
+
+ dbSlipRate = pyre.inventory.facility("slip_rate", family="spatial_database",
factory=SimpleDB)
- slipRate.meta['tip'] = "Spatial database of slip rate."
+ dbSlipRate.meta['tip'] = "Spatial database of slip rate."
# PUBLIC METHODS /////////////////////////////////////////////////////
@@ -63,28 +58,11 @@
Constructor.
"""
SlipTimeFn.__init__(self, name)
+ ModuleConstRateSlipFn.__init__(self)
self._loggingPrefix = "CrSF "
return
- def initialize(self):
- """
- Initialize.
- """
- logEvent = "%sinit" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- self.slipRate.initialize()
- self.slipTime.initialize()
- assert(None != self.cppHandle)
-
- self.cppHandle.dbSlipRate = self.slipRate.cppHandle
- self.cppHandle.dbSlipTime = self.slipTime.cppHandle
-
- self._logger.eventEnd(logEvent)
- return
-
-
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
@@ -92,21 +70,11 @@
Setup members using inventory.
"""
SlipTimeFn._configure(self)
- self.slipRate = self.inventory.slipRate
- self.slipTime = self.inventory.slipTime
+ ModuleConstRateSlipFn.dbSlipRate(self, self.inventory.dbSlipRate)
+ ModuleConstRateSlipFn.dbSlipTime(self, self.inventory.dbSlipTime)
return
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- if None == self.cppHandle:
- import pylith.faults.faults as bindings
- self.cppHandle = bindings.ConstRateSlipFn()
- return
-
-
# FACTORIES ////////////////////////////////////////////////////////////
def slip_time_fn():
Modified: short/3D/PyLith/branches/pylith-swig/pylith/faults/EqKinSrc.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/faults/EqKinSrc.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/pylith/faults/EqKinSrc.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -21,52 +21,47 @@
##
## Factory: eq_kinematic_src
-from pyre.components.Component import Component
+from pylith.utils.PetscComponent import PetscComponent
+from faults import EqKinSrc as ModuleEqKinSrc
# EqKinSrc class
-class EqKinSrc(Component):
+class EqKinSrc(PetscComponent, ModuleEqKinSrc):
"""
Python object for managing parameters for a kinematic earthquake sources.
+ Inventory
+
+ \b Properties
+ @li \b origin_time Origin time for earthquake rupture.
+
+ \b Facilities
+ @li \b slip_function Slip time history function.
+
Factory: eq_kinematic_src
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(Component.Inventory):
- """
- Python object for managing EqKinSrc facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing EqKinSrc facilities and properties.
- ##
- ## \b Properties
- ## @li \b origin_time Origin time for earthquake rupture.
- ##
- ## \b Facilities
- ## @li \b slip_function Slip time history function.
+ import pyre.inventory
+
+ from pyre.units.time import second
+ originTime = pyre.inventory.dimensional("origin_time", default=0.0*second)
+ originTime.meta['tip'] = "Origin time for earthquake rupture."
+
+ from StepSlipFn import StepSlipFn
+ slipfn = pyre.inventory.facility("slip_function", family="slip_time_fn",
+ factory=StepSlipFn)
+ slipfn.meta['tip'] = "Slip time history function."
+
- import pyre.inventory
-
- from pyre.units.time import second
- originTime = pyre.inventory.dimensional("origin_time", default=0.0*second)
- originTime.meta['tip'] = "Origin time for earthquake rupture."
-
- from StepSlipFn import StepSlipFn
- slipfn = pyre.inventory.facility("slip_function", family="slip_time_fn",
- factory=StepSlipFn)
- slipfn.meta['tip'] = "Slip time history function."
-
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="eqkinsrc"):
"""
Constructor.
"""
- Component.__init__(self, name, facility="eqkinsrc")
- self.cppHandle = None
+ PetscComponent.__init__(self, name, facility="eqkinsrc")
+ self._createModuleObj()
self._loggingPrefix = "EqKi "
return
@@ -76,10 +71,7 @@
Do pre-initialization setup.
"""
self._setupLogging()
- self._createCppHandle()
- self.cppHandle.originTime = self.originTime.value
self.slipfn.preinitialize()
- self.cppHandle.slipfn = self.slipfn.cppHandle
return
@@ -115,19 +107,17 @@
"""
Setup members using inventory.
"""
- Component._configure(self)
- self.originTime = self.inventory.originTime
- self.slipfn = self.inventory.slipfn
+ PetscComponent._configure(self)
+ ModuleEqKinSrc.originTime(self, self.inventory.originTime.value)
+ ModuleEqKinSrc.slipfn(self, self.inventory.slipfn)
return
- def _createCppHandle(self):
+ def _createModuleObj(self):
"""
Create handle to corresponding C++ object.
"""
- if None == self.cppHandle:
- import pylith.faults.faults as bindings
- self.cppHandle = bindings.EqKinSrc()
+ ModuleEqKinSrc.__init__(self)
return
@@ -140,7 +130,7 @@
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("FE Constraint")
+ logger.className("Kinematic Earthquake Source")
logger.initialize()
events = ["verify",
Modified: short/3D/PyLith/branches/pylith-swig/pylith/faults/Fault.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/faults/Fault.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/pylith/faults/Fault.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -20,7 +20,8 @@
##
## Factory: fault
-from pyre.components.Component import Component
+from pylith.utils.PetscComponent import PetscComponent
+from faults import Fault as ModuleFault
# Validator for direction
def validateDir(value):
@@ -36,115 +37,91 @@
nums = map(float, value)
except:
raise ValueError(msg)
- return value
+ return nums
# Fault class
-class Fault(Component):
+class Fault(PetscComponent, ModuleFault):
"""
Python abstract base class for a fault surface.
This implementation of a fault associates both physical
properties and a quadrature scheme with the fault.
+ Inventory
+
+ \b Properties
+ @li \b id Fault identifier
+ @li \b name Name of fault
+ @li \b up_dir Up-dip or up direction
+ (perpendicular to along-strike and not collinear with fault normal;
+ only applies to fault surfaces in a 3-D domain).
+ @li \b normal_dir General preferred direction for fault normal
+ (used to pick which of two possible normal directions for
+ interface; only applies to fault surfaces in a 3-D domain).
+ @li \b mat_db Spatial database for bulk material properties
+ (used in improving conditioning of Jacobian matrix).
+
+ \b Facilities
+ @li \b quadrature Quadrature object for numerical integration
+
Factory: fault
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(Component.Inventory):
- """
- Python object for managing Fault facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing Fault facilities and properties.
- ##
- ## \b Properties
- ## @li \b id Fault identifier
- ## @li \b name Name of fault
- ## @li \b up_dir Up-dip or up direction
- ## (perpendicular to along-strike and not collinear with fault normal;
- ## only applies to fault surfaces in a 3-D domain).
- ## @li \b normal_dir General preferred direction for fault normal
- ## (used to pick which of two possible normal directions for
- ## interface; only applies to fault surfaces in a 3-D domain).
- ## @li \b mat_db Spatial database for bulk material properties
- ## (used in improving conditioning of Jacobian matrix).
- ##
- ## \b Facilities
- ## @li \b quadrature Quadrature object for numerical integration
+ import pyre.inventory
+
+ id = pyre.inventory.int("id", default=100)
+ id.meta['tip'] = "Fault identifier (must be unique across all faults " \
+ "and materials)."
+
+ label = pyre.inventory.str("label", default="")
+ label.meta['tip'] = "Name of fault."
+
+ upDir = pyre.inventory.list("up_dir", default=[0, 0, 1],
+ validator=validateDir)
+ upDir.meta['tip'] = "Up-dip or up direction " \
+ "(perpendicular to along-strike and not collinear " \
+ "with fault normal; only applies to fault surface " \
+ "in a 3-D domain)."
+
+ normalDir = pyre.inventory.list("normal_dir", default=[1, 0, 0],
+ validator=validateDir)
+ normalDir.meta['tip'] = "General preferred direction for fault normal " \
+ "(used to pick which of two possible normal directions for " \
+ "interface; only applies to fault surfaces in a 3-D domain)."
+
+ from pylith.feassemble.Quadrature import SubMeshQuadrature
+ quadrature = pyre.inventory.facility("quadrature", factory=SubMeshQuadrature)
+ quadrature.meta['tip'] = "Quadrature object for numerical integration."
+
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+ matDB = pyre.inventory.facility("mat_db", family="spatial_database",
+ factory=SimpleDB)
+ matDB.meta['tip'] = "Spatial database for bulk material properties " \
+ "(used in improving conditioning of Jacobian matrix)."
- import pyre.inventory
-
- id = pyre.inventory.int("id", default=100)
- id.meta['tip'] = "Fault identifier (must be unique across all faults " \
- "and materials)."
-
- label = pyre.inventory.str("label", default="")
- label.meta['tip'] = "Name of fault."
-
- upDir = pyre.inventory.list("up_dir", default=[0, 0, 1],
- validator=validateDir)
- upDir.meta['tip'] = "Up-dip or up direction " \
- "(perpendicular to along-strike and not collinear " \
- "with fault normal; only applies to fault surface " \
- "in a 3-D domain)."
-
- normalDir = pyre.inventory.list("normal_dir", default=[1, 0, 0],
- validator=validateDir)
- normalDir.meta['tip'] = "General preferred direction for fault normal " \
- "(used to pick which of two possible normal directions for " \
- "interface; only applies to fault surfaces in a 3-D domain)."
-
- from pylith.feassemble.quadrature.Quadrature import Quadrature
- quadrature = pyre.inventory.facility("quadrature", factory=Quadrature)
- quadrature.meta['tip'] = "Quadrature object for numerical integration."
-
- from spatialdata.spatialdb.SimpleDB import SimpleDB
- matDB = pyre.inventory.facility("mat_db", family="spatial_database",
- factory=SimpleDB)
- matDB.meta['tip'] = "Spatial database for bulk material properties " \
- "(used in improving conditioning of Jacobian matrix)."
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="fault"):
"""
Constructor.
"""
- Component.__init__(self, name, facility="fault")
- self.cppHandle = None
+ PetscComponent.__init__(self, name, facility="fault")
+ self._createModuleObj()
self.mesh = None
self.output = None
return
- def adjustTopology(self, mesh):
- """
- Adjust mesh topology for fault implementation.
- """
- self._createCppHandle()
-
- assert(None != self.cppHandle)
- self.cppHandle.id = self.id
- self.cppHandle.label = self.label
- self.cppHandle.adjustTopology(mesh.cppHandle)
- return
-
-
def preinitialize(self, mesh):
"""
Setup fault.
"""
- self._createCppHandle()
- self.cppHandle.id = self.id
- self.cppHandle.label = self.label
-
self.mesh = mesh
- self.quadrature.preinitialize()
- self.cppHandle.quadrature = self.quadrature.cppHandle
+ self.faultQuadrature.preinitialize(mesh.coordsys().spaceDim())
if None != self.output:
self.output.preinitialize(self)
@@ -160,15 +137,12 @@
self._logger.eventBegin(logEvent)
faultDim = self.mesh.dimension() - 1
- if faultDim != self.quadrature.cell.cellDim:
+ if faultDim != self.faultQuadrature.cell.cellDim:
raise ValueError, \
"Quadrature is incompatible with fault surface.\n" \
"Dimensions for quadrature: %d, dimensions of fault: %d" % \
- (self.quadrature.cell.cellDim, faultDim)
+ (self.faultQuadrature.cell.cellDim, faultDim)
- assert(None != self.cppHandle)
- self.cppHandle.verifyConfiguration(self.mesh.cppHandle)
-
if None != self.output:
self.output.verifyConfiguration(self.mesh)
@@ -183,21 +157,12 @@
logEvent = "%sinit" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- self.quadrature.initialize()
- self.matDB.initialize()
+ self.faultQuadrature.initialize()
+ ModuleFault.initialize(self,
+ self.mesh, self.upDir, self.normalDir, self.matDB)
- assert(None != self.cppHandle)
- self.cppHandle.initialize(self.mesh.cppHandle,
- self.mesh.coordsys.cppHandle,
- self.upDir, self.normalDir,
- self.matDB.cppHandle)
- from pylith.topology.Mesh import Mesh
- self.faultMesh = Mesh()
- self.faultMesh.initialize(self.mesh.coordsys)
- self.cppHandle.faultMesh(self.faultMesh.cppHandle)
-
if None != self.output:
- self.output.initialize(normalizer, self.quadrature)
+ self.output.initialize(normalizer, self.faultQuadrature)
self.output.writeInfo()
self.output.open(totalTime, numTimeSteps)
@@ -223,7 +188,7 @@
"""
Get mesh associated with data fields.
"""
- return (self.faultMesh, None, None)
+ return (self.faultMesh(), None, None)
def getVertexField(self, name, fields=None):
@@ -248,21 +213,21 @@
"""
Setup members using inventory.
"""
- Component._configure(self)
- self.id = self.inventory.id
- self.label = self.inventory.label
+ PetscComponent._configure(self)
+ self.faultQuadrature = self.inventory.quadrature
self.upDir = map(float, self.inventory.upDir)
self.normalDir = map(float, self.inventory.normalDir)
- self.quadrature = self.inventory.quadrature
self.matDB = self.inventory.matDB
+ ModuleFault.id(self, self.inventory.id)
+ ModuleFault.label(self, self.inventory.label)
return
- def _createCppHandle(self):
+ def _createModuleObj(self):
"""
Create handle to corresponding C++ object.
"""
- raise NotImplementedError("Please implement _createCppHandle() in " \
+ raise NotImplementedError("Please implement _createModuleObj() in " \
"derived class.")
Modified: short/3D/PyLith/branches/pylith-swig/pylith/faults/FaultCohesive.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/faults/FaultCohesive.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/pylith/faults/FaultCohesive.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -19,52 +19,50 @@
## Factory: fault
from Fault import Fault
+from faults import FaultCohesive as ModuleFaultCohesive
# FaultCohesive class
-class FaultCohesive(Fault):
+class FaultCohesive(Fault, ModuleFaultCohesive):
"""
Python abstract base class for a fault surface implemeted with
cohesive elements.
+ Inventory
+
+ @class Inventory
+ Python object for managing FaultCohesive facilities and properties.
+
+ \b Properties
+ @li \b use_fault_mesh If true, use fault mesh to define fault;
+ otherwise, use group of vertices to define fault.
+
+ \b Facilities
+ @li \b fault_mesh_importer Importer for fault mesh.
+
Factory: fault
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(Fault.Inventory):
- """
- Python object for managing FaultCohesive facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing FaultCohesive facilities and properties.
- ##
- ## \b Properties
- ## @li \b use_fault_mesh If true, use fault mesh to define fault;
- ## otherwise, use group of vertices to define fault.
- ##
- ## \b Facilities
- ## @li \b fault_mesh_importer Importer for fault mesh.
+ import pyre.inventory
- import pyre.inventory
+ useFaultMesh = pyre.inventory.bool("use_fault_mesh", default=False)
+ useFaultMesh.meta['tip'] = "If true, use fault mesh to define fault; " \
+ "otherwise, use group of vertices to define fault."
- useFaultMesh = pyre.inventory.bool("use_fault_mesh", default=False)
- useFaultMesh.meta['tip'] = "If true, use fault mesh to define fault; " \
- "otherwise, use group of vertices to define fault."
+ # Future, improved implementation
+ #from pylith.meshio.MeshIOAscii imoport MeshIOAscii
+ #faultMeshImporter = pyre.inventory.facility("fault_mesh_importer",
+ # factory=MeshIOLagrit,
+ # family="mesh_io")
+ #faultMeshImporter.meta['tip'] = "Importer for fault mesh."
- # Future, improved implementation
- #from pylith.meshio.MeshIOAscii imoport MeshIOAscii
- #faultMeshImporter = pyre.inventory.facility("fault_mesh_importer",
- # factory=MeshIOLagrit,
- # family="mesh_io")
- #faultMeshImporter.meta['tip'] = "Importer for fault mesh."
+ # Current kludge
+ faultMeshFilename = pyre.inventory.str("fault_mesh_filename",
+ default="fault.inp")
+ faultMeshFilename.meta['tip'] = "Filename for fault mesh UCD file."
- # Current kludge
- faultMeshFilename = pyre.inventory.str("fault_mesh_filename",
- default="fault.inp")
- faultMeshFilename.meta['tip'] = "Filename for fault mesh UCD file."
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="faultcohesive"):
@@ -75,20 +73,6 @@
return
- def adjustTopology(self, mesh):
- """
- Adjust mesh topology for fault implementation.
- """
- self._createCppHandle()
- assert(None != self.cppHandle)
- self.cppHandle.useFaultMesh = self.useFaultMesh
- #self.cppHandle.faultMeshImporter = self.faultMeshImporter.cppHandle
- self.cppHandle.faultMeshFilename = self.faultMeshFilename # TEMPORARY
-
- Fault.adjustTopology(self, mesh)
- return
-
-
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
@@ -96,9 +80,12 @@
Setup members using inventory.
"""
Fault._configure(self)
- self.useFaultMesh = self.inventory.useFaultMesh
- #self.faultMeshImporter = self.inventory.faultMeshImporter
- self.faultMeshFilename = self.inventory.faultMeshFilename # TEMPORARY
+ ModuleFaultCohesive.useFaultMesh(self, self.inventory.useFaultMesh)
+ #ModuleFaultCohesive.faultMeshImporter(self,
+ # self.inventory.faultMeshImporter)
+ # TEMPORARY
+ ModuleFaultCohesive.faultMeshFilename(self,
+ self.inventory.faultMeshFilename)
return
Modified: short/3D/PyLith/branches/pylith-swig/pylith/faults/FaultCohesiveKin.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/faults/FaultCohesiveKin.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/pylith/faults/FaultCohesiveKin.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -20,6 +20,7 @@
from FaultCohesive import FaultCohesive
from pylith.feassemble.Integrator import Integrator
+from faults import FaultCohesiveKin as ModuleFaultCohesiveKin
# ITEM FACTORIES ///////////////////////////////////////////////////////
@@ -33,45 +34,41 @@
# FaultCohesiveKin class
-class FaultCohesiveKin(FaultCohesive, Integrator):
+class FaultCohesiveKin(FaultCohesive, Integrator, ModuleFaultCohesiveKin):
"""
Python object for a fault surface with kinematic (prescribed) slip
implemented with cohesive elements.
+ Inventory
+
+ @class Inventory
+ Python object for managing FaultCohesiveKin facilities and properties.
+
+ \b Properties
+ @li None
+
+ \b Facilities
+ @li \b eq_srcs Kinematic earthquake sources information.
+ @li \b output Output manager associated with fault data.
+
Factory: fault
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(FaultCohesive.Inventory):
- """
- Python object for managing FaultCohesiveKin facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing FaultCohesiveKin facilities and properties.
- ##
- ## \b Properties
- ## @li None
- ##
- ## \b Facilities
- ## @li \b eq_srcs Kinematic earthquake sources information.
- ## @li \b output Output manager associated with fault data.
+ import pyre.inventory
- import pyre.inventory
+ from SingleRupture import SingleRupture
+ eqsrcs = pyre.inventory.facilityArray("eq_srcs", itemFactory=eqsrcFactory,
+ factory=SingleRupture)
+ eqsrcs.meta['tip'] = "Kinematic earthquake sources information."
+
+ from pylith.meshio.OutputFaultKin import OutputFaultKin
+ output = pyre.inventory.facility("output", family="output_manager",
+ factory=OutputFaultKin)
+ output.meta['tip'] = "Output manager associated with fault data."
+
- from SingleRupture import SingleRupture
- eqsrcs = pyre.inventory.facilityArray("eq_srcs", itemFactory=eqsrcFactory,
- factory=SingleRupture)
- eqsrcs.meta['tip'] = "Kinematic earthquake sources information."
-
- from pylith.meshio.OutputFaultKin import OutputFaultKin
- output = pyre.inventory.facility("output", family="output_manager",
- factory=OutputFaultKin)
- output.meta['tip'] = "Output manager associated with fault data."
-
-
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="faultcohesivekin"):
@@ -102,11 +99,13 @@
self._info.log("Pre-initializing fault '%s'." % self.label)
FaultCohesive.preinitialize(self, mesh)
Integrator.preinitialize(self, mesh)
- assert(None != self.cppHandle)
+
+ ModuleFaultCohesiveKin.quadrature(self, self.faultQuadrature)
+
for eqsrc in self.eqsrcs.components():
eqsrc.preinitialize()
- self.cppHandle.eqsrcs(self.eqsrcs.inventory.facilityNames(),
- self.eqsrcs.components())
+ ModuleFaultCohesiveKin.eqsrcs(self, self.eqsrcs.inventory.facilityNames(),
+ self.eqsrcs.components())
for name in self.eqsrcs.inventory.facilityNames():
self.availableFields['vertex']['info'] += ["final_slip_%s" % name]
@@ -129,6 +128,8 @@
FaultCohesive.verifyConfiguration(self)
Integrator.verifyConfiguration(self)
+ ModuleFaultCohesiveKin.verifyConfiguration(self, self.mesh)
+
for eqsrc in self.eqsrcs.components():
eqsrc.verifyConfiguration()
@@ -173,13 +174,10 @@
Get vertex field.
"""
if None == fields:
- (field, fieldType) = self.cppHandle.vertexField(name,
- self.mesh.cppHandle)
+ field = ModuleFaultCohesiveKin.vertexField(name)
else:
- (field, fieldType) = self.cppHandle.vertexField(name,
- self.mesh.cppHandle,
- fields.cppHandle)
- return (field, fieldType)
+ field = ModuleFaultCohesiveKin.vertexField(name, fields)
+ return field
def getCellField(self, name, fields=None):
@@ -187,11 +185,10 @@
Get cell field.
"""
if None == fields:
- (field, fieldType) = self.cppHandle.cellField(name, self.mesh.cppHandle)
+ field = ModuleFaultCohesiveKin.cellField(name)
else:
- (field, fieldType) = self.cppHandle.cellField(name, self.mesh.cppHandle,
- fields.cppHandle)
- return (field, fieldType)
+ field = ModuleFaultCohesiveKin.cellField(name, fields)
+ return field
# PRIVATE METHODS ////////////////////////////////////////////////////
@@ -206,13 +203,11 @@
return
- def _createCppHandle(self):
+ def _createModuleObj(self):
"""
Create handle to C++ FaultCohesiveKin.
"""
- if None == self.cppHandle:
- import pylith.faults.faults as bindings
- self.cppHandle = bindings.FaultCohesiveKin()
+ ModuleFaultCohesiveKin.__init__(self)
return
Modified: short/3D/PyLith/branches/pylith-swig/pylith/faults/LiuCosSlipFn.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/faults/LiuCosSlipFn.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/pylith/faults/LiuCosSlipFn.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -19,50 +19,45 @@
## Factory: slip_time_fn
from SlipTimeFn import SlipTimeFn
+from faults import LiuCosSlipFn as ModuleLiuCosSlipFn
# LiuCosSlipFn class
-class LiuCosSlipFn(SlipTimeFn):
+class LiuCosSlipFn(SlipTimeFn, ModuleLiuCosSlipFn):
"""
Sine/cosine slip time function from Liu, Archuleta, and Hartzell,
BSSA, 2006 (doi:10.1785/0120060036) which has a rapid rise and then
a gradual falloff with a finite duration.
+ Inventory
+
+ \b Properties
+ @li None
+
+ \b Facilities
+ @li \b slip Spatial database of final slip.
+ @li \b slip_time Spatial database of slip initiation time.
+ @li \b rise_time Spatial database of rise time (t95).
+
Factory: slip_time_fn
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(SlipTimeFn.Inventory):
- """
- Python object for managing LiuCosSlipFn facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing LiuCosSlipFn 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.
- ## @li \b rise_time Spatial database of rise time (t95).
-
- import pyre.inventory
-
- from spatialdata.spatialdb.SimpleDB import SimpleDB
-
- slip = pyre.inventory.facility("slip", family="spatial_database",
+ import pyre.inventory
+
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+
+ dbSlip = pyre.inventory.facility("slip", family="spatial_database",
factory=SimpleDB)
- slip.meta['tip'] = "Spatial database of slip."
-
- slipTime = pyre.inventory.facility("slip_time", family="spatial_database",
+ dbSlip.meta['tip'] = "Spatial database of slip."
+
+ dbSlipTime = pyre.inventory.facility("slip_time", family="spatial_database",
factory=SimpleDB)
- slipTime.meta['tip'] = "Spatial database of slip initiation time."
-
- riseTime = pyre.inventory.facility("rise_time", family="spatial_database",
+ dbSlipTime.meta['tip'] = "Spatial database of slip initiation time."
+
+ dbRiseTime = pyre.inventory.facility("rise_time", family="spatial_database",
factory=SimpleDB)
- riseTime.meta['tip'] = "Spatial database of rise time (t95)."
+ dbRiseTime.meta['tip'] = "Spatial database of rise time (t95)."
# PUBLIC METHODS /////////////////////////////////////////////////////
@@ -72,30 +67,11 @@
Constructor.
"""
SlipTimeFn.__init__(self, name)
+ ModuleLiuCosSlipFn.__init__(self)
self._loggingPrefix = "BrSF "
return
- def initialize(self):
- """
- Initialize.
- """
- logEvent = "%sinit" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- self.slip.initialize()
- self.slipTime.initialize()
- self.riseTime.initialize()
- assert(None != self.cppHandle)
-
- self.cppHandle.dbFinalSlip = self.slip.cppHandle
- self.cppHandle.dbSlipTime = self.slipTime.cppHandle
- self.cppHandle.dbRiseTime = self.riseTime.cppHandle
-
- self._logger.eventEnd(logEvent)
- return
-
-
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
@@ -103,22 +79,12 @@
Setup members using inventory.
"""
SlipTimeFn._configure(self)
- self.slip = self.inventory.slip
- self.slipTime = self.inventory.slipTime
- self.riseTime = self.inventory.riseTime
+ ModuleLiuCosSlipFn.dbFinalSlip(self, self.inventory.dbSlip)
+ ModuleLiuCosSlipFn.dbSlipTime(self, self.inventory.dbSlipTime)
+ ModuleLiuCosSlipFn.dbRiseTime(self, self.inventory.dbRiseTime)
return
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- if None == self.cppHandle:
- import pylith.faults.faults as bindings
- self.cppHandle = bindings.LiuCosSlipFn()
- return
-
-
# FACTORIES ////////////////////////////////////////////////////////////
def slip_time_fn():
Modified: short/3D/PyLith/branches/pylith-swig/pylith/faults/SingleRupture.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/faults/SingleRupture.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/pylith/faults/SingleRupture.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -14,45 +14,43 @@
##
## @brief Python kinematic rupture container with one rupture.
-from pyre.components.Component import Component
+from pylith.utils.PetscComponent import PetscComponent
# SingleRupture class
-class SingleRupture(Component):
+class SingleRupture(PetscComponent):
"""
Python kinematic rupture container with one rupture.
+
+ Inventory
+
+ @class Inventory
+ Python object for managing SingleRupture facilities and properties.
+
+ \b Properties
+ @li None
+
+ \b Facilities
+ @li \b rupture Kinematic earthquake rupture in problem
+
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(Component.Inventory):
- """
- Python object for managing SingleRupture facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing SingleRupture facilities and properties.
- ##
- ## \b Properties
- ## @li None
- ##
- ## \b Facilities
- ## @li \b rupture Kinematic earthquake rupture in problem
+ import pyre.inventory
- import pyre.inventory
+ from EqKinSrc import EqKinSrc
+ rupture = pyre.inventory.facility("rupture", family="eq_kinematic_src",
+ factory=EqKinSrc)
+ rupture.meta['tip'] = "Kinematic earthquake rupture in problem."
- from EqKinSrc import EqKinSrc
- rupture = pyre.inventory.facility("rupture", family="eq_kinematic_src",
- factory=EqKinSrc)
- rupture.meta['tip'] = "Kinematic earthquake rupture in problem."
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="singlerupture"):
"""
Constructor.
"""
- Component.__init__(self, name)
+ PetscComponent.__init__(self, name, facility="rupture")
return
Modified: short/3D/PyLith/branches/pylith-swig/pylith/faults/SlipTimeFn.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/faults/SlipTimeFn.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/pylith/faults/SlipTimeFn.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -34,7 +34,6 @@
Constructor.
"""
Component.__init__(self, name, facility="sliptimefn")
- self.cppHandle = None
return
@@ -43,7 +42,6 @@
Do pre-initialization setup.
"""
self._setupLogging()
- self._createCppHandle()
return
@@ -79,14 +77,6 @@
return
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- raise NotImplementedError("Please implement _createCppHandle().")
- return
-
-
def _setupLogging(self):
"""
Setup event logging.
@@ -96,7 +86,7 @@
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("FE Constraint")
+ logger.className("Slip Time Function")
logger.initialize()
events = ["verify",
Modified: short/3D/PyLith/branches/pylith-swig/pylith/faults/StepSlipFn.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/faults/StepSlipFn.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/pylith/faults/StepSlipFn.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -17,43 +17,38 @@
## Factory: slip_time_fn
from SlipTimeFn import SlipTimeFn
+from faults import StepSlipFn as ModuleStepSlipFn
# StepSlipFn class
-class StepSlipFn(SlipTimeFn):
+class StepSlipFn(SlipTimeFn, ModuleStepSlipFn):
"""
Python object for a step-function slip time function.
+ Inventory
+
+ \b Properties
+ @li None
+
+ \b Facilities
+ @li \b slip Spatial database of final slip.
+ @li \b slip_time Spatial database of slip initiation time.
+
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
- import pyre.inventory
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
- 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",
+ dbSlipTime = pyre.inventory.facility("slip_time", family="spatial_database",
+ factory=SimpleDB)
+ dbSlipTime.meta['tip'] = "Spatial database of slip initiation time."
+
+ dbSlip = pyre.inventory.facility("slip", family="spatial_database",
factory=SimpleDB)
- slip.meta['tip'] = "Spatial database of final slip."
+ dbSlip.meta['tip'] = "Spatial database of final slip."
# PUBLIC METHODS /////////////////////////////////////////////////////
@@ -63,28 +58,11 @@
Constructor.
"""
SlipTimeFn.__init__(self, name)
+ ModuleStepSlipFn.__init__(self)
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):
@@ -92,21 +70,11 @@
Setup members using inventory.
"""
SlipTimeFn._configure(self)
- self.slip = self.inventory.slip
- self.slipTime = self.inventory.slipTime
+ ModuleStepSlipFn.dbSlipTime(self, self.inventory.dbSlipTime)
+ ModuleStepSlipFn.dbFinalSlip(self, self.inventory.dbSlip)
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():
Modified: short/3D/PyLith/branches/pylith-swig/pylith/meshio/OutputFaultKin.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/meshio/OutputFaultKin.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/pylith/meshio/OutputFaultKin.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -17,7 +17,7 @@
##
## Factory: output_manager
-from OutputManager import OutputManagerSubMesh
+from OutputManagerSubMesh import OutputManagerSubMesh
# OutputFaultKin class
class OutputFaultKin(OutputManagerSubMesh):
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestBruneSlipFn.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestBruneSlipFn.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestBruneSlipFn.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -29,11 +29,18 @@
Test constructor.
"""
slipFn = BruneSlipFn()
- slipFn._createCppHandle()
- self.failIfEqual(None, slipFn.cppHandle)
return
+ def test_configure(self):
+ """
+ Test constructor.
+ """
+ slipFn = BruneSlipFn()
+ slipFn._configure()
+ return
+
+
def test_initialize(self):
"""
Test initialize().
@@ -42,28 +49,36 @@
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
ioFinalSlip = SimpleIOAscii()
- ioFinalSlip.filename = "finalslip.spatialdb"
+ ioFinalSlip.inventory.filename = "finalslip.spatialdb"
+ ioFinalSlip._configure()
dbFinalSlip = SimpleDB()
- dbFinalSlip.iohandler = ioFinalSlip
- dbFinalSlip.label = "final slip"
+ dbFinalSlip.inventory.iohandler = ioFinalSlip
+ dbFinalSlip.inventory.label = "final slip"
+ dbFinalSlip._configure()
ioSlipTime = SimpleIOAscii()
- ioSlipTime.filename = "sliptime.spatialdb"
+ ioSlipTime.inventory.filename = "sliptime.spatialdb"
+ ioSlipTime._configure()
dbSlipTime = SimpleDB()
- dbSlipTime.iohandler = ioSlipTime
- dbSlipTime.label = "slip time"
+ dbSlipTime.inventory.iohandler = ioSlipTime
+ dbSlipTime.inventory.label = "slip time"
+ dbSlipTime._configure()
- ioPeakRate = SimpleIOAscii()
- ioPeakRate.filename = "peakrate.spatialdb"
- dbPeakRate = SimpleDB()
- dbPeakRate.iohandler = ioPeakRate
- dbPeakRate.label = "peak rate"
+ ioRiseTime = SimpleIOAscii()
+ ioRiseTime.inventory.filename = "risetime.spatialdb"
+ ioRiseTime._configure()
+ dbRiseTime = SimpleDB()
+ dbRiseTime.inventory.iohandler = ioRiseTime
+ dbRiseTime.inventory.label = "rise time"
+ dbRiseTime._configure()
slipFn = BruneSlipFn()
- slipFn.slip = dbFinalSlip
- slipFn.slipTime = dbSlipTime
- slipFn.slipRate = dbPeakRate
+ slipFn.inventory.dbslip = dbFinalSlip
+ slipFn.inventory.dbSlipTime = dbSlipTime
+ slipFn.inventory.dbRiseTime = dbRiseTime
+ slipFn._configure()
slipFn.preinitialize()
+ slipFn.verifyConfiguration()
slipFn.initialize()
return
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestConstRateSlipFn.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestConstRateSlipFn.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestConstRateSlipFn.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -29,11 +29,18 @@
Test constructor.
"""
slipFn = ConstRateSlipFn()
- slipFn._createCppHandle()
- self.failIfEqual(None, slipFn.cppHandle)
return
+ def test_configure(self):
+ """
+ Test _configure().
+ """
+ slipFn = ConstRateSlipFn()
+ slipFn._configure()
+ return
+
+
def test_initialize(self):
"""
Test initialize().
@@ -42,21 +49,27 @@
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
ioSlipRate = SimpleIOAscii()
- ioSlipRate.filename = "sliprate.spatialdb"
+ ioSlipRate.inventory.filename = "sliprate.spatialdb"
+ ioSlipRate._configure()
dbSlipRate = SimpleDB()
- dbSlipRate.iohandler = ioSlipRate
- dbSlipRate.label = "slip rate"
+ dbSlipRate.inventory.iohandler = ioSlipRate
+ dbSlipRate.inventory.label = "slip rate"
+ dbSlipRate._configure()
ioSlipTime = SimpleIOAscii()
- ioSlipTime.filename = "sliptime.spatialdb"
+ ioSlipTime.inventory.filename = "sliptime.spatialdb"
+ ioSlipTime._configure()
dbSlipTime = SimpleDB()
- dbSlipTime.iohandler = ioSlipTime
- dbSlipTime.label = "slip time"
+ dbSlipTime.inventory.iohandler = ioSlipTime
+ dbSlipTime.inventory.label = "slip time"
+ dbSlipTime._configure()
slipFn = ConstRateSlipFn()
- slipFn.slipRate = dbSlipRate
- slipFn.slipTime = dbSlipTime
+ slipFn.inventory.dbSlipRate = dbSlipRate
+ slipFn.inventory.dbSlipTime = dbSlipTime
+ slipFn._configure()
slipFn.preinitialize()
+ slipFn.verifyConfiguration()
slipFn.initialize()
return
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestEqKinSrc.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestEqKinSrc.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestEqKinSrc.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -29,11 +29,18 @@
Test constructor.
"""
eqsrc = EqKinSrc()
- eqsrc._createCppHandle()
- self.failIfEqual(None, eqsrc.cppHandle)
return
+ def test_configure(self):
+ """
+ Test constructor.
+ """
+ eqsrc = EqKinSrc()
+ eqsrc._configure()
+ return
+
+
def test_initialize(self):
"""
Test initialize().
@@ -43,33 +50,33 @@
from pyre.units.time import second
ioFinalSlip = SimpleIOAscii()
- ioFinalSlip.filename = "finalslip.spatialdb"
+ ioFinalSlip.inventory.filename = "finalslip.spatialdb"
+ ioFinalSlip._configure()
dbFinalSlip = SimpleDB()
- dbFinalSlip.iohandler = ioFinalSlip
- dbFinalSlip.label = "final slip"
+ dbFinalSlip.inventory.iohandler = ioFinalSlip
+ dbFinalSlip.inventory.label = "final slip"
+ dbFinalSlip._configure()
ioSlipTime = SimpleIOAscii()
- ioSlipTime.filename = "sliptime.spatialdb"
+ ioSlipTime.inventory.filename = "sliptime.spatialdb"
+ ioSlipTime._configure()
dbSlipTime = SimpleDB()
- dbSlipTime.iohandler = ioSlipTime
- dbSlipTime.label = "slip time"
+ dbSlipTime.inventory.iohandler = ioSlipTime
+ dbSlipTime.inventory.label = "slip time"
+ dbSlipTime._configure()
- ioPeakRate = SimpleIOAscii()
- ioPeakRate.filename = "peakrate.spatialdb"
- dbPeakRate = SimpleDB()
- dbPeakRate.iohandler = ioPeakRate
- dbPeakRate.label = "peak rate"
-
- from pylith.faults.BruneSlipFn import BruneSlipFn
- slipfn = BruneSlipFn()
- slipfn.slip = dbFinalSlip
- slipfn.slipTime = dbSlipTime
- slipfn.slipRate = dbPeakRate
+ from pylith.faults.StepSlipFn import StepSlipFn
+ slipfn = StepSlipFn()
+ slipfn.inventory.dbSlip = dbFinalSlip
+ slipfn.inventory.dbSlipTime = dbSlipTime
+ slipfn._configure()
eqsrc = EqKinSrc()
- eqsrc.originTime = 5.3*second
- eqsrc.slipfn = slipfn
+ eqsrc.inventory.originTime = 5.3*second
+ eqsrc.inventory.slipfn = slipfn
+ eqsrc._configure()
eqsrc.preinitialize()
+ eqsrc.verifyConfiguration()
eqsrc.initialize()
return
Deleted: short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestFault.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestFault.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestFault.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-## @file unittests/pytests/faults/TestFault.py
-
-## @brief Unit testing of Fault object.
-
-import unittest
-
-from pylith.faults.Fault import Fault
-
-# ----------------------------------------------------------------------
-class TestFault(unittest.TestCase):
- """
- Unit testing of Fault object.
- """
-
- def test_constructor(self):
- """
- Test constructor.
- """
- fault = Fault()
- self.assertEqual(None, fault.cppHandle)
- return
-
-
-# End of file
Deleted: short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestFaultCohesive.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestFaultCohesive.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestFaultCohesive.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -1,63 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-## @file unittests/pytests/faults/TestFaultCohesive.py
-
-## @brief Unit testing of Fault object.
-
-import unittest
-
-from pylith.faults.FaultCohesive import FaultCohesive
-
-# ----------------------------------------------------------------------
-class TestFaultCohesive(unittest.TestCase):
- """
- Unit testing of Fault object.
- """
-
- def test_constructor(self):
- """
- Test constructor.
- """
- fault = FaultCohesive()
- self.assertEqual(None, fault.cppHandle)
- return
-
-
- def test_useFaultMesh(self):
- """
- Test useFaultMesh().
- """
- fault = FaultCohesive()
- fault._configure()
- self.assertEqual(False, fault.useFaultMesh)
-
- fault.useFaultMesh = True;
- self.assertEqual(True, fault.useFaultMesh)
- return
-
-
- def test_faultMeshFilename(self):
- """
- Test faultMeshFilename().
- """
- fault = FaultCohesive()
- fault._configure()
- self.assertEqual("fault.inp", fault.faultMeshFilename)
-
- filename = "SanAndreas.inp"
- fault.faultMeshFilename = filename
- self.assertEqual(filename, fault.faultMeshFilename)
- return
-
-
-# End of file
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestFaultCohesiveKin.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestFaultCohesiveKin.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestFaultCohesiveKin.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -27,28 +27,60 @@
Unit testing of Fault object.
"""
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ fault = FaultCohesiveKin()
+ return
+
+
+ def test_configure(self):
+ """
+ Test _configure().
+ """
+ fault = FaultCohesiveKin()
+ fault._configure()
+ return
+
+
def test_implementsIntegrator(self):
"""
Test to make sure FaultCohesiveKin satisfies integrator requirements.
"""
fault = FaultCohesiveKin()
- fault._configure()
from pylith.feassemble.Integrator import implementsIntegrator
self.failUnless(implementsIntegrator(fault))
return
- def test_constructor(self):
+ def test_useFaultMesh(self):
"""
- Test constructor.
+ Test useFaultMesh().
"""
- fault = FaultCohesiveKin()
+ fault = FaultCohesive()
fault._configure()
- fault._createCppHandle()
- self.failIfEqual(None, fault.cppHandle)
+ self.assertEqual(False, fault.useFaultMesh)
+
+ fault.useFaultMesh = True;
+ self.assertEqual(True, fault.useFaultMesh)
return
+ def test_faultMeshFilename(self):
+ """
+ Test faultMeshFilename().
+ """
+ fault = FaultCohesive()
+ fault._configure()
+ self.assertEqual("fault.inp", fault.faultMeshFilename)
+
+ filename = "SanAndreas.inp"
+ fault.faultMeshFilename = filename
+ self.assertEqual(filename, fault.faultMeshFilename)
+ return
+
+
def test_adjustTopology(self):
"""
Test adjustTopology().
@@ -65,14 +97,15 @@
from pylith.meshio.MeshIOAscii import MeshIOAscii
importer = MeshIOAscii()
- importer.filename = "data/tri3.mesh"
- importer.coordsys = cs
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ improter._configure()
mesh = importer.read(normalizer, debug=False, interpolate=False)
fault = FaultCohesiveKin()
+ fault.inventory.id = 10
+ fault.inventory.label = "fault"
fault._configure()
- fault.id = 10
- fault.label = "fault"
fault.adjustTopology(mesh)
@@ -101,8 +134,8 @@
"""
dt = 2.4
(mesh, fault, fields) = self._initialize()
- fault.timeStep = dt
- self.assertEqual(dt, fault.timeStep)
+ fault.timeStep(dt)
+ self.assertEqual(dt, fault.timeStep())
return
@@ -146,7 +179,7 @@
"""
(mesh, fault, fields) = self._initialize()
- residual = fields.getReal("residual")
+ residual = fields.get("residual")
t = 1.0
fault.integrateResidual(residual, t, fields)
@@ -164,9 +197,9 @@
"""
(mesh, fault, fields) = self._initialize()
- jacobian = mesh.createMatrix(fields.getReal("residual"))
- import pylith.utils.petsc as petsc
- petsc.mat_setzero(jacobian)
+ from pylith.topology.Jacobian import Jacobian
+ jacobian = Jacobian(fields)
+ jacobian.zero()
t = 1.0
fault.integrateJacobian(jacobian, t, fields)
self.assertEqual(False, fault.needNewJacobian())
@@ -186,7 +219,7 @@
(mesh, fault, fields) = self._initialize()
t = 0.50
- residual = fields.getReal("residual")
+ residual = fields.get("residual")
fault.integrateResidual(residual, t, fields)
dt = 0.1
@@ -224,27 +257,29 @@
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
- normalizer.initialize()
+ normalizer._configure()
# Setup mesh
cs = CSCart()
cs.spaceDim = 2
from pylith.meshio.MeshIOAscii import MeshIOAscii
importer = MeshIOAscii()
- importer.filename = "data/tri3.mesh"
- importer.coordsys = cs
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
mesh = importer.read(normalizer, debug=False, interpolate=False)
# Setup quadrature
from pylith.feassemble.FIATSimplex import FIATSimplex
cell = FIATSimplex()
- cell.shape = "line"
- cell.degree = 1
- cell.order = 1
- from pylith.feassemble.quadrature.Quadrature1Din2D import Quadrature1Din2D
- quadrature = Quadrature1Din2D()
+ cell.inventory.shape = "line"
+ cell.inventory.degree = 1
+ cell.inventory.order = 1
+ cell._configure()
+ from pylith.feassemble.Quadrature import SubMeshQuadrature
+ quadrature = SubMeshQuadrature()
+ quadrature.inventory.cell = cell
quadrature._configure()
- quadrature.cell = cell
# Setup earthquake source
from spatialdata.spatialdb.SimpleDB import SimpleDB
@@ -261,38 +296,36 @@
dbSlipTime.iohandler = ioSlipTime
dbSlipTime.label = "slip time"
- ioPeakRate = SimpleIOAscii()
- ioPeakRate.filename = "data/tri3_peakrate.spatialdb"
- dbPeakRate = SimpleDB()
- dbPeakRate.iohandler = ioPeakRate
- dbPeakRate.label = "peak rate"
-
- from pylith.faults.BruneSlipFn import BruneSlipFn
- slipfn = BruneSlipFn()
- slipfn.slip = dbFinalSlip
- slipfn.slipTime = dbSlipTime
- slipfn.slipRate = dbPeakRate
+ from pylith.faults.StepSlipFn import StepSlipFn
+ slipfn = StepSlipFn()
+ slipfn.inventory.dbSlip = dbFinalSlip
+ slipfn.inventory.dbSlipTime = dbSlipTime
+ slipfn._configure()
ioMatDB = SimpleIOAscii()
- ioMatDB.filename = "data/bulkprops_2d.spatialdb"
+ ioMatDB.inventory.filename = "data/bulkprops_2d.spatialdb"
+ ioMatDB._configure()
dbMat = SimpleDB()
- dbMat.iohandler = ioMatDB
- dbMat.label = "bulk properties"
+ dbMat.inventory.iohandler = ioMatDB
+ dbMat.inventory.label = "bulk properties"
+ dbMat._configure()
# Setup fault
fault = FaultCohesiveKin()
+ fault.inventory.output.inventory.writer._configure()
+ fault.inventory.output._configure()
+ fault.inventory.id = 10
+ fault.inventory.label = "fault"
+ fault.inventory.upDir = [0, 0, 1]
+ fault.inventory.normalDir = [1, 0, 0]
+ fault.inventory.quadrature = quadrature
+ fault.inventory.matDB = dbMat
fault._configure()
- fault.output._configure()
- fault.output.writer._configure()
- fault.id = 10
- fault.label = "fault"
- fault.upDir = [0, 0, 1]
- fault.normalDir = [1, 0, 0]
- fault.quadrature = quadrature
eqsrc = fault.eqsrcs.components()[0]
- eqsrc.originTime = 1.23*second
- eqsrc.slipfn = slipfn
- fault.matDB = dbMat
+ eqsrc.inventory.originTime = 1.23*second
+ eqsrc.inventory.slipfn = slipfn
+ eqsrc._configure()
+
fault.adjustTopology(mesh)
fault.preinitialize(mesh)
fault.timeStep(dt)
@@ -301,18 +334,17 @@
fault.initialize(totalTime=0.0*s, numTimeSteps=1, normalizer=normalizer)
# Setup fields
- from pylith.topology.FieldsManager import FieldsManager
- fields = FieldsManager(mesh)
- fields.addReal("residual")
- fields.addReal("solution")
- fields.addReal("disp")
- fields.solutionField("solution")
- fields.setFiberDimension("residual", cs.spaceDim)
- fields.allocate("residual")
+ from pylith.topology.SolutionFields import SolutionFields
+ fields = SolutionFields(mesh)
+ fields.add("residual")
+ fields.add("solution")
+ fields.add("disp")
+ fields.solutionName("solution")
+ residual = fields.get("residual")
+ residual.newSection(residual.VERTICES_FIELD, cs.spaceDim)
+ residual.allocate()
+ residual.zero()
fields.copyLayout("residual")
-
- import pylith.topology.topology as bindings
- bindings.zeroRealSection(fields.getReal("residual"))
return (mesh, fault, fields)
Added: short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestLiuCosSlipFn.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestLiuCosSlipFn.py (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestLiuCosSlipFn.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -0,0 +1,86 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/faults/TestLiuCosSlipFn.py
+
+## @brief Unit testing of LiuCosSlipFn object.
+
+import unittest
+
+from pylith.faults.LiuCosSlipFn import LiuCosSlipFn
+
+# ----------------------------------------------------------------------
+class TestLiuCosSlipFn(unittest.TestCase):
+ """
+ Unit testing of LiuCosSlipFn object.
+ """
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ slipFn = LiuCosSlipFn()
+ return
+
+
+ def test_configure(self):
+ """
+ Test constructor.
+ """
+ slipFn = LiuCosSlipFn()
+ slipFn._configure()
+ return
+
+
+ def test_initialize(self):
+ """
+ Test initialize().
+ """
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+ from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
+
+ ioFinalSlip = SimpleIOAscii()
+ ioFinalSlip.inventory.filename = "finalslip.spatialdb"
+ ioFinalSlip._configure()
+ dbFinalSlip = SimpleDB()
+ dbFinalSlip.inventory.iohandler = ioFinalSlip
+ dbFinalSlip.inventory.label = "final slip"
+ dbFinalSlip._configure()
+
+ ioSlipTime = SimpleIOAscii()
+ ioSlipTime.inventory.filename = "sliptime.spatialdb"
+ ioSlipTime._configure()
+ dbSlipTime = SimpleDB()
+ dbSlipTime.inventory.iohandler = ioSlipTime
+ dbSlipTime.inventory.label = "slip time"
+ dbSlipTime._configure()
+
+ ioRiseTime = SimpleIOAscii()
+ ioRiseTime.inventory.filename = "risetime.spatialdb"
+ ioRiseTime._configure()
+ dbRiseTime = SimpleDB()
+ dbRiseTime.inventory.iohandler = ioRiseTime
+ dbRiseTime.inventory.label = "rise time"
+ dbRiseTime._configure()
+
+ slipFn = LiuCosSlipFn()
+ slipFn.inventory.dbslip = dbFinalSlip
+ slipFn.inventory.dbSlipTime = dbSlipTime
+ slipFn.inventory.dbRiseTime = dbRiseTime
+ slipFn._configure()
+ slipFn.preinitialize()
+ slipFn.verifyConfiguration()
+ slipFn.initialize()
+ return
+
+
+# End of file
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestStepSlipFn.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestStepSlipFn.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestStepSlipFn.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -29,11 +29,18 @@
Test constructor.
"""
slipFn = StepSlipFn()
- slipFn._createCppHandle()
- self.failIfEqual(None, slipFn.cppHandle)
return
+ def test_configure(self):
+ """
+ Test constructor.
+ """
+ slipFn = StepSlipFn()
+ slipFn._configure()
+ return
+
+
def test_initialize(self):
"""
Test initialize().
@@ -42,21 +49,27 @@
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
ioFinalSlip = SimpleIOAscii()
- ioFinalSlip.filename = "finalslip.spatialdb"
+ ioFinalSlip.inventory.filename = "finalslip.spatialdb"
+ ioFinalSlip._configure()
dbFinalSlip = SimpleDB()
- dbFinalSlip.iohandler = ioFinalSlip
- dbFinalSlip.label = "final slip"
+ dbFinalSlip.inventory.iohandler = ioFinalSlip
+ dbFinalSlip.inventory.label = "final slip"
+ dbFinalSlip._configure()
ioSlipTime = SimpleIOAscii()
- ioSlipTime.filename = "sliptime.spatialdb"
+ ioSlipTime.inventory.filename = "sliptime.spatialdb"
+ ioSlipTime._configure()
dbSlipTime = SimpleDB()
- dbSlipTime.iohandler = ioSlipTime
- dbSlipTime.label = "slip time"
+ dbSlipTime.inventory.iohandler = ioSlipTime
+ dbSlipTime.inventory.label = "slip time"
+ dbSlipTime._configure()
slipFn = StepSlipFn()
- slipFn.slip = dbFinalSlip
- slipFn.slipTime = dbSlipTime
+ slipFn.inventory.dbSlip = dbFinalSlip
+ slipFn.inventory.dbSlipTime = dbSlipTime
+ slipFn._configure()
slipFn.preinitialize()
+ slipFn.verifyConfiguration()
slipFn.initialize()
return
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/testfaults.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/testfaults.py 2009-04-29 22:50:18 UTC (rev 14820)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/testfaults.py 2009-04-30 00:11:39 UTC (rev 14821)
@@ -56,24 +56,21 @@
suite = unittest.TestSuite()
- from TestBruneSlipFn import TestBruneSlipFn
- suite.addTest(unittest.makeSuite(TestBruneSlipFn))
+ from TestStepSlipFn import TestStepSlipFn
+ suite.addTest(unittest.makeSuite(TestStepSlipFn))
from TestConstRateSlipFn import TestConstRateSlipFn
suite.addTest(unittest.makeSuite(TestConstRateSlipFn))
- from TestStepSlipFn import TestStepSlipFn
- suite.addTest(unittest.makeSuite(TestStepSlipFn))
+ from TestBruneSlipFn import TestBruneSlipFn
+ suite.addTest(unittest.makeSuite(TestBruneSlipFn))
+ from TestLiuCosSlipFn import TestLiuCosSlipFn
+ suite.addTest(unittest.makeSuite(TestLiuCosSlipFn))
+
from TestEqKinSrc import TestEqKinSrc
suite.addTest(unittest.makeSuite(TestEqKinSrc))
- from TestFault import TestFault
- suite.addTest(unittest.makeSuite(TestFault))
-
- from TestFaultCohesive import TestFaultCohesive
- suite.addTest(unittest.makeSuite(TestFaultCohesive))
-
from TestFaultCohesiveKin import TestFaultCohesiveKin
suite.addTest(unittest.makeSuite(TestFaultCohesiveKin))
More information about the CIG-COMMITS
mailing list