[cig-commits] r6556 - in short/3D/PyLith/trunk: . libsrc/meshio
modulesrc/meshio modulesrc/topology pylith/meshio
pylith/topology unittests/libtests/meshio unittests/pytests
unittests/pytests/materials unittests/pytests/meshio
unittests/pytests/topology
brad at geodynamics.org
brad at geodynamics.org
Thu Apr 12 12:13:56 PDT 2007
Author: brad
Date: 2007-04-12 12:13:55 -0700 (Thu, 12 Apr 2007)
New Revision: 6556
Added:
short/3D/PyLith/trunk/unittests/pytests/topology/
short/3D/PyLith/trunk/unittests/pytests/topology/Makefile.am
short/3D/PyLith/trunk/unittests/pytests/topology/TestMesh.py
short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py
short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshImporter.py
short/3D/PyLith/trunk/unittests/pytests/topology/testdriver.py
Removed:
short/3D/PyLith/trunk/libsrc/meshio/README.txt
short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIO.py
Modified:
short/3D/PyLith/trunk/TODO
short/3D/PyLith/trunk/configure.ac
short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc
short/3D/PyLith/trunk/libsrc/meshio/MeshIO.hh
short/3D/PyLith/trunk/libsrc/meshio/MeshIO.icc
short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src
short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src
short/3D/PyLith/trunk/pylith/meshio/MeshIO.py
short/3D/PyLith/trunk/pylith/topology/Mesh.py
short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py
short/3D/PyLith/trunk/pylith/topology/MeshImporter.py
short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.hh
short/3D/PyLith/trunk/unittests/pytests/Makefile.am
short/3D/PyLith/trunk/unittests/pytests/materials/TestMaterial.py
short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am
short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOAscii.py
short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver.py
Log:
Fixed setting of debug and interpolate flags for PETSc Mesh object. Now set at constructor based on settings in MeshGenerator. Added unit tests for Python topology stuff.
Modified: short/3D/PyLith/trunk/TODO
===================================================================
--- short/3D/PyLith/trunk/TODO 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/TODO 2007-04-12 19:13:55 UTC (rev 6556)
@@ -4,11 +4,6 @@
Error checking
- Fix when Mesh debug is turned on. Make sure set upon creation (pass
- to topology Mesh constructor).
-
- Move interpolate to same location as Mesh debug (not in importer).
-
add isNull() assertions before using ALE::Obj.
add check to material::initialize: material dimension must match
Modified: short/3D/PyLith/trunk/configure.ac
===================================================================
--- short/3D/PyLith/trunk/configure.ac 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/configure.ac 2007-04-12 19:13:55 UTC (rev 6556)
@@ -169,6 +169,7 @@
unittests/pytests/materials/data/Makefile
unittests/pytests/meshio/Makefile
unittests/pytests/meshio/data/Makefile
+ unittests/pytests/topology/Makefile
unittests/pytests/utils/Makefile
doc/Makefile])
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc 2007-04-12 19:13:55 UTC (rev 6556)
@@ -22,6 +22,7 @@
// Constructor
pylith::meshio::MeshIO::MeshIO(void) :
_useIndexZero(true),
+ _debug(false),
_interpolate(false),
_mesh(0)
{ // constructor
@@ -81,19 +82,19 @@
assert(0 != _mesh);
*_mesh = new Mesh(PETSC_COMM_WORLD, meshDim);
- ALE::Obj<Mesh>& mesh = *_mesh;
- mesh.addRef();
-
- ALE::Obj<sieve_type> sieve = new sieve_type(mesh->comm());
+ assert(!_mesh->isNull());
+ (*_mesh)->setDebug(_debug);
+ ALE::Obj<sieve_type> sieve = new sieve_type((*_mesh)->comm());
+
ALE::SieveBuilder<Mesh>::buildTopology(sieve, meshDim,
numCells,
const_cast<int*>(cells),
numVertices,
_interpolate, numCorners);
- mesh->setSieve(sieve);
- mesh->stratify();
- ALE::SieveBuilder<Mesh>::buildCoordinates(mesh, spaceDim, coordinates);
+ (*_mesh)->setSieve(sieve);
+ (*_mesh)->stratify();
+ ALE::SieveBuilder<Mesh>::buildCoordinates(*_mesh, spaceDim, coordinates);
} // _buildMesh
// ----------------------------------------------------------------------
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIO.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIO.hh 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIO.hh 2007-04-12 19:13:55 UTC (rev 6556)
@@ -39,6 +39,18 @@
/// Destructor
virtual ~MeshIO(void);
+ /** Set debug flag for mesh.
+ *
+ * @param flag True to print debugging information.
+ */
+ void debug(const bool flag);
+
+ /** Get debug flag for mesh.
+ *
+ * @returns True if debugging is on.
+ */
+ bool debug(void) const;
+
/** Set flag associated with building intermediate mesh topology
* elements.
*
@@ -187,6 +199,7 @@
private :
bool _useIndexZero; ///< Flag indicating if indicates start at 0 (T) or 1 (F)
+ bool _debug; ///< True to turn of mesh debugging output
bool _interpolate; ///< True if building intermediate topology elements
ALE::Obj<Mesh>* _mesh; ///< Pointer to PETSc mesh object
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIO.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIO.icc 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIO.icc 2007-04-12 19:13:55 UTC (rev 6556)
@@ -28,6 +28,20 @@
_useIndexZero = flag;
}
+// Set debug flag for mesh.
+inline
+void
+pylith::meshio::MeshIO::debug(const bool flag) {
+ _debug = flag;
+}
+
+// Get debug flag for mesh.
+inline
+bool
+pylith::meshio::MeshIO::debug(void) const {
+ return _debug;
+}
+
// Set flag associated with building intermediate mesh topology
inline
void
Deleted: short/3D/PyLith/trunk/libsrc/meshio/README.txt
===================================================================
Modified: short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src 2007-04-12 19:13:55 UTC (rev 6556)
@@ -153,6 +153,42 @@
return MeshIO_interpolate_get(self.thisptr)
+ property debug:
+ def __set__(self, flag):
+ """Set debug."""
+ # create shim for method 'debug'
+ #embed{ void MeshIO_debug_set(void* pObj, int flag)
+ try {
+ ((pylith::meshio::MeshIO*) pObj)->debug(flag);
+ } 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
+ MeshIO_debug_set(self.thisptr, flag)
+
+ def __get__(self):
+ """Get debug."""
+ # create shim for method 'debug'
+ #embed{ int MeshIO_debug_get(void* pObj)
+ int result = 0;
+ try {
+ result = ((pylith::meshio::MeshIO*) pObj)->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
+ return result;
+ #}embed
+ return MeshIO_debug_get(self.thisptr)
+
+
# ----------------------------------------------------------------------
cdef class MeshIOAscii(MeshIO):
Modified: short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src 2007-04-12 19:13:55 UTC (rev 6556)
@@ -74,7 +74,9 @@
#embed{ void* MeshPtr_constructor()
void* result = 0;
try {
- result = (void*)(new ALE::Obj<ALE::Mesh>);
+ ALE::Obj<ALE::Mesh>* mesh = new ALE::Obj<ALE::Mesh>;
+ assert(0 != mesh);
+ result = (void*) mesh;
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
@@ -208,7 +210,9 @@
try {
ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) objVptr;
assert(0 != mesh);
- assert(!mesh->isNull());
+ if (mesh->isNull())
+ throw std::runtime_error("Cannot set debug flag when there is " \
+ "no mesh data.");
(*mesh)->setDebug(value);
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
Modified: short/3D/PyLith/trunk/pylith/meshio/MeshIO.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/MeshIO.py 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/pylith/meshio/MeshIO.py 2007-04-12 19:13:55 UTC (rev 6556)
@@ -24,30 +24,6 @@
Python abstract base class for finite-element mesh I/O.
"""
- # INVENTORY //////////////////////////////////////////////////////////
-
- class Inventory(Component.Inventory):
- """
- Python object for managing MeshIO facilities and properties.
-
- Factory: mesh.
- """
-
- ## @class Inventory
- ## Python object for managing MeshIO facilities and properties.
- ##
- ## \b Properties
- ## @li \b interpolate Build intermediate mesh topology elements (if true)
- ##
- ## \b Facilities
- ## @li None
-
- import pyre.inventory
-
- interpolate = pyre.inventory.bool("interpolate", default=False)
- interpolate.meta['tip'] = "Build intermediate mesh topology elements"
-
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="meshio"):
@@ -56,25 +32,33 @@
"""
Component.__init__(self, name, facility="mesh_io")
self.cppHandle = None
- self.interpolate = False
self.coordsys = None
return
- def read(self):
+ def read(self, debug, interpolate):
"""
Read finite-element mesh and store in Sieve mesh object.
@returns PETSc mesh object containing finite-element mesh
"""
self._info.log("Reading finite-element mesh")
+
+ # Set flags
self._sync()
- from pylith.topology.Mesh import Mesh
- mesh = Mesh()
+ self.cppHandle.debug = debug
+ self.cppHandle.interpolate = interpolate
+
+ # 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)
+
+ # Read mesh
self.cppHandle.read(mesh.cppHandle)
return mesh
@@ -98,7 +82,6 @@
Set members based using inventory.
"""
Component._configure(self)
- self.interpolate = self.inventory.interpolate
return
@@ -106,8 +89,7 @@
"""
Force synchronization between Python and C++.
"""
- self.cppHandle.interpolate = self.interpolate
return
-
+
# End of file
Modified: short/3D/PyLith/trunk/pylith/topology/Mesh.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/Mesh.py 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/pylith/topology/Mesh.py 2007-04-12 19:13:55 UTC (rev 6556)
@@ -34,6 +34,7 @@
import pylith.topology.topology as bindings
self.cppHandle = bindings.Mesh()
self.coordsys = None
+ self.debug = False
return
Modified: short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py 2007-04-12 19:13:55 UTC (rev 6556)
@@ -38,6 +38,7 @@
##
## \b Properties
## @li \b debug Debugging flag for mesh.
+ ## @li \b interpolate Build intermediate mesh topology elements (if true)
##
## \b Facilities
## @li None
@@ -47,7 +48,10 @@
debug = pyre.inventory.bool("debug", default=False)
debug.meta['tip'] = "Debugging flag for mesh."
+ interpolate = pyre.inventory.bool("interpolate", default=False)
+ interpolate.meta['tip'] = "Build intermediate mesh topology elements"
+
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="meshgenerator"):
@@ -55,6 +59,8 @@
Constructor.
"""
Component.__init__(self, name, facility="mesh_generator")
+ self.debug = False
+ self.interpolate = False
return
@@ -74,6 +80,7 @@
"""
Component._configure(self)
self.debug = self.inventory.debug
+ self.interpolate = self.inventory.interpolate
return
Modified: short/3D/PyLith/trunk/pylith/topology/MeshImporter.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/MeshImporter.py 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/pylith/topology/MeshImporter.py 2007-04-12 19:13:55 UTC (rev 6556)
@@ -63,8 +63,7 @@
"""
Hook for creating mesh.
"""
- mesh = self.importer.read()
- mesh.setDebug(self.debug)
+ mesh = self.importer.read(self.debug, self.interpolate)
return mesh
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.cc 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.cc 2007-04-12 19:13:55 UTC (rev 6556)
@@ -14,6 +14,8 @@
#include "TestMeshIO.hh" // Implementation of class methods
+#include "pylith/meshio/MeshIO.hh" // USES MeshIO
+
#include "data/MeshData.hh"
// ----------------------------------------------------------------------
@@ -153,4 +155,33 @@
// :TODO: Check groups of vertices
} // checkVals
+// ----------------------------------------------------------------------
+// Test debug()
+void
+pylith::meshio::TestMeshIO::_testDebug(MeshIO& iohandler)
+{ // testDebug
+ bool debug = false;
+ iohandler.debug(debug);
+ CPPUNIT_ASSERT_EQUAL(debug, iohandler.debug());
+
+ debug = true;
+ iohandler.debug(debug);
+ CPPUNIT_ASSERT_EQUAL(debug, iohandler.debug());
+} // testDebug
+
+// ----------------------------------------------------------------------
+// Test interpolate()
+void
+pylith::meshio::TestMeshIO::_testInterpolate(MeshIO& iohandler)
+{ // testInterpolate
+ bool interpolate = false;
+ iohandler.interpolate(interpolate);
+ CPPUNIT_ASSERT_EQUAL(interpolate, iohandler.interpolate());
+
+ interpolate = true;
+ iohandler.interpolate(interpolate);
+ CPPUNIT_ASSERT_EQUAL(interpolate, iohandler.interpolate());
+} // testInterpolate
+
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.hh 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.hh 2007-04-12 19:13:55 UTC (rev 6556)
@@ -29,6 +29,8 @@
namespace pylith {
namespace meshio {
class TestMeshIO;
+ class MeshIO;
+
class MeshData;
} // meshio
} // pylith
@@ -61,6 +63,21 @@
void checkVals(const ALE::Obj<Mesh>& mesh,
const MeshData& data);
+ // PROTECTED METHODS //////////////////////////////////////////////////
+protected :
+
+ /** Test debug().
+ *
+ * @param iohandler MeshIO object.
+ */
+ void _testDebug(MeshIO& iohandler);
+
+ /** Test interpolate().
+ *
+ * @param iohandler MeshIO object.
+ */
+ void _testInterpolate(MeshIO& iohandler);
+
}; // class TestMeshIO
#endif // pylith_meshio_testmeshio_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.cc 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.cc 2007-04-12 19:13:55 UTC (rev 6556)
@@ -23,8 +23,6 @@
#include "data/MeshData2Din3D.hh"
#include "data/MeshData3D.hh"
-#include <assert.h> // USES assert()
-
// ----------------------------------------------------------------------
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestMeshIOAscii );
@@ -37,6 +35,24 @@
} // testConstructor
// ----------------------------------------------------------------------
+// Test debug()
+void
+pylith::meshio::TestMeshIOAscii::testDebug(void)
+{ // testDebug
+ MeshIOAscii iohandler;
+ _testDebug(iohandler);
+} // testDebug
+
+// ----------------------------------------------------------------------
+// Test interpolate()
+void
+pylith::meshio::TestMeshIOAscii::testInterpolate(void)
+{ // testInterpolate
+ MeshIOAscii iohandler;
+ _testInterpolate(iohandler);
+} // testInterpolate
+
+// ----------------------------------------------------------------------
// Test filename()
void
pylith::meshio::TestMeshIOAscii::testFilename(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.hh 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.hh 2007-04-12 19:13:55 UTC (rev 6556)
@@ -38,6 +38,8 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestMeshIOAscii );
CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testDebug );
+ CPPUNIT_TEST( testInterpolate );
CPPUNIT_TEST( testFilename );
CPPUNIT_TEST( testWriteRead1D );
CPPUNIT_TEST( testWriteRead1Din2D );
@@ -53,6 +55,12 @@
/// Test constructor
void testConstructor(void);
+ /// Test debug()
+ void testDebug(void);
+
+ /// Test interpolate()
+ void testInterpolate(void);
+
/// Test filename()
void testFilename(void);
Modified: short/3D/PyLith/trunk/unittests/pytests/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/Makefile.am 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/unittests/pytests/Makefile.am 2007-04-12 19:13:55 UTC (rev 6556)
@@ -14,6 +14,7 @@
feassemble \
materials \
meshio \
+ topology \
utils
# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestMaterial.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestMaterial.py 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestMaterial.py 2007-04-12 19:13:55 UTC (rev 6556)
@@ -63,7 +63,7 @@
importer = MeshIOAscii()
importer.filename = "data/twoelems.mesh"
importer.coordsys = cs
- mesh = importer.read()
+ mesh = importer.read(debug=False, interpolate=False)
material.initialize(mesh)
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am 2007-04-12 19:13:55 UTC (rev 6556)
@@ -20,7 +20,6 @@
check_SCRIPTS = testdriver.py
noinst_PYTHON = \
- TestMeshIO.py \
TestMeshIOAscii.py
Deleted: short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIO.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIO.py 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIO.py 2007-04-12 19:13:55 UTC (rev 6556)
@@ -1,42 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-## @file unittests/pytests/meshio/TestMeshIO.py
-
-## @brief Unit testing of MeshIO object.
-
-import unittest
-
-# ----------------------------------------------------------------------
-class TestMeshIO(unittest.TestCase):
- """
- Unit testing of MeshIO object.
- """
-
-
- def test_interpolate(self):
- """
- Test interpolate access.
- """
- from pylith.meshio.MeshIO import MeshIO
- iohandler = MeshIO()
-
- value = False # default is False
- self.assertEqual(value, iohandler.interpolate)
-
- value = True
- iohandler.interpolate = value
- self.assertEqual(value, iohandler.interpolate)
- return
-
-
-# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOAscii.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOAscii.py 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOAscii.py 2007-04-12 19:13:55 UTC (rev 6556)
@@ -15,6 +15,7 @@
## @brief Unit testing of Python MeshIOAscii object.
import unittest
+
from pylith.meshio.MeshIOAscii import MeshIOAscii
# ----------------------------------------------------------------------
@@ -28,7 +29,7 @@
Test constructor.
"""
iohandler = MeshIOAscii()
- self.failIf(None == iohandler.cppHandle)
+ self.assertNotEqual(None, iohandler.cppHandle)
return
@@ -36,10 +37,10 @@
"""
Test filename().
"""
- filename = "hi.txt"
iohandler = MeshIOAscii()
- iohandler.filename = filename
- self.assertEqual(filename, iohandler.filename)
+ value = "hi.txt"
+ iohandler.filename = value
+ self.assertEqual(value, iohandler.filename)
return
@@ -47,14 +48,14 @@
"""
Test write() and read().
"""
+ iohandler = MeshIOAscii()
filenameIn = "data/mesh2Din3D.txt"
filenameOut = "data/mesh2Din3D_test.txt"
from spatialdata.geocoords.CSCart import CSCart
- iohandler = MeshIOAscii()
iohandler.filename = filenameIn
iohandler.coordsys = CSCart()
- mesh = iohandler.read()
+ mesh = iohandler.read(debug=False, interpolate=False)
iohandler.filename = filenameOut
iohandler.write(mesh)
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver.py 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver.py 2007-04-12 19:13:55 UTC (rev 6556)
@@ -54,9 +54,6 @@
suite = unittest.TestSuite()
- from TestMeshIO import TestMeshIO
- suite.addTest(unittest.makeSuite(TestMeshIO))
-
from TestMeshIOAscii import TestMeshIOAscii
suite.addTest(unittest.makeSuite(TestMeshIOAscii))
Added: short/3D/PyLith/trunk/unittests/pytests/topology/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/Makefile.am 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/Makefile.am 2007-04-12 19:13:55 UTC (rev 6556)
@@ -0,0 +1,26 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+subpackage = topology
+include $(top_srcdir)/subpackage.am
+
+TESTS = testdriver.py
+
+check_SCRIPTS = testdriver.py
+
+noinst_PYTHON = \
+ TestMesh.py \
+ TestMeshGenerator.py \
+ TestMeshImporter.py
+
+
+# End of file
Added: short/3D/PyLith/trunk/unittests/pytests/topology/TestMesh.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestMesh.py 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestMesh.py 2007-04-12 19:13:55 UTC (rev 6556)
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/topology/TestMesh.py
+
+## @brief Unit testing of Mesh object.
+
+import unittest
+
+from pylith.topology.Mesh import Mesh
+
+# ----------------------------------------------------------------------
+class TestMesh(unittest.TestCase):
+ """
+ Unit testing of Mesh object.
+ """
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ mesh = Mesh()
+ self.assertNotEqual(None, mesh.cppHandle)
+ return
+
+
+ def test_initialize(self):
+ """
+ Test initialize().
+ """
+ from spatialdata.geocoords.CSCart import CSCart
+ cs = CSCart()
+
+ mesh = Mesh()
+ mesh.initialize(cs)
+ self.assertEqual(cs, mesh.coordsys)
+ return
+
+
+# End of file
Added: short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py 2007-04-12 19:13:55 UTC (rev 6556)
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/topology/TestMeshGenerator.py
+
+## @brief Unit testing of MeshGenerator object.
+
+import unittest
+
+from pylith.topology.MeshGenerator import MeshGenerator
+
+# ----------------------------------------------------------------------
+class TestMeshGenerator(unittest.TestCase):
+ """
+ Unit testing of MeshIO object.
+ """
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ generator = MeshGenerator()
+ return
+
+
+ def test_debug(self):
+ """
+ Test debug().
+ """
+ generator = MeshGenerator()
+
+ value = False # default should be False
+ self.assertTrue(value == generator.debug)
+
+ value = True
+ generator.debug = value
+ self.assertTrue(value == generator.debug)
+ return
+
+
+ def test_interpolate(self):
+ """
+ Test interpolate access.
+ """
+ generator = MeshGenerator()
+
+ value = False # default should be False
+ self.assertEqual(value, generator.interpolate)
+
+ value = True
+ generator.interpolate = value
+ self.assertEqual(value, generator.interpolate)
+ return
+
+
+# End of file
Added: short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshImporter.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshImporter.py 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshImporter.py 2007-04-12 19:13:55 UTC (rev 6556)
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/topology/TestMeshImporter.py
+
+## @brief Unit testing of MeshImporter object.
+
+import unittest
+
+from pylith.topology.MeshImporter import MeshImporter
+
+# ----------------------------------------------------------------------
+class TestMeshImporter(unittest.TestCase):
+ """
+ Unit testing of MeshIO object.
+ """
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ importer = MeshImporter()
+ return
+
+
+# End of file
Added: short/3D/PyLith/trunk/unittests/pytests/topology/testdriver.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/testdriver.py 2007-04-12 17:30:02 UTC (rev 6555)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/testdriver.py 2007-04-12 19:13:55 UTC (rev 6556)
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/topology/testdriver.py
+
+## @brief Python application for testing topology code.
+
+from pyre.applications.Script import Script
+
+import unittest
+
+class TestApp(Script):
+ """
+ Test application.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="testapp"):
+ """
+ Constructor.
+ """
+ Script.__init__(self, name)
+ return
+
+
+ def main(self):
+ """
+ Run the application.
+ """
+ unittest.TextTestRunner(verbosity=2).run(self._suite())
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _suite(self):
+ """
+ Setup the test suite.
+ """
+
+ suite = unittest.TestSuite()
+
+ from TestMesh import TestMesh
+ suite.addTest(unittest.makeSuite(TestMesh))
+
+ from TestMeshGenerator import TestMeshGenerator
+ suite.addTest(unittest.makeSuite(TestMeshGenerator))
+
+ from TestMeshImporter import TestMeshImporter
+ suite.addTest(unittest.makeSuite(TestMeshImporter))
+
+ return suite
+
+
+# ----------------------------------------------------------------------
+if __name__ == '__main__':
+ app = TestApp()
+ app.run()
+
+
+# End of file
Property changes on: short/3D/PyLith/trunk/unittests/pytests/topology/testdriver.py
___________________________________________________________________
Name: svn:executable
+ *
More information about the cig-commits
mailing list