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

knepley at geodynamics.org knepley at geodynamics.org
Mon Apr 23 21:09:09 PDT 2007


Author: knepley
Date: 2007-04-23 21:09:08 -0700 (Mon, 23 Apr 2007)
New Revision: 6640

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/pylith/meshio/MeshIO.py
   short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py
   short/3D/PyLith/trunk/pylith/topology/MeshImporter.py
   short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py
Log:
Trying to add a mesh test (having problem with pyre stuff)


Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc	2007-04-24 00:23:03 UTC (rev 6639)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc	2007-04-24 04:09:08 UTC (rev 6640)
@@ -73,6 +73,19 @@
 } // 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-04-24 00:23:03 UTC (rev 6639)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIO.hh	2007-04-24 04:09:08 UTC (rev 6640)
@@ -79,6 +79,12 @@
    */
   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-04-24 00:23:03 UTC (rev 6639)
+++ short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src	2007-04-24 04:09:08 UTC (rev 6640)
@@ -113,6 +113,32 @@
     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/pylith/meshio/MeshIO.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/MeshIO.py	2007-04-24 00:23:03 UTC (rev 6639)
+++ short/3D/PyLith/trunk/pylith/meshio/MeshIO.py	2007-04-24 04:09:08 UTC (rev 6640)
@@ -75,6 +75,32 @@
     return
 
 
+  def createCubeBoundary(self, debug):
+    """
+    Create cube boundary mesh and store in Sieve mesh object.
+
+    @returns PETSc mesh object containing cube boundary mesh
+    """
+    self._info.log("Creating cube boundary mesh")
+
+    # Set flags
+    ##self._sync()
+    self.cppHandle.debug = debug
+
+    # Initialize coordinate system
+    ##if self.coordsys is None:
+    ##  raise ValueError, "Coordinate system for mesh is unknown."
+    ##self.coordsys.initialize()
+
+    from pylith.topology.Mesh import Mesh
+    mesh = Mesh()
+    ##mesh.initialize(self.coordsys)
+
+    # Create boundary
+    self.cppHandle.createCubeBoundary(mesh.cppHandle)
+    return mesh
+
+
   # PRIVATE METHODS ////////////////////////////////////////////////////
 
   def _configure(self):

Modified: short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py	2007-04-24 00:23:03 UTC (rev 6639)
+++ short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py	2007-04-24 04:09:08 UTC (rev 6640)
@@ -57,7 +57,11 @@
                                                                        "parmetis"]))
     partitioner.meta['tip'] = "Name of mesh partitioner."
 
+    from pylith.meshio.MeshIOAscii import MeshIOAscii
+    importer = pyre.inventory.facility("importer", factory=MeshIOAscii)
+    importer.meta['tip'] = "Mesh importer."
 
+
   # PUBLIC METHODS /////////////////////////////////////////////////////
 
   def __init__(self, name="meshgenerator"):
@@ -70,7 +74,7 @@
     return
 
 
-  def create(self, faults):
+  def create(self, boundary, faults = None):
     """
     Hook for creating mesh.
     """
@@ -78,6 +82,13 @@
     return
 
 
+  def createCubeBoundary(self):
+    """
+    Returns a Mesh that is the boundary of the unit cube
+    """
+    return self.inventory.importer.createCubeBoundary(self.debug)
+
+
   # PRIVATE METHODS ////////////////////////////////////////////////////
 
   def _configure(self):
@@ -88,6 +99,7 @@
     self.debug = self.inventory.debug
     self.interpolate = self.inventory.interpolate
     self.partitioner = self.inventory.partitioner
+    self.importer    = self.inventory.importer
     return
 
 
@@ -97,7 +109,7 @@
     """
     if not faults is None:
       for fault in faults:
-        fault.adjustTopology(mesh)
+        mesh.adjustTopology(fault)
     return
   
 

Modified: short/3D/PyLith/trunk/pylith/topology/MeshImporter.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/MeshImporter.py	2007-04-24 00:23:03 UTC (rev 6639)
+++ short/3D/PyLith/trunk/pylith/topology/MeshImporter.py	2007-04-24 04:09:08 UTC (rev 6640)
@@ -69,6 +69,13 @@
     return mesh
 
 
+  def createCubeBoundary(self):
+    """
+    Hook for creating cube boundary.
+    """
+    return self.importer.createCubeBoundary(self.debug)
+
+
   # PRIVATE METHODS ////////////////////////////////////////////////////
 
   def _configure(self):

Modified: short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py	2007-04-24 00:23:03 UTC (rev 6639)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py	2007-04-24 04:09:08 UTC (rev 6640)
@@ -62,4 +62,15 @@
     return
 
 
+  def test_distribution(self):
+    """
+    Test mesh distribution
+    """
+    generator = MeshGenerator()
+    generator.interpolate = True
+    generator.create(generator.createCubeBoundary())
+    self.assertEqual(True, generator.interpolate)
+    return
+
+
 # End of file 



More information about the cig-commits mailing list