[cig-commits] r11336 - in short/3D/PyLith/trunk: libsrc/meshio unittests/libtests/meshio

brad at geodynamics.org brad at geodynamics.org
Wed Mar 5 15:40:19 PST 2008


Author: brad
Date: 2008-03-05 15:40:19 -0800 (Wed, 05 Mar 2008)
New Revision: 11336

Added:
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.hh
Modified:
   short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh
   short/3D/PyLith/trunk/libsrc/meshio/OutputSolnSubset.hh
   short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am
Log:
Added C++ unit tests for OutputSolnSubset.

Modified: short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh	2008-03-05 23:16:00 UTC (rev 11335)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh	2008-03-05 23:40:19 UTC (rev 11336)
@@ -41,10 +41,10 @@
 
 class pylith::meshio::OutputManager
 { // OutputManager
+  friend class TestOutputManager; // unit testing
 
 // PUBLIC METHODS ///////////////////////////////////////////////////////
 public :
-  friend class TestOutputManager; // unit testing
 
   /// Constructor
   OutputManager(void);

Modified: short/3D/PyLith/trunk/libsrc/meshio/OutputSolnSubset.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputSolnSubset.hh	2008-03-05 23:16:00 UTC (rev 11335)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputSolnSubset.hh	2008-03-05 23:40:19 UTC (rev 11336)
@@ -28,11 +28,14 @@
 namespace pylith {
   namespace meshio {
     class OutputSolnSubset;
+
+    class TestOutputSolnSubset; // unit testing
   } // meshio
 } // pylith
 
 class pylith::meshio::OutputSolnSubset : public OutputManager
 { // OutputSolnSubset
+  friend class TestOutputSolnSubset; // unit testing
 
 // PUBLIC METHODS ///////////////////////////////////////////////////////
 public :

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am	2008-03-05 23:16:00 UTC (rev 11335)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am	2008-03-05 23:40:19 UTC (rev 11336)
@@ -47,6 +47,7 @@
 	TestMeshIOAscii.cc \
 	TestMeshIOLagrit.cc \
 	TestOutputManager.cc \
+	TestOutputSolnSubset.cc \
 	test_meshio.cc
 
 
@@ -76,7 +77,8 @@
 	TestMeshIO.hh \
 	TestMeshIOAscii.hh \
 	TestMeshIOLagrit.hh \
-	TestOutputManager.hh
+	TestOutputManager.hh \
+	TestOutputSolnSubset.hh
 
 
 # Source files associated with testing data

Added: short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.cc	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.cc	2008-03-05 23:40:19 UTC (rev 11336)
@@ -0,0 +1,109 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestOutputSolnSubset.hh" // Implementation of class methods
+
+#include "pylith/meshio/OutputSolnSubset.hh"
+
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestOutputSolnSubset );
+
+// ----------------------------------------------------------------------
+// Test constructor
+void
+pylith::meshio::TestOutputSolnSubset::testConstructor(void)
+{ // testConstructor
+  OutputSolnSubset output;
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test label()
+void
+pylith::meshio::TestOutputSolnSubset::testLabel(void)
+{ // testLabel
+  OutputSolnSubset output;
+
+  const char* label = "boundary";
+
+  output.label(label);
+  CPPUNIT_ASSERT(0 == strcmp(label, output._label.c_str()));
+} // testLabel
+
+// ----------------------------------------------------------------------
+// Test subdomainMesh()
+void
+pylith::meshio::TestOutputSolnSubset::testSubdomainMesh(void)
+{ // testSubdomainMesh
+  const char* filename = "data/quad4.mesh";
+  const char* label = "bc3";
+  const int nvertices = 3;
+  const int verticesE[] = { 2, 4, 6 };
+  const int ncells = 2;
+  const int ncorners = 2;
+  const int cellsE[] = { 2, 4, 4, 6 };
+
+  MeshIOAscii iohandler;
+  ALE::Obj<Mesh> mesh;
+  iohandler.filename("data/quad4.mesh");
+  iohandler.read(&mesh);
+  CPPUNIT_ASSERT(!mesh.isNull());
+  mesh->getFactory()->clear();
+
+  OutputSolnSubset output;
+  output.label(label);
+  const ALE::Obj<Mesh> submesh = output.subdomainMesh(mesh);
+
+  // Check vertices
+  const ALE::Obj<Mesh::label_sequence>& vertices = submesh->depthStratum(0);
+  const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+  CPPUNIT_ASSERT_EQUAL(nvertices, int(vertices->size()));
+  int ipt = 0;
+  for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+       v_iter != verticesEnd;
+       ++v_iter, ++ipt)
+    CPPUNIT_ASSERT_EQUAL(verticesE[ipt], *v_iter);
+
+  // Check cells
+  const ALE::Obj<Mesh::label_sequence>& cells = submesh->heightStratum(1);
+  const Mesh::label_sequence::iterator cellsEnd = cells->end();
+  const ALE::Obj<sieve_type>& sieve = submesh->getSieve();
+  assert(!sieve.isNull());
+  typedef ALE::SieveAlg<Mesh> SieveAlg;
+
+  CPPUNIT_ASSERT_EQUAL(ncells, int(cells->size()));
+
+  int icell = 0;
+  int index = 0;
+  for (Mesh::label_sequence::iterator c_iter=cells->begin();
+       c_iter != cellsEnd;
+       ++c_iter, ++icell) {
+    const int depth = 1;
+    const ALE::Obj<SieveAlg::coneArray>& cone = 
+      SieveAlg::nCone(submesh, *c_iter, depth);
+    assert(!cone.isNull());
+    const SieveAlg::coneArray::iterator vEnd = cone->end();
+
+    CPPUNIT_ASSERT_EQUAL(ncorners, int(cone->size()));
+    
+    for(SieveAlg::coneArray::iterator v_iter=cone->begin();
+	v_iter != vEnd;
+	++v_iter, ++index)
+      CPPUNIT_ASSERT_EQUAL(cellsE[index], *v_iter);
+  } // for
+} // testSubdomainMesh
+
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.hh	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.hh	2008-03-05 23:40:19 UTC (rev 11336)
@@ -0,0 +1,62 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/meshio/TestOutputSolnSubset.hh
+ *
+ * @brief C++ TestOutputSolnSubset object
+ *
+ * C++ unit testing for OutputSolnSubset.
+ */
+
+#if !defined(pylith_meshio_testoutputsolnsubset_hh)
+#define pylith_meshio_testoutputsolnsubset_hh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+/// Namespace for pylith package
+namespace pylith {
+  namespace meshio {
+    class TestOutputSolnSubset;
+  } // meshio
+} // pylith
+
+/// C++ unit testing for OutputSolnSubset
+class pylith::meshio::TestOutputSolnSubset : public CppUnit::TestFixture
+{ // class TestOutputSolnSubset
+
+  // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+  CPPUNIT_TEST_SUITE( TestOutputSolnSubset );
+
+  CPPUNIT_TEST( testConstructor );
+  CPPUNIT_TEST( testLabel );
+  CPPUNIT_TEST( testSubdomainMesh );
+
+  CPPUNIT_TEST_SUITE_END();
+
+  // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+  /// Test constructor
+  void testConstructor(void);
+
+  /// Test label()
+  void testLabel(void);
+
+  /// Test subdomainMesh()
+  void testSubdomainMesh(void);
+
+}; // class TestOutputSolnSubset
+
+#endif // pylith_meshio_testoutputsolnsubset_hh
+
+// End of file 



More information about the cig-commits mailing list