[cig-commits] r21714 - in short/3D/PyLith/trunk: libsrc/pylith/topology unittests/libtests/topology

brad at geodynamics.org brad at geodynamics.org
Thu Apr 4 09:32:40 PDT 2013


Author: brad
Date: 2013-04-04 09:32:40 -0700 (Thu, 04 Apr 2013)
New Revision: 21714

Modified:
   short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.icc
   short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.cc
   short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.hh
Log:
Fixed bug in getting cell info for submesh. Added appropriate unit tests to trap error.

Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.icc	2013-04-04 01:56:28 UTC (rev 21713)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.icc	2013-04-04 16:32:40 UTC (rev 21714)
@@ -110,7 +110,7 @@
   if (_newMesh) {
     PetscErrorCode err;
     PetscInt cStart = 0;
-    err = DMPlexGetHeightStratum(_newMesh, 0, &cStart, NULL);CHECK_PETSC_ERROR(err);
+    err = DMPlexGetHeightStratum(_newMesh, 1, &cStart, NULL);CHECK_PETSC_ERROR(err);
     err = DMPlexGetConeSize(_newMesh, cStart, &coneSize);CHECK_PETSC_ERROR(err);
   } // if
   return coneSize;
@@ -136,7 +136,7 @@
   PetscInt ncells = 0;
   if (_newMesh) {
     PetscInt begin=0, end=0;
-    PetscErrorCode err = DMPlexGetHeightStratum(_newMesh, 0, &begin, &end);CHECK_PETSC_ERROR(err);
+    PetscErrorCode err = DMPlexGetHeightStratum(_newMesh, 1, &begin, &end);CHECK_PETSC_ERROR(err);
     ncells = end-begin;
   } // if
   return ncells;

Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.cc	2013-04-04 01:56:28 UTC (rev 21713)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.cc	2013-04-04 16:32:40 UTC (rev 21714)
@@ -37,11 +37,11 @@
       const int nvertices = 4;
       const int ncells = 2;
       const int ncorners = 3;
-      const int cells[] = {
+      const int cells[ncells*ncorners] = {
 	0, 1, 3,
 	0, 3, 2,
       };
-      const PylithScalar coordinates[] = {
+      const PylithScalar coordinates[nvertices*cellDim] = {
 	0.0, 0.0,
 	1.0, 0.0,
 	0.0, 1.0,
@@ -52,6 +52,7 @@
       const int groupVertices[groupSize] = {
 	1, 2, 3,
       };
+      const int submeshNumCorners = 2;
       const int submeshNumVertices = groupSize;
       const int submeshVertices[submeshNumVertices] = {
 	2, 3, 4,
@@ -217,6 +218,52 @@
 } // testDimension
 
 // ----------------------------------------------------------------------
+// Test coneSize().
+void
+pylith::topology::TestSubMesh::testConeSize(void)
+{ // testConeSize
+  PYLITH_METHOD_BEGIN;
+
+  Mesh mesh;
+  _buildMesh(&mesh);
+
+  SubMesh submesh(mesh, _TestSubMesh::label);
+  CPPUNIT_ASSERT_EQUAL(_TestSubMesh::submeshNumCorners, submesh.coneSize());
+
+  PYLITH_METHOD_END;
+} // testConeSize
+
+// ----------------------------------------------------------------------
+// Test numVertices().
+void
+pylith::topology::TestSubMesh::testNumVertices(void)
+{ // testNumVertices
+  PYLITH_METHOD_BEGIN;
+
+  Mesh mesh;
+  _buildMesh(&mesh);
+  SubMesh submesh(mesh, _TestSubMesh::label);
+  CPPUNIT_ASSERT_EQUAL(_TestSubMesh::submeshNumVertices, submesh.numVertices());
+
+  PYLITH_METHOD_END;
+} // testNumVertices
+
+// ----------------------------------------------------------------------
+// Test numCells().
+void
+pylith::topology::TestSubMesh::testNumCells(void)
+{ // testNumCells
+  PYLITH_METHOD_BEGIN;
+
+  Mesh mesh;
+  _buildMesh(&mesh);
+  SubMesh submesh(mesh, _TestSubMesh::label);
+  CPPUNIT_ASSERT_EQUAL(_TestSubMesh::submeshNumCells, submesh.numCells());
+
+  PYLITH_METHOD_END;
+} // testNumCells
+
+// ----------------------------------------------------------------------
 // Test comm().
 void
 pylith::topology::TestSubMesh::testComm(void)

Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.hh	2013-04-04 01:56:28 UTC (rev 21713)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.hh	2013-04-04 16:32:40 UTC (rev 21714)
@@ -52,6 +52,9 @@
   CPPUNIT_TEST( testCoordsys );
   CPPUNIT_TEST( testDebug );
   CPPUNIT_TEST( testDimension );
+  CPPUNIT_TEST( testConeSize );
+  CPPUNIT_TEST( testNumVertices );
+  CPPUNIT_TEST( testNumCells );
   CPPUNIT_TEST( testComm );
   CPPUNIT_TEST( testInitialize );
 
@@ -78,6 +81,15 @@
   /// Test dimension().
   void testDimension(void);
 
+  /// Test coneSize().
+  void testConeSize(void);
+
+  /// Test numVertices().
+  void testNumVertices(void);
+
+  /// Test numCells().
+  void testNumCells(void);
+
   /// Test comm().
   void testComm(void);
 



More information about the CIG-COMMITS mailing list