[cig-commits] r13945 - in short/3D/PyLith/branches/pylith-swig: . modulesrc/meshio pylith/meshio unittests/pytests/meshio

brad at geodynamics.org brad at geodynamics.org
Sat Jan 24 12:56:17 PST 2009


Author: brad
Date: 2009-01-24 12:56:17 -0800 (Sat, 24 Jan 2009)
New Revision: 13945

Added:
   short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/MeshIOCubit.i
Modified:
   short/3D/PyLith/branches/pylith-swig/TODO
   short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/Makefile.am
   short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/meshio.i
   short/3D/PyLith/branches/pylith-swig/pylith/meshio/MeshIOCubit.py
   short/3D/PyLith/branches/pylith-swig/pylith/meshio/MeshIOLagrit.py
   short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/Makefile.am
   short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/TestMeshIOCubit.py
Log:
Updated MeshIOCubit.

Modified: short/3D/PyLith/branches/pylith-swig/TODO
===================================================================
--- short/3D/PyLith/branches/pylith-swig/TODO	2009-01-24 14:25:34 UTC (rev 13944)
+++ short/3D/PyLith/branches/pylith-swig/TODO	2009-01-24 20:56:17 UTC (rev 13945)
@@ -5,9 +5,13 @@
 0. SWIG conversion
   TestMesh.test_view()
   TestMesh.test_checkMaterialIds()
-  TestSolutionFields
 
+  meshio
+    lib
+    module
 
+  FieldsManager (change to SolutionFields)
+
 1. Reduce memory use (new labels) [Matt]
 
 2. Nondimensionalize [Brad]

Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/Makefile.am	2009-01-24 14:25:34 UTC (rev 13944)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/Makefile.am	2009-01-24 20:56:17 UTC (rev 13945)
@@ -21,7 +21,8 @@
 	meshio.i \
 	MeshIOObj.i \
 	MeshIOAscii.i \
-	MeshIOLagrit.i
+	MeshIOLagrit.i \
+	MeshIOCubit.i
 
 swig_generated = \
 	meshio_wrap.cxx \

Added: short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/MeshIOCubit.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/MeshIOCubit.i	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/MeshIOCubit.i	2009-01-24 20:56:17 UTC (rev 13945)
@@ -0,0 +1,61 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/MeshIOCubit.i
+ *
+ * @brief Python interface to C++ MeshIOCubit object.
+ */
+
+namespace pylith {
+  namespace meshio {
+
+    class MeshIOCubit : public MeshIO
+    { // MeshIOCubit
+
+      // PUBLIC METHODS /////////////////////////////////////////////////
+    public :
+
+      /// Constructor
+      MeshIOCubit(void);
+
+      /// Destructor
+      ~MeshIOCubit(void);
+
+      /** Set filename for Cubit file.
+       *
+       * @param filename Name of file
+       */
+      void filename(const char* name);
+      
+      /** Get filename of Cubit file.
+       *
+       * @returns Name of file
+       */
+      const char* filename(void) const;
+      
+      // PROTECTED METHODS ////////////////////////////////////////////////////
+    protected :
+      
+      /// Write mesh
+      void _write(void) const;
+      
+      /// Read mesh
+      void _read(void);
+      
+    }; // MeshIOCubit
+
+  } // meshio
+} // pylith
+
+
+// End of file 

Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/meshio.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/meshio.i	2009-01-24 14:25:34 UTC (rev 13944)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/meshio.i	2009-01-24 20:56:17 UTC (rev 13945)
@@ -18,6 +18,7 @@
 #include "pylith/meshio/MeshIO.hh"
 #include "pylith/meshio/MeshIOAscii.hh"
 #include "pylith/meshio/MeshIOLagrit.hh"
+#include "pylith/meshio/MeshIOCubit.hh"
 
 #include "pylith/utils/arrayfwd.hh"
 %}
@@ -37,6 +38,7 @@
 %include "MeshIOObj.i"
 %include "MeshIOAscii.i"
 %include "MeshIOLagrit.i"
+%include "MeshIOCubit.i"
 
 
 // End of file

Modified: short/3D/PyLith/branches/pylith-swig/pylith/meshio/MeshIOCubit.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/meshio/MeshIOCubit.py	2009-01-24 14:25:34 UTC (rev 13944)
+++ short/3D/PyLith/branches/pylith-swig/pylith/meshio/MeshIOCubit.py	2009-01-24 20:56:17 UTC (rev 13945)
@@ -17,10 +17,11 @@
 ##
 ## Factory: mesh_io
 
-from MeshIO import MeshIO
+from MeshIOObj import MeshIOObj
+from meshio import MeshIOCubit as ModuleMeshIOCubit
 
 # MeshIOCubit class
-class MeshIOCubit(MeshIO):
+class MeshIOCubit(MeshIOObj, ModuleMeshIOCubit):
   """
   Python object for reading/writing finite-element mesh from Cubit.
 
@@ -29,7 +30,7 @@
 
   # INVENTORY //////////////////////////////////////////////////////////
 
-  class Inventory(MeshIO.Inventory):
+  class Inventory(MeshIOObj.Inventory):
     """
     Python object for managing MeshIOCubit facilities and properties.
     """
@@ -60,7 +61,7 @@
     """
     Constructor.
     """
-    MeshIO.__init__(self, name)
+    MeshIOObj.__init__(self, name)
     return
 
 
@@ -70,22 +71,17 @@
     """
     Set members based using inventory.
     """
-    MeshIO._configure(self)
-    self.filename = self.inventory.filename
+    MeshIOObj._configure(self)
     self.coordsys = self.inventory.coordsys
+    self.filename(self.inventory.filename)
     return
 
 
-  def _sync(self):
+  def _createModuleObj(self):
     """
-    Force synchronization between Python and C++.
+    Create C++ MeshIOCubit object.
     """
-    if None == self.cppHandle:
-      import pylith.meshio.meshio as bindings
-      self.cppHandle = bindings.MeshIOCubit()
-
-    MeshIO._sync(self)
-    self.cppHandle.filename = self.filename
+    ModuleMeshIOCubit.__init__(self)
     return
   
 

Modified: short/3D/PyLith/branches/pylith-swig/pylith/meshio/MeshIOLagrit.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/meshio/MeshIOLagrit.py	2009-01-24 14:25:34 UTC (rev 13944)
+++ short/3D/PyLith/branches/pylith-swig/pylith/meshio/MeshIOLagrit.py	2009-01-24 20:56:17 UTC (rev 13945)
@@ -101,7 +101,7 @@
 
   def _createModuleObj(self):
     """
-    Create C++ MeshIOAscii object.
+    Create C++ MeshIOLagrit object.
     """
     ModuleMeshIOLagrit.__init__(self)
     return

Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/Makefile.am	2009-01-24 14:25:34 UTC (rev 13944)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/Makefile.am	2009-01-24 20:56:17 UTC (rev 13945)
@@ -30,8 +30,8 @@
 	TestOutputSolnSubset.py
 
 if ENABLE_CUBIT
-#  TESTS += testdriver_cubit.py
-#  dist_check_SCRIPTS += testdriver_cubit.py
+  TESTS += testdriver_cubit.py
+  dist_check_SCRIPTS += testdriver_cubit.py
 endif	
 
 noinst_tmp = \

Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/TestMeshIOCubit.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/TestMeshIOCubit.py	2009-01-24 14:25:34 UTC (rev 13944)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/TestMeshIOCubit.py	2009-01-24 20:56:17 UTC (rev 13945)
@@ -29,10 +29,7 @@
     """
     Test constructor.
     """
-    iohandler = MeshIOCubit()
-    iohandler._configure()
-    iohandler._sync()
-    self.assertNotEqual(None, iohandler.cppHandle)
+    io = MeshIOCubit()
     return
 
 
@@ -40,10 +37,11 @@
     """
     Test filename().
     """
-    iohandler = MeshIOCubit()
     value = "hi.txt"
-    iohandler.filename = value
-    self.assertEqual(value, iohandler.filename)
+
+    io = MeshIOCubit()
+    io.filename(value)
+    self.assertEqual(value, io.filename())
     return
 
 
@@ -51,27 +49,29 @@
     """
     Test read().
     """
+    filenameIn = "data/twohex8.exo"
+    filenameOut = "data/twohex8_test.txt"
+    filenameE = "data/twohex8.txt"
+    dim = 3
+
     from spatialdata.geocoords.CSCart import CSCart
+    cs = CSCart()
+    cs._configure()
 
     # For now, we only test reading the file.
-    iohandler = MeshIOCubit()
-
-    filenameIn = "data/twohex8.exo"
-    filenameOut = "data/twohex8_test.txt"
-    filenameE = "data/twohex8.txt"
+    io = MeshIOCubit()
+    io.inventory.filename = filenameIn
+    io._configure()
     
     from spatialdata.units.Nondimensional import Nondimensional
     normalizer = Nondimensional()
-    normalizer.initialize()
 
-    iohandler.filename = filenameIn
-    iohandler.coordsys = CSCart()
-    mesh = iohandler.read(normalizer, debug=False, interpolate=False)
+    mesh = io.read(dim, normalizer, debug=False, interpolate=False)
     self.assertEqual(3, mesh.dimension())
 
     testhandler = MeshIOAscii()
-    testhandler.filename = filenameOut
-    testhandler.coordsys = CSCart()
+    testhandler.filename(filenameOut)
+    testhandler.coordsys = cs
     testhandler.write(mesh)
 
     fileE = open(filenameE, "r")



More information about the CIG-COMMITS mailing list