[cig-commits] r6926 - in short/3D/PyLith/trunk: . pylith/topology unittests/pytests/topology unittests/pytests/topology/data

brad at geodynamics.org brad at geodynamics.org
Fri May 18 12:08:43 PDT 2007


Author: brad
Date: 2007-05-18 12:08:31 -0700 (Fri, 18 May 2007)
New Revision: 6926

Added:
   short/3D/PyLith/trunk/unittests/pytests/topology/data/
   short/3D/PyLith/trunk/unittests/pytests/topology/data/Makefile.am
   short/3D/PyLith/trunk/unittests/pytests/topology/data/tri3.mesh
Modified:
   short/3D/PyLith/trunk/configure.ac
   short/3D/PyLith/trunk/pylith/topology/Mesh.py
   short/3D/PyLith/trunk/unittests/pytests/topology/Makefile.am
   short/3D/PyLith/trunk/unittests/pytests/topology/TestMesh.py
Log:
Added some more Python unit tests for Mesh (creating/allocating sections and sparse matrix).

Modified: short/3D/PyLith/trunk/configure.ac
===================================================================
--- short/3D/PyLith/trunk/configure.ac	2007-05-18 18:54:27 UTC (rev 6925)
+++ short/3D/PyLith/trunk/configure.ac	2007-05-18 19:08:31 UTC (rev 6926)
@@ -241,6 +241,7 @@
 		unittests/pytests/meshio/Makefile
 		unittests/pytests/meshio/data/Makefile
 		unittests/pytests/topology/Makefile
+		unittests/pytests/topology/data/Makefile
 		unittests/pytests/utils/Makefile
                 doc/Makefile])
 

Modified: short/3D/PyLith/trunk/pylith/topology/Mesh.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/Mesh.py	2007-05-18 18:54:27 UTC (rev 6925)
+++ short/3D/PyLith/trunk/pylith/topology/Mesh.py	2007-05-18 19:08:31 UTC (rev 6926)
@@ -69,7 +69,7 @@
     """
     Get MPI communicator associated with mesh.
     """
-    #comm = None
+    comm = None
     #if not self.cppHandle is None:
     #  comm = self.cppHandle.comm
     import mpi
@@ -109,7 +109,7 @@
     return self.cppHandle.createMatrix(field)
   
 
-  # PUBLIC METHODS /////////////////////////////////////////////////////
+  # PRIVATE METHODS ////////////////////////////////////////////////////
 
   def _configure(self):
     """

Modified: short/3D/PyLith/trunk/unittests/pytests/topology/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/Makefile.am	2007-05-18 18:54:27 UTC (rev 6925)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/Makefile.am	2007-05-18 19:08:31 UTC (rev 6926)
@@ -13,6 +13,8 @@
 subpackage = topology
 include $(top_srcdir)/subpackage.am
 
+SUBDIRS = data
+
 TESTS = testdriver.py
 
 check_SCRIPTS = testdriver.py

Modified: short/3D/PyLith/trunk/unittests/pytests/topology/TestMesh.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestMesh.py	2007-05-18 18:54:27 UTC (rev 6925)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestMesh.py	2007-05-18 19:08:31 UTC (rev 6926)
@@ -46,4 +46,97 @@
     return
 
 
+  def test_comm(self):
+    """
+    Test comm().
+    """
+    mesh = self._getMesh()
+    comm = mesh.comm()
+    import mpi
+    self.assertEqual(mpi.MPI_COMM_WORLD, comm)
+    return
+
+
+  def test_getRealSection(self):
+    """
+    Test createRealSection().
+
+    WARNING: This is not a rigorous test of createRealSection()
+    because we don't verify the results.
+    """
+    mesh = self._getMesh()
+    field = mesh.getRealSection("field")
+
+    # We should really add something here to check to make sure things
+    # actually initialized correctly.
+    return
+
+
+  def test_createRealSection(self):
+    """
+    Test createRealSection().
+
+    WARNING: This is not a rigorous test of createRealSection()
+    because we don't verify the results.
+    """
+    mesh = self._getMesh()
+    field = mesh.createRealSection("field", fiberDim=2)
+
+    # We should really add something here to check to make sure things
+    # actually initialized correctly.
+    return
+
+
+  def test_allocateRealSection(self):
+    """
+    Test createRealSection().
+
+    WARNING: This is not a rigorous test of createRealSection()
+    because we don't verify the results.
+    """
+    mesh = self._getMesh()
+    field = mesh.createRealSection("field", fiberDim=2)
+    mesh.allocateRealSection(field)
+
+    # We should really add something here to check to make sure things
+    # actually initialized correctly.
+    return
+
+
+  def test_createMatrix(self):
+    """
+    Test createRealSection().
+
+    WARNING: This is not a rigorous test of createRealSection()
+    because we don't verify the results.
+    """
+    mesh = self._getMesh()
+    field = mesh.createRealSection("field", fiberDim=2)
+    mesh.allocateRealSection(field)
+    matrix = mesh.createMatrix(field)
+
+    # We should really add something here to check to make sure things
+    # actually initialized correctly.
+    return
+
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _getMesh(self):
+    """
+    Get mesh from file.
+    """
+    from spatialdata.geocoords.CSCart import CSCart
+    cs = CSCart()
+    cs.spaceDim = 2
+
+    from pylith.meshio.MeshIOAscii import MeshIOAscii
+    importer = MeshIOAscii()
+    importer.filename = "data/tri3.mesh"
+    importer.coordsys = cs
+    mesh = importer.read(debug=False, interpolate=False)
+    
+    return mesh
+  
+
 # End of file 

Added: short/3D/PyLith/trunk/unittests/pytests/topology/data/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/data/Makefile.am	2007-05-18 18:54:27 UTC (rev 6925)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/data/Makefile.am	2007-05-18 19:08:31 UTC (rev 6926)
@@ -0,0 +1,29 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+noinst_DATA = \
+	tri3.mesh
+
+noinst_TMP =
+
+# 'export' the input files by performing a mock install
+export_datadir = $(top_builddir)/unittests/pytests/topology/data
+export-data: $(noinst_DATA)
+	for f in $(noinst_DATA); do $(install_sh_DATA) $(srcdir)/$$f $(export_datadir); done
+
+BUILT_SOURCES = export-data
+
+CLEANFILES = \
+	$(export_datadir)/$(noinst_DATA)
+
+
+# End of file 

Added: short/3D/PyLith/trunk/unittests/pytests/topology/data/tri3.mesh
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/data/tri3.mesh	2007-05-18 18:54:27 UTC (rev 6925)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/data/tri3.mesh	2007-05-18 19:08:31 UTC (rev 6926)
@@ -0,0 +1,42 @@
+mesh = {
+  dimension = 2
+  use-index-zero = true
+  vertices = {
+    dimension = 2
+    count = 4
+    coordinates = {
+             0     -1.0  0.0
+             1      0.0 -1.0
+             2      0.0  1.0
+             3      1.0  0.0
+    }
+  }
+  cells = {
+    count = 2
+    num-corners = 3
+    simplices = {
+             0       0  1  2
+             1       1  3  2
+    }
+    material-ids = {
+             0   0
+             1   0
+    }
+  }
+  group = {
+    name = bc
+    type = vertices
+    count = 2
+    indices = {
+      1  3
+    }
+  }
+  group = {
+    name = bc2
+    type = vertices
+    count = 1
+    indices = {
+      0
+    }
+  }
+}



More information about the cig-commits mailing list