[cig-commits] r11338 - in short/3D/PyLith/trunk: modulesrc/meshio pylith pylith/meshio unittests/pytests/meshio
brad at geodynamics.org
brad at geodynamics.org
Wed Mar 5 20:23:55 PST 2008
Author: brad
Date: 2008-03-05 20:23:55 -0800 (Wed, 05 Mar 2008)
New Revision: 11338
Added:
short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNorm.py
short/3D/PyLith/trunk/unittests/pytests/meshio/TestCellFilterAvg.py
short/3D/PyLith/trunk/unittests/pytests/meshio/TestVertexFilterVecNorm.py
Modified:
short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src
short/3D/PyLith/trunk/pylith/Makefile.am
short/3D/PyLith/trunk/pylith/meshio/__init__.py
short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am
short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver.py
Log:
Added Python unit tests for CellFilterAvg and VertexFilterVecNorm. Added Python bindings for VertexFilterVecNorm.
Modified: short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src 2008-03-06 00:10:26 UTC (rev 11337)
+++ short/3D/PyLith/trunk/modulesrc/meshio/meshio.pyxe.src 2008-03-06 04:23:55 UTC (rev 11338)
@@ -21,6 +21,7 @@
#include "pylith/meshio/OutputManager.hh"
#include "pylith/meshio/OutputSolnSubset.hh"
#include "pylith/meshio/VertexFilter.hh"
+#include "pylith/meshio/VertexFilterVecNorm.hh"
#if defined(ENABLE_CUBIT)
#include "pylith/meshio/MeshIOCubit.hh"
@@ -1270,4 +1271,68 @@
return
+# ----------------------------------------------------------------------
+cdef void VertexFilter_destructor(void* obj):
+ """
+ Destroy VertexFilter object.
+ """
+ # create shim for destructor
+ #embed{ void VertexFilter_destructor_cpp(void* pObj)
+ pylith::meshio::VertexFilter* f = (pylith::meshio::VertexFilter*) pObj;
+ delete f;
+ #}embed
+ VertexFilter_destructor_cpp(obj)
+ return
+
+cdef class VertexFilter:
+
+ cdef void* thisptr # Pointer to C++ object
+ cdef readonly object handle # PyCObject holding pointer to C++ object
+ cdef readonly object name # Identifier for object base type
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ self.handle = None
+ self.thisptr = NULL
+ self.name = "pylith_meshio_VertexFilter"
+ return
+
+
+ def _createHandle(self):
+ """Wrap pointer to C++ object in PyCObject."""
+ return PyCObject_FromVoidPtr(self.thisptr, VertexFilter_destructor)
+
+
+# ----------------------------------------------------------------------
+cdef class VertexFilterVecNorm(VertexFilter):
+
+ def __init__(self):
+ """Constructor."""
+ # create shim for constructor
+ #embed{ void* VertexFilterVecNorm_constructor()
+ void* result = 0;
+ try {
+ result = (void*)(new pylith::meshio::VertexFilterVecNorm);
+ assert(0 != result);
+ } catch (const std::exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.what()));
+ } catch (const ALE::Exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.msg().c_str()));
+ } catch (...) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Caught unknown C++ exception.");
+ } // try/catch
+ return result;
+ #}embed
+
+ VertexFilter.__init__(self)
+ self.thisptr = VertexFilterVecNorm_constructor()
+ self.handle = self._createHandle()
+ return
+
+
# End of file
Modified: short/3D/PyLith/trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/pylith/Makefile.am 2008-03-06 00:10:26 UTC (rev 11337)
+++ short/3D/PyLith/trunk/pylith/Makefile.am 2008-03-06 04:23:55 UTC (rev 11338)
@@ -88,6 +88,7 @@
meshio/OutputSolnSubset.py \
meshio/SingleOutput.py \
meshio/VertexFilter.py \
+ meshio/VertexFilterVecNorm.py \
problems/__init__.py \
problems/Explicit.py \
problems/Formulation.py \
Added: short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNorm.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNorm.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNorm.py 2008-03-06 04:23:55 UTC (rev 11338)
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/VertexFilterVecNorm.py
+##
+## @brief Python class for computing vector norm for each vertex for
+## field over vertices when writing finite-element data.
+##
+## Factory: output_vertex_filter
+
+from VertexFilter import VertexFilter
+
+# VertexFilterVecNorm class
+class VertexFilterVecNorm(VertexFilter):
+ """
+ Python class for computing vector norm for each vertex for field
+ over vertices when writing finite-element data.
+
+ Factory: output_vertex_filter
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="vertexfiltervecnorm"):
+ """
+ Constructor.
+ """
+ VertexFilter.__init__(self, name)
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _createCppHandle(self):
+ """
+ Create handle to C++ object.
+ """
+ if None == self.cppHandle:
+ import meshio as bindings
+ self.cppHandle = bindings.VertexFilterVecNorm()
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def output_vertex_filter():
+ """
+ Factory associated with VertexFilter.
+ """
+ return VertexFilterVecNorm()
+
+
+# End of file
Modified: short/3D/PyLith/trunk/pylith/meshio/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/__init__.py 2008-03-06 00:10:26 UTC (rev 11337)
+++ short/3D/PyLith/trunk/pylith/meshio/__init__.py 2008-03-06 04:23:55 UTC (rev 11338)
@@ -30,7 +30,9 @@
'OutputSoln',
'OutputSolnSubset',
'SingleOutput',
- 'VertexFilter']
+ 'VertexFilter',
+ 'VertexFilterVecNorm',
+ ]
# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am 2008-03-06 00:10:26 UTC (rev 11337)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am 2008-03-06 04:23:55 UTC (rev 11338)
@@ -23,7 +23,9 @@
noinst_PYTHON = \
TestMeshIOAscii.py \
TestMeshIOCubit.py \
- TestMeshIOLagrit.py
+ TestMeshIOLagrit.py \
+ TestVertexFilterVecNorm.py \
+ TestCellFilterAvg.py
if ENABLE_CUBIT
TESTS += testdriver_cubit.py
Added: short/3D/PyLith/trunk/unittests/pytests/meshio/TestCellFilterAvg.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestCellFilterAvg.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestCellFilterAvg.py 2008-03-06 04:23:55 UTC (rev 11338)
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/meshio/TestCellFilterAvg.py
+
+## @brief Unit testing of Python CellFilterAvg object.
+
+import unittest
+
+from pylith.meshio.CellFilterAvg import CellFilterAvg
+
+# ----------------------------------------------------------------------
+class TestCellFilterAvg(unittest.TestCase):
+ """
+ Unit testing of Python CellFilterAvg object.
+ """
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ filter = CellFilterAvg()
+ filter._configure()
+ return
+
+
+ def test_initialize(self):
+ """
+ Test constructor.
+ """
+ from pylith.feassemble.quadrature.Quadrature1D import Quadrature1D
+
+ from pylith.feassemble.FIATSimplex import FIATSimplex
+ cell = FIATSimplex()
+ cell.shape = "line"
+ cell.degree = 2
+ cell.order = 2
+
+ quadrature = Quadrature1D()
+ quadrature.cell = cell
+ quadrature.preinitialize()
+ quadrature.initialize()
+
+ filter = CellFilterAvg()
+ filter._configure()
+ filter.initialize(quadrature)
+ self.assertNotEqual(None, filter.cppHandle)
+ return
+
+
+ def test_factory(self):
+ """
+ Test factory method.
+ """
+ from pylith.meshio.CellFilterAvg import output_cell_filter
+ filter = output_cell_filter()
+ return
+
+
+# End of file
Added: short/3D/PyLith/trunk/unittests/pytests/meshio/TestVertexFilterVecNorm.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestVertexFilterVecNorm.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestVertexFilterVecNorm.py 2008-03-06 04:23:55 UTC (rev 11338)
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/meshio/TestVertexFilterVecNorm.py
+
+## @brief Unit testing of Python VertexFilterVecNorm object.
+
+import unittest
+
+from pylith.meshio.VertexFilterVecNorm import VertexFilterVecNorm
+
+# ----------------------------------------------------------------------
+class TestVertexFilterVecNorm(unittest.TestCase):
+ """
+ Unit testing of Python VertexFilterVecNorm object.
+ """
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ filter = VertexFilterVecNorm()
+ filter._configure()
+ return
+
+
+ def test_initialize(self):
+ """
+ Test constructor.
+ """
+ filter = VertexFilterVecNorm()
+ filter._configure()
+ filter.initialize()
+ self.assertNotEqual(None, filter.cppHandle)
+ return
+
+
+ def test_factory(self):
+ """
+ Test factory method.
+ """
+ from pylith.meshio.VertexFilterVecNorm import output_vertex_filter
+ filter = output_vertex_filter()
+ return
+
+
+# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver.py 2008-03-06 00:10:26 UTC (rev 11337)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver.py 2008-03-06 04:23:55 UTC (rev 11338)
@@ -60,6 +60,12 @@
from TestMeshIOLagrit import TestMeshIOLagrit
suite.addTest(unittest.makeSuite(TestMeshIOLagrit))
+ from TestVertexFilterVecNorm import TestVertexFilterVecNorm
+ suite.addTest(unittest.makeSuite(TestVertexFilterVecNorm))
+
+ from TestCellFilterAvg import TestCellFilterAvg
+ suite.addTest(unittest.makeSuite(TestCellFilterAvg))
+
return suite
More information about the cig-commits
mailing list