[cig-commits] r6811 - in short/3D/PyLith/trunk: libsrc/faults modulesrc/faults pylith/faults

brad at geodynamics.org brad at geodynamics.org
Wed May 9 13:32:08 PDT 2007


Author: brad
Date: 2007-05-09 13:32:08 -0700 (Wed, 09 May 2007)
New Revision: 6811

Modified:
   short/3D/PyLith/trunk/libsrc/faults/Fault.hh
   short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.hh
   short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc
   short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.hh
   short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src
   short/3D/PyLith/trunk/pylith/faults/Fault.py
Log:
Added binding for Fault::initialization. Added in initialization of kinematic source to FaultCohesiveKin.

Modified: short/3D/PyLith/trunk/libsrc/faults/Fault.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/Fault.hh	2007-05-09 20:31:29 UTC (rev 6810)
+++ short/3D/PyLith/trunk/libsrc/faults/Fault.hh	2007-05-09 20:32:08 UTC (rev 6811)
@@ -33,6 +33,13 @@
   } // faults
 } // pylith
 
+/// Namespace for spatialdata package
+namespace spatialdata {
+  namespace geocoords {
+    class CoordSys;
+  } // geocoords
+} // spatialdata
+
 /// C++ abstract base class for Fault object.
 class pylith::faults::Fault
 { // class Fault
@@ -90,12 +97,14 @@
    * condition parameters.
    *
    * @param mesh PETSc mesh
+   * @param cs Coordinate system for mesh
    * @param upDir Direction perpendicular to along-strike direction that is 
    *   not collinear with fault normal (usually "up" direction but could 
    *   be up-dip direction).
    */
   virtual
   void initialize(const ALE::Obj<ALE::Mesh>& mesh,
+		  const spatialdata::geocoords::CoordSys* cs,
 		  const double_array& upDir) = 0;
 
   // PROTECTED METHODS //////////////////////////////////////////////////

Modified: short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.hh	2007-05-09 20:31:29 UTC (rev 6810)
+++ short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.hh	2007-05-09 20:32:08 UTC (rev 6811)
@@ -56,18 +56,6 @@
    */
   void adjustTopology(const ALE::Obj<ALE::Mesh>& mesh);
 
-  /** Initialize fault. Determine orientation and setup boundary
-   * condition parameters.
-   *
-   * @param mesh PETSc mesh
-   * @param upDir Direction perpendicular to along-strike direction that is 
-   *   not collinear with fault normal (usually "up" direction but could 
-   *   be up-dip direction).
-   */
-  virtual
-  void initialize(const ALE::Obj<ALE::Mesh>& mesh,
-		  const double_array& upDir) = 0;
-
   /** Integrate contribution of cohesive cells to residual term.
    *
    * @param residual Residual field (output)

Modified: short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc	2007-05-09 20:31:29 UTC (rev 6810)
+++ short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc	2007-05-09 20:32:08 UTC (rev 6811)
@@ -59,10 +59,12 @@
 // Initialize fault. Determine orientation and setup boundary
 void
 pylith::faults::FaultCohesiveKin::initialize(const ALE::Obj<ALE::Mesh>& mesh,
+					     const spatialdata::geocoords::CoordSys* cs,
 					     const double_array& upDir)
 { // initialize
   assert(0 != _quadrature);
   assert(0 != _faultMesh);
+  assert(0 != _eqsrc);
   assert(!_faultMesh->isNull());
   
   if (3 != upDir.size())
@@ -210,6 +212,8 @@
       orientation->restrictPoint(*v_iter);
     _orientation->updatePoint(*v_iter, vertexOrient);
   } // for
+  
+  _eqsrc->initialize(mesh, *_faultMesh, setVert, cs);
 } // initialize
 
 // ----------------------------------------------------------------------

Modified: short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.hh	2007-05-09 20:31:29 UTC (rev 6810)
+++ short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.hh	2007-05-09 20:32:08 UTC (rev 6811)
@@ -73,11 +73,13 @@
    * condition parameters.
    *
    * @param mesh PETSc mesh
+   * @param cs Coordinate system for mesh
    * @param upDir Direction perpendicular to along-strike direction that is 
    *   not collinear with fault normal (usually "up" direction but could 
    *   be up-dip direction).
    */
   void initialize(const ALE::Obj<ALE::Mesh>& mesh,
+		  const spatialdata::geocoords::CoordSys* cs,
 		  const double_array& upDir);
 
   /** Integrate contribution of cohesive cells to residual term.

Modified: short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src	2007-05-09 20:31:29 UTC (rev 6810)
+++ short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src	2007-05-09 20:32:08 UTC (rev 6811)
@@ -17,6 +17,8 @@
 #include "pylith/faults/SlipTimeFn.hh"
 #include "pylith/faults/BruneSlipFn.hh"
 
+#include "pylith/utils/array.hh"
+
 #include <assert.h>
 #include <stdexcept>
 #include <Python.h>
@@ -100,6 +102,53 @@
     return
 
 
+  def initialize(self, mesh, cs, upDir):
+    """
+    Initialize fault.
+    """
+    # create shim for method 'initialize'
+    #embed{ void Fault_initialize(void* objVptr, void* meshVptr, void* csVptr, double* upDirPtr)
+    try {
+      assert(0 != objVptr);
+      assert(0 != meshVptr);
+      assert(0 != csVptr);
+      ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) meshVptr;
+      spatialdata::geocoords::CoordSys* cs =
+        (spatialdata::geocoords::CoordSys*) csVptr;
+      pylith::double_array upDir(3);
+      upDir[0] = upDirPtr[0];
+      upDir[1] = upDirPtr[1];
+      upDir[2] = upDirPtr[2];
+      ((pylith::faults::Fault*) objVptr)->initialize(*mesh, cs, upDir);
+      } catch (const std::exception& err) {
+      PyErr_SetString(PyExc_RuntimeError,
+                      const_cast<char*>(err.what()));
+    } catch (...) {
+      PyErr_SetString(PyExc_RuntimeError,
+                      "Caught unknown C++ exception.");
+    } // try/catch      
+    #}embed
+
+    if not mesh.name == "pylith_topology_Mesh":
+      raise TypeError, \
+            "Argument must be extension module type " \
+            "'pylith::topology::Mesh'."
+    if not cs.name == "spatialdata_geocoords_CoordSys":
+      raise TypeError, \
+            "Argument must be extension module type " \
+            "'spatialdata::geocoords::CoordSys'."
+    if 3 != len(upDir):
+      raise TypeError, \
+            "Argument must be a 3 vector (list)."
+    cdef double upDirCpp[3]
+    upDirCpp[0] = upDir[0]
+    upDirCpp[1] = upDir[1]
+    upDirCpp[2] = upDir[2]    
+    Fault_initialize(self.thisptr, ptrFromHandle(mesh), ptrFromHandle(cs),
+                     upDirCpp)
+    return
+
+
   def _createHandle(self):
     """
     Wrap pointer to C++ object in PyCObject.

Modified: short/3D/PyLith/trunk/pylith/faults/Fault.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/Fault.py	2007-05-09 20:31:29 UTC (rev 6810)
+++ short/3D/PyLith/trunk/pylith/faults/Fault.py	2007-05-09 20:32:08 UTC (rev 6811)
@@ -112,7 +112,7 @@
 
   def initialize(self, mesh):
     """
-    Initialize material property manager.
+    Initialize fault.
     """
     self._info.log("Initializing fault '%s'." % self.label)
 



More information about the cig-commits mailing list