[cig-commits] r13942 - in short/3D/PyLith/branches/pylith-swig: libsrc/meshio modulesrc/meshio pylith/meshio unittests/pytests/meshio
brad at geodynamics.org
brad at geodynamics.org
Fri Jan 23 21:13:22 PST 2009
Author: brad
Date: 2009-01-23 21:13:22 -0800 (Fri, 23 Jan 2009)
New Revision: 13942
Added:
short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/MeshIOLagrit.i
Modified:
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/MeshIOLagrit.hh
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/MeshIOLagrit.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/TestMeshIOAscii.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/TestMeshIOLagrit.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/testdriver.py
Log:
Updated TestMeshIOLagrit tests.
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/MeshIOLagrit.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/MeshIOLagrit.hh 2009-01-24 05:12:57 UTC (rev 13941)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/MeshIOLagrit.hh 2009-01-24 05:13:22 UTC (rev 13942)
@@ -11,7 +11,7 @@
//
/**
- * @file pylith/meshio/MeshIOLagrit.hh
+ * @file libsrc/meshio/MeshIOLagrit.hh
*
* @brief Input/output manager for LaGriT GMV and Pset files.
*/
Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/Makefile.am 2009-01-24 05:12:57 UTC (rev 13941)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/Makefile.am 2009-01-24 05:13:22 UTC (rev 13942)
@@ -20,7 +20,8 @@
swig_sources = \
meshio.i \
MeshIOObj.i \
- MeshIOAscii.i
+ MeshIOAscii.i \
+ MeshIOLagrit.i
swig_generated = \
meshio_wrap.cxx \
Added: short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/MeshIOLagrit.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/MeshIOLagrit.i (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/MeshIOLagrit.i 2009-01-24 05:13:22 UTC (rev 13942)
@@ -0,0 +1,124 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/MeshIOLagrit.i
+ *
+ * @brief Python interface to C++ MeshIOLagrit object.
+ */
+
+namespace pylith {
+ namespace meshio {
+
+ class MeshIOLagrit : public MeshIO
+ { // MeshIOLagrit
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ MeshIOLagrit(void);
+
+ /// Destructor
+ ~MeshIOLagrit(void);
+
+ /** Set filename for mesh GMV file.
+ *
+ * @param filename Name of file
+ */
+ void filenameGmv(const char* name);
+
+ /** Get filename of mesh GMV file.
+ *
+ * @returns Name of file
+ */
+ const char* filenameGmv(void) const;
+
+ /** Set filename for PSET mesh file.
+ *
+ * @param filename Name of file
+ */
+ void filenamePset(const char* name);
+
+ /** Get filename of PSET mesh file.
+ *
+ * @returns Name of file
+ */
+ const char* filenamePset(void) const;
+
+ /** Set flag to write ASCII or binary files.
+ *
+ * @param flag True if writing ASCII, false if writing binary
+ */
+ void writerAscii(const bool flag);
+
+ /** Get flag for writing ASCII or binary files.
+ *
+ * @returns True if writing ASCII, false if writing binary.
+ */
+ bool writeAscii(void) const;
+
+ /** Set flag to flip endian type when reading/writing from binary files.
+ *
+ * @param flag True if flipping endian, false otherwise
+ */
+ void flipEndian(const bool flag);
+
+ /** Get flag for flipping endian type when reading/writing from
+ * binary files.
+ *
+ * @returns True if flipping endian, false othewise.
+ */
+ bool flipEndian(void) const;
+
+ /** Set flag indicating LaGriT Pset files use 32-bit integers.
+ *
+ * @param flag True if using 32-bit integers, false if using
+ * 64-bit integers.
+ */
+ void ioInt32(const bool flag);
+
+ /** Get flag indicating LaGriT Pset files use 32-bit integers.
+ *
+ * @returns True if using 32-bit integers, false if using 64-bit integers.
+ */
+ bool ioInt32(void) const;
+
+ /** Set Fortran record header size flag.
+ *
+ * @param flag True if Fortran record header size is 32-bit,
+ * false if 64-bit.
+ */
+ void isRecordHeader32Bit(const bool flag);
+
+ /** Get Fortran record header size flag.
+ *
+ * @param returns True if Fortran record header size is 32-bit,
+ * false if 64-bit.
+ */
+ bool isRecordHeader32Bit(void) const;
+
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /// Write mesh
+ void _write(void) const;
+
+ /// Read mesh
+ void _read(void);
+
+ }; // MeshIOLagrit
+
+ } // 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 05:12:57 UTC (rev 13941)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/meshio.i 2009-01-24 05:13:22 UTC (rev 13942)
@@ -17,6 +17,7 @@
%{
#include "pylith/meshio/MeshIO.hh"
#include "pylith/meshio/MeshIOAscii.hh"
+#include "pylith/meshio/MeshIOLagrit.hh"
#include "pylith/utils/arrayfwd.hh"
%}
@@ -35,6 +36,7 @@
// Interfaces
%include "MeshIOObj.i"
%include "MeshIOAscii.i"
+%include "MeshIOLagrit.i"
// End of file
Modified: short/3D/PyLith/branches/pylith-swig/pylith/meshio/MeshIOLagrit.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/meshio/MeshIOLagrit.py 2009-01-24 05:12:57 UTC (rev 13941)
+++ short/3D/PyLith/branches/pylith-swig/pylith/meshio/MeshIOLagrit.py 2009-01-24 05:13:22 UTC (rev 13942)
@@ -17,10 +17,11 @@
##
## Factory: mesh_io
-from MeshIO import MeshIO
+from MeshIOObj import MeshIOObj
+from meshio import MeshIOLagrit as ModuleMeshIOLagrit
# MeshIOLagrit class
-class MeshIOLagrit(MeshIO):
+class MeshIOLagrit(MeshIOObj, ModuleMeshIOLagrit):
"""
Python object for reading/writing finite-element mesh from LaGriT.
@@ -29,7 +30,7 @@
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(MeshIO.Inventory):
+ class Inventory(MeshIOObj.Inventory):
"""
Python object for managing MeshIOLagrit facilities and properties.
"""
@@ -78,7 +79,7 @@
"""
Constructor.
"""
- MeshIO.__init__(self, name)
+ MeshIOObj.__init__(self, name)
return
@@ -88,30 +89,21 @@
"""
Set members based using inventory.
"""
- MeshIO._configure(self)
- self.filenameGmv = self.inventory.filenameGmv
- self.filenamePset = self.inventory.filenamePset
+ MeshIOObj._configure(self)
self.coordsys = self.inventory.coordsys
- self.flipEndian = self.inventory.flipEndian
- self.ioInt32 = self.inventory.ioInt32
- self.isRecordHeader32Bit = self.inventory.isRecordHeader32Bit
+ self.filenameGmv(self.inventory.filenameGmv)
+ self.filenamePset(self.inventory.filenamePset)
+ self.flipEndian(self.inventory.flipEndian)
+ self.ioInt32(self.inventory.ioInt32)
+ self.isRecordHeader32Bit(self.inventory.isRecordHeader32Bit)
return
- def _sync(self):
+ def _createModuleObj(self):
"""
- Force synchronization between Python and C++.
+ Create C++ MeshIOAscii object.
"""
- if None == self.cppHandle:
- import pylith.meshio.meshio as bindings
- self.cppHandle = bindings.MeshIOLagrit()
-
- MeshIO._sync(self)
- self.cppHandle.filenameGmv = self.filenameGmv
- self.cppHandle.filenamePset = self.filenamePset
- self.cppHandle.flipEndian = self.flipEndian
- self.cppHandle.ioInt32 = self.ioInt32
- self.cppHandle.isRecordHeader32Bit = self.isRecordHeader32Bit
+ ModuleMeshIOLagrit.__init__(self)
return
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/TestMeshIOAscii.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/TestMeshIOAscii.py 2009-01-24 05:12:57 UTC (rev 13941)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/TestMeshIOAscii.py 2009-01-24 05:13:22 UTC (rev 13942)
@@ -65,7 +65,6 @@
normalizer = Nondimensional()
mesh = io.read(dim, normalizer, debug=False, interpolate=False)
-
self.assertEqual(2, mesh.dimension())
io.filename(filenameOut)
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/TestMeshIOLagrit.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/TestMeshIOLagrit.py 2009-01-24 05:12:57 UTC (rev 13941)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/TestMeshIOLagrit.py 2009-01-24 05:13:22 UTC (rev 13942)
@@ -29,10 +29,7 @@
"""
Test constructor.
"""
- iohandler = MeshIOLagrit()
- iohandler._configure()
- iohandler._sync()
- self.assertNotEqual(None, iohandler.cppHandle)
+ io = MeshIOLagrit()
return
@@ -40,14 +37,14 @@
"""
Test filename().
"""
- iohandler = MeshIOLagrit()
- iohandler._configure()
valueGmv = "hi.txt"
valuePset = "hi2.txt"
- iohandler.filenameGmv = valueGmv
- iohandler.filenamePset = valuePset
- self.assertEqual(valueGmv, iohandler.filenameGmv)
- self.assertEqual(valuePset, iohandler.filenamePset)
+
+ io = MeshIOLagrit()
+ io.filenameGmv(valueGmv)
+ io.filenamePset(valuePset)
+ self.assertEqual(valueGmv, io.filenameGmv())
+ self.assertEqual(valuePset, io.filenamePset())
return
@@ -55,31 +52,32 @@
"""
Test read().
"""
+ filenameGmvIn = "data/cube2_ascii.gmv"
+ filenamePsetIn = "data/cube2_ascii.pset"
+ filenameOut = "data/cube2_test.txt"
+ filenameE = "data/cube2.txt"
+ dim = 3
+
from spatialdata.geocoords.CSCart import CSCart
+ cs = CSCart()
+ cs._configure()
# For now, we only test reading the file. We would like to write
# the file and compare against the original.
- iohandler = MeshIOLagrit()
- iohandler._configure()
+ io = MeshIOLagrit()
+ io.inventory.filenameGmv = filenameGmvIn
+ io.inventory.filenamePset = filenamePsetIn
+ io._configure()
- filenameGmvIn = "data/cube2_ascii.gmv"
- filenamePsetIn = "data/cube2_ascii.pset"
- filenameOut = "data/cube2_test.txt"
- filenameE = "data/cube2.txt"
-
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
- normalizer.initialize()
- iohandler.filenameGmv = filenameGmvIn
- iohandler.filenamePset = filenamePsetIn
- 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")
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/testdriver.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/testdriver.py 2009-01-24 05:12:57 UTC (rev 13941)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/testdriver.py 2009-01-24 05:13:22 UTC (rev 13942)
@@ -59,8 +59,8 @@
from TestMeshIOAscii import TestMeshIOAscii
suite.addTest(unittest.makeSuite(TestMeshIOAscii))
- #from TestMeshIOLagrit import TestMeshIOLagrit
- #suite.addTest(unittest.makeSuite(TestMeshIOLagrit))
+ from TestMeshIOLagrit import TestMeshIOLagrit
+ suite.addTest(unittest.makeSuite(TestMeshIOLagrit))
#from TestVertexFilterVecNorm import TestVertexFilterVecNorm
#suite.addTest(unittest.makeSuite(TestVertexFilterVecNorm))
More information about the CIG-COMMITS
mailing list