[cig-commits] r19756 - in short/3D/PyLith/trunk/unittests/pytests/meshio: . data
brad at geodynamics.org
brad at geodynamics.org
Thu Mar 8 17:38:14 PST 2012
Author: brad
Date: 2012-03-08 17:38:13 -0800 (Thu, 08 Mar 2012)
New Revision: 19756
Added:
short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputSolnPoints.py
short/3D/PyLith/trunk/unittests/pytests/meshio/data/points.txt
Modified:
short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am
short/3D/PyLith/trunk/unittests/pytests/meshio/data/Makefile.am
short/3D/PyLith/trunk/unittests/pytests/meshio/testmeshio.py
Log:
Added some Python unit tests for OutputSolnPoints.
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am 2012-03-09 01:27:46 UTC (rev 19755)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am 2012-03-09 01:38:13 UTC (rev 19756)
@@ -35,6 +35,7 @@
TestOutputManagerMesh.py \
TestOutputManagerSubMesh.py \
TestOutputSolnSubset.py \
+ TestOutputSolnPoints.py \
TestDataWriterVTK.py \
TestDataWriterHDF5.py \
TestDataWriterHDF5Ext.py \
Added: short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputSolnPoints.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputSolnPoints.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputSolnPoints.py 2012-03-09 01:38:13 UTC (rev 19756)
@@ -0,0 +1,192 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard, U.S. Geological Survey
+# Charles A. Williams, GNS Science
+# Matthew G. Knepley, University of Chicago
+#
+# This code was developed as part of the Computational Infrastructure
+# for Geodynamics (http://geodynamics.org).
+#
+# Copyright (c) 2010-2012 University of California, Davis
+#
+# See COPYING for license information.
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/meshio/TestOutputSolnPoints.py
+
+## @brief Unit testing of Python OutputSolnPoints object.
+
+import unittest
+
+from pylith.meshio.OutputSolnPoints import OutputSolnPoints
+
+# ----------------------------------------------------------------------
+class TestOutputSolnPoints(unittest.TestCase):
+ """
+ Unit testing of Python OutputSolnPoints object.
+ """
+
+ def setUp(self):
+ from pylith.meshio.MeshIOAscii import MeshIOAscii
+ iohandler = MeshIOAscii()
+ filename = "data/twohex8.txt"
+
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ normalizer._configure()
+
+ from spatialdata.geocoords.CSCart import CSCart
+ iohandler.inventory.filename = filename
+ iohandler.inventory.coordsys = CSCart()
+ iohandler._configure()
+ mesh = iohandler.read(debug=False, interpolate=False)
+
+ from pylith.topology.SolutionFields import SolutionFields
+ fields = SolutionFields(mesh)
+
+ name = "disp(t)"
+ fields.add(name, "displacement")
+ fields.solutionName(name)
+ field = fields.get(name)
+ field.newSection(field.VERTICES_FIELD, mesh.dimension())
+ field.allocate()
+
+ self.mesh = mesh
+ self.fields = fields
+ self.normalizer = normalizer
+ return
+
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ output = OutputSolnPoints()
+ output.inventory.writer._configure()
+ output.inventory.reader.inventory.filename = "data/points.txt"
+ output.inventory.reader._configure()
+ output._configure()
+ return
+
+
+ def test_preinitialize(self):
+ """
+ Test preinitialize().
+ """
+ output = OutputSolnPoints()
+ output.inventory.reader.inventory.filename = "data/points.txt"
+ output.inventory.reader._configure()
+ output._configure()
+ output.preinitialize()
+
+ self.assertEqual(output, output.dataProvider)
+ return
+
+
+ def test_verifyConfiguration(self):
+ """
+ Test verifyConfiguration().
+ """
+ output = OutputSolnPoints()
+ output.inventory.reader.inventory.filename = "data/points.txt"
+ output.inventory.reader._configure()
+ output._configure()
+ output.preinitialize()
+
+ output.vertexDataFields = ["displacement"]
+ output.verifyConfiguration(self.mesh)
+ return
+
+
+ def test_initialize(self):
+ """
+ Test initialize().
+ """
+ output = OutputSolnPoints()
+ output.inventory.reader.inventory.filename = "data/points.txt"
+ output.inventory.reader._configure()
+ output.inventory.writer.inventory.filename = "test.vtk"
+ output.inventory.writer._configure()
+ output._configure()
+
+ output.preinitialize()
+ output.initialize(self.mesh, self.normalizer)
+ return
+
+
+ def test_openclose(self):
+ """
+ Test open() and close().
+ """
+ output = OutputSolnPoints()
+ output.inventory.reader.inventory.filename = "data/points.txt"
+ output.inventory.reader._configure()
+ output.inventory.writer.inventory.filename = "test.vtk"
+ output.inventory.writer._configure()
+ output._configure()
+
+ output.preinitialize()
+ output.initialize(self.mesh, self.normalizer)
+
+ from pyre.units.time import s
+ output.open(totalTime=5.0*s, numTimeSteps=2)
+ output.close()
+ return
+
+
+ def test_writeInfo(self):
+ """
+ Test writeInfo().
+ """
+ output = OutputSolnPoints()
+ output.inventory.reader.inventory.filename = "data/points.txt"
+ output.inventory.reader._configure()
+ output.inventory.writer.inventory.filename = "output_sub.vtk"
+ output.inventory.writer._configure()
+ output._configure()
+
+ output.preinitialize()
+ output.initialize(self.mesh, self.normalizer)
+
+ output.open(totalTime=5.0, numTimeSteps=2)
+ output.writeInfo()
+ output.close()
+ return
+
+
+ def test_writeData(self):
+ """
+ Test writeData().
+ """
+ output = OutputSolnPoints()
+ output.inventory.reader.inventory.filename = "data/points.txt"
+ output.inventory.reader._configure()
+ output.inventory.writer.inventory.filename = "outputsub.vtk"
+ output.inventory.writer.inventory.timeFormat = "%3.1f"
+ output.inventory.writer._configure()
+ output.inventory.vertexDataFields = ["displacement"]
+ output._configure()
+
+ output.preinitialize()
+ output.initialize(self.mesh, self.normalizer)
+
+ output.open(totalTime=5.0, numTimeSteps=2)
+ output.writeData(2.0, self.fields)
+ output.close()
+ return
+
+
+ def test_factory(self):
+ """
+ Test factory method.
+ """
+ from pylith.meshio.OutputSolnPoints import output_manager
+ o = output_manager()
+ return
+
+
+# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/data/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/data/Makefile.am 2012-03-09 01:27:46 UTC (rev 19755)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/data/Makefile.am 2012-03-09 01:38:13 UTC (rev 19756)
@@ -22,7 +22,8 @@
cube2_ascii.pset \
cube2.txt \
twohex8.exo \
- twohex8.txt
+ twohex8.txt \
+ points.txt
noinst_TMP = \
cube2_test.txt \
Added: short/3D/PyLith/trunk/unittests/pytests/meshio/data/points.txt
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/data/points.txt (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/data/points.txt 2012-03-09 01:38:13 UTC (rev 19756)
@@ -0,0 +1,4 @@
+# Here are some points within the volume of the hex8 mesh.
+ 0.5 0.2 0.0
+-0.5 0.2 0.0
+ 0.5 -0.2 0.0
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/testmeshio.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/testmeshio.py 2012-03-09 01:27:46 UTC (rev 19755)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/testmeshio.py 2012-03-09 01:38:13 UTC (rev 19756)
@@ -98,6 +98,9 @@
from TestOutputSolnSubset import TestOutputSolnSubset
suite.addTest(unittest.makeSuite(TestOutputSolnSubset))
+ from TestOutputSolnPoints import TestOutputSolnPoints
+ suite.addTest(unittest.makeSuite(TestOutputSolnPoints))
+
from TestSingleOutput import TestSingleOutput
suite.addTest(unittest.makeSuite(TestSingleOutput))
More information about the CIG-COMMITS
mailing list