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

knepley at geodynamics.org knepley at geodynamics.org
Fri May 11 10:47:19 PDT 2007


Author: knepley
Date: 2007-05-11 10:47:18 -0700 (Fri, 11 May 2007)
New Revision: 6853

Modified:
   short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src
   short/3D/PyLith/trunk/pylith/Makefile.am
   short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py
   short/3D/PyLith/trunk/pylith/topology/__init__.py
   short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py
Log:
MeshDistributor appears to work


Modified: short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src	2007-05-11 04:45:20 UTC (rev 6852)
+++ short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src	2007-05-11 17:47:18 UTC (rev 6853)
@@ -119,6 +119,40 @@
     return mesh
 
 # ----------------------------------------------------------------------
+cdef class MeshDistributor:
+
+  def distributeMesh(self, mesh, partitioner = None):
+    """
+    Distribute a Mesh
+    """
+    # create shim for method 'read'
+    #embed{ void MeshDistributor_distributeMesh(void* meshVptr, char *partitioner, void* newMeshVptr)
+    try {
+      assert(0 != meshVptr);
+      assert(0 != newMeshVptr);
+      ALE::Obj<ALE::Mesh>* pMesh    = (ALE::Obj<ALE::Mesh>*) meshVptr;
+      ALE::Obj<ALE::Mesh>* pNewMesh = (ALE::Obj<ALE::Mesh>*) newMeshVptr;
+      if (!strlen(partitioner)) {
+        *pNewMesh = ALE::Distribution<ALE::Mesh>::distributeMesh(*pMesh);
+      } else {
+        *pNewMesh = ALE::Distribution<ALE::Mesh>::distributeMesh(*pMesh, 0, partitioner);
+      }
+    } 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'."
+    newMesh = Mesh()
+    MeshDistributor_distributeMesh(ptrFromHandle(mesh), partitioner, ptrFromHandle(newMesh))
+    return newMesh
+
+# ----------------------------------------------------------------------
 cdef class Mesh:
 
   cdef void* thisptr # Pointer to C++ object

Modified: short/3D/PyLith/trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/pylith/Makefile.am	2007-05-11 04:45:20 UTC (rev 6852)
+++ short/3D/PyLith/trunk/pylith/Makefile.am	2007-05-11 17:47:18 UTC (rev 6853)
@@ -71,6 +71,7 @@
 	solver/SolverLinear.py \
 	topology/__init__.py \
 	topology/Mesh.py \
+	topology/MeshDistributor.py \
 	topology/MeshGenerator.py \
 	topology/MeshImporter.py \
 	utils/__init__.py \

Modified: short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py	2007-05-11 04:45:20 UTC (rev 6852)
+++ short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py	2007-05-11 17:47:18 UTC (rev 6853)
@@ -39,7 +39,6 @@
     ## \b Properties
     ## @li \b debug Debugging flag for mesh.
     ## @li \b interpolate Build intermediate mesh topology elements (if true)
-    ## @li \b partitioner Name of mesh partitioner {"parmetis", "chaco"}
     ##
     ## \b Facilities
     ## @li None
@@ -52,16 +51,7 @@
     interpolate = pyre.inventory.bool("interpolate", default=False)
     interpolate.meta['tip'] = "Build intermediate mesh topology elements"
 
-    partitioner = pyre.inventory.str("partitioner", default="chaco",
-                                      validator=pyre.inventory.choice(["chaco",
-                                                                       "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"):
@@ -99,8 +89,6 @@
     Component._configure(self)
     self.debug = self.inventory.debug
     self.interpolate = self.inventory.interpolate
-    self.partitioner = self.inventory.partitioner
-    self.importer    = self.inventory.importer
     return
 
 

Modified: short/3D/PyLith/trunk/pylith/topology/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/__init__.py	2007-05-11 04:45:20 UTC (rev 6852)
+++ short/3D/PyLith/trunk/pylith/topology/__init__.py	2007-05-11 17:47:18 UTC (rev 6853)
@@ -15,6 +15,7 @@
 ## @brief Python PyLith finite-element topology module initialization
 
 __all__ = ['Mesh',
+           'MeshDistributor',
            'MeshGenerator',
            'MeshImporter']
 

Modified: short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py	2007-05-11 04:45:20 UTC (rev 6852)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py	2007-05-11 17:47:18 UTC (rev 6853)
@@ -17,6 +17,7 @@
 import unittest
 
 from pylith.topology.MeshGenerator import MeshGenerator
+from pylith.topology.MeshDistributor import MeshDistributor
 
 # ----------------------------------------------------------------------
 class TestMeshGenerator(unittest.TestCase):
@@ -68,7 +69,9 @@
     """
     generator = MeshGenerator()
     generator.interpolate = True
-    generator.create(generator.createCubeBoundary())
+    mesh = generator.create(generator.createCubeBoundary())
+    distributor = MeshDistributor()
+    newMesh = distributor.distributeMesh(mesh)
     self.assertEqual(True, generator.interpolate)
     return
 



More information about the cig-commits mailing list