[cig-commits] r6846 - in short/3D/PyLith/trunk: libsrc/meshio modulesrc/meshio modulesrc/topology pylith/topology

knepley at geodynamics.org knepley at geodynamics.org
Thu May 10 16:30:12 PDT 2007


Author: knepley
Date: 2007-05-10 16:30:11 -0700 (Thu, 10 May 2007)
New Revision: 6846

Modified:
   short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc
   short/3D/PyLith/trunk/libsrc/meshio/MeshIO.hh
   short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src
   short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src
   short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py
Log:
MeshGenerator appears to work (need VTK output)


Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc	2007-05-10 21:32:05 UTC (rev 6845)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc	2007-05-10 23:30:11 UTC (rev 6846)
@@ -73,19 +73,6 @@
 } // write
 
 // ----------------------------------------------------------------------
-// Create cube boundary mesh.
-void 
-pylith::meshio::MeshIO::createCubeBoundary(ALE::Obj<Mesh>* mesh)
-{ // read
-  double lower[3] = {0.0, 0.0, 0.0};
-  double upper[3] = {1.0, 1.0, 1.0};
-  int    faces[3] = {1, 1, 1};
-
-  *mesh = ALE::MeshBuilder::createCubeBoundary(PETSC_COMM_WORLD, lower, upper, faces, _debug);
-  mesh->addRef();
-} // createCubeBoundary
-
-// ----------------------------------------------------------------------
 // Set vertices in mesh.
 void
 pylith::meshio::MeshIO::_buildMesh(const double_array& coordinates,

Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIO.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIO.hh	2007-05-10 21:32:05 UTC (rev 6845)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIO.hh	2007-05-10 23:30:11 UTC (rev 6846)
@@ -79,12 +79,6 @@
    */
   void write(ALE::Obj<ALE::Mesh>* mesh);
 
-  /** Create cube boundary mesh.
-   *
-   * @param mesh Pointer to PETSc mesh object
-   */
-  void createCubeBoundary(ALE::Obj<ALE::Mesh>* mesh);
-
 // PROTECTED MEMBERS ////////////////////////////////////////////////////
 protected :
 

Modified: short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src	2007-05-10 21:32:05 UTC (rev 6845)
+++ short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src	2007-05-10 23:30:11 UTC (rev 6846)
@@ -118,32 +118,6 @@
     return
 
 
-  def createCubeBoundary(self, mesh):
-    """
-    Read mesh from file.
-    """
-    # create shim for method 'read'
-    #embed{ void MeshIO_createCubeBoundary(void* objVptr, void* meshVptr)
-    try {
-      assert(0 != objVptr);
-      assert(0 != meshVptr);
-      ALE::Obj<ALE::Mesh>* pMesh = (ALE::Obj<ALE::Mesh>*) meshVptr;
-      ((pylith::meshio::MeshIO*) objVptr)->createCubeBoundary(pMesh);
-    } 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 mesh.name != "pylith_topology_Mesh":
-      raise TypeError, \
-            "Argument must be extension module type 'Mesh'."
-    MeshIO_createCubeBoundary(self.thisptr, ptrFromHandle(mesh))
-    return
-
-
   def _createHandle(self):
     """Wrap pointer to C++ object in PyCObject."""
     return PyCObject_FromVoidPtr(self.thisptr, MeshIO_destructor)

Modified: short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src	2007-05-10 21:32:05 UTC (rev 6845)
+++ short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src	2007-05-10 23:30:11 UTC (rev 6846)
@@ -12,6 +12,7 @@
 
 #header{
 #include <Mesh.hh>
+#include <Generator.hh>
 #include <Distribution.hh>
 #include <petscmesh.h>
 #include "pylith/utils/petscfwd.h"
@@ -63,6 +64,61 @@
   return
 
 # ----------------------------------------------------------------------
+cdef class MeshGenerator:
+
+  def createCubeBoundary(self, debug = 0):
+    """
+    Returns a Mesh that is the boundary of the unit cube
+    """
+    # create shim for method 'read'
+    #embed{ void MeshGenerator_createCubeBoundary(int debug, void* meshVptr)
+    try {
+      assert(0 != meshVptr);
+      ALE::Obj<ALE::Mesh>* pMesh   = (ALE::Obj<ALE::Mesh>*) meshVptr;
+      const double lower[3] = {0.0, 0.0, 0.0};
+      const double upper[3] = {1.0, 1.0, 1.0};
+      const int    faces[3] = {1, 1, 1};
+      *pMesh = ALE::MeshBuilder::createCubeBoundary(PETSC_COMM_WORLD, lower, upper, faces, debug);
+    } 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
+    mesh = Mesh()
+    MeshGenerator_createCubeBoundary(debug, ptrFromHandle(mesh))
+    return mesh
+
+  def generateMesh(self, meshBd):
+    """
+    Generate a Mesh from a boundary
+    """
+    # create shim for method 'read'
+    #embed{ void MeshGenerator_generateMesh(void* meshBdVptr, void* meshVptr)
+    try {
+      assert(0 != meshBdVptr);
+      assert(0 != meshVptr);
+      ALE::Obj<ALE::Mesh>* pMeshBd = (ALE::Obj<ALE::Mesh>*) meshBdVptr;
+      ALE::Obj<ALE::Mesh>* pMesh   = (ALE::Obj<ALE::Mesh>*) meshVptr;
+      *pMesh = ALE::Generator::generateMesh(*pMeshBd);
+    } 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 meshBd.name != "pylith_topology_Mesh":
+      raise TypeError, \
+            "Argument must be extension module type 'Mesh'."
+    mesh = Mesh()
+    MeshGenerator_generateMesh(ptrFromHandle(meshBd), ptrFromHandle(mesh))
+    return mesh
+
+# ----------------------------------------------------------------------
 cdef class Mesh:
 
   cdef void* thisptr # Pointer to C++ object

Modified: short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py	2007-05-10 21:32:05 UTC (rev 6845)
+++ short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py	2007-05-10 23:30:11 UTC (rev 6846)
@@ -69,6 +69,8 @@
     Constructor.
     """
     Component.__init__(self, name, facility="mesh_generator")
+    import pylith.topology.topology as bindings
+    self.cppHandle = bindings.MeshGenerator()
     self.debug = False
     self.interpolate = False
     return
@@ -76,17 +78,16 @@
 
   def create(self, boundary, faults = None):
     """
-    Hook for creating mesh.
+    Generate a Mesh from a boundary
     """
-    raise NotImplementedError, "MeshGenerator::create() not implemented."
-    return
+    return self.cppHandle.generateMesh(boundary)
 
 
   def createCubeBoundary(self):
     """
     Returns a Mesh that is the boundary of the unit cube
     """
-    return self.inventory.importer.createCubeBoundary(self.debug)
+    return self.cppHandle.createCubeBoundary(self.debug)
 
 
   # PRIVATE METHODS ////////////////////////////////////////////////////



More information about the cig-commits mailing list