[cig-commits] r7054 - in short/3D/PyLith/trunk: . unittests/libtests/bc unittests/libtests/bc/data unittests/pytests/bc unittests/pytests/feassemble unittests/pytests/topology

brad at geodynamics.org brad at geodynamics.org
Sun Jun 3 19:10:19 PDT 2007


Author: brad
Date: 2007-06-03 19:10:17 -0700 (Sun, 03 Jun 2007)
New Revision: 7054

Added:
   short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletLine2b.cc
   short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletLine2b.hh
   short/3D/PyLith/trunk/unittests/libtests/bc/data/DirichletDataLine2b.cc
   short/3D/PyLith/trunk/unittests/libtests/bc/data/DirichletDataLine2b.hh
Modified:
   short/3D/PyLith/trunk/TODO
   short/3D/PyLith/trunk/unittests/libtests/bc/Makefile.am
   short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichlet.cc
   short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichlet.py
   short/3D/PyLith/trunk/unittests/pytests/feassemble/TestIntegrator.py
   short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenSimple.py
Log:
Added C++ unit test for Dirichlet with no fixedDOF. Added Python unit tests for Contraint.finalize() and Integrator.finalize().

Modified: short/3D/PyLith/trunk/TODO
===================================================================
--- short/3D/PyLith/trunk/TODO	2007-06-03 03:02:01 UTC (rev 7053)
+++ short/3D/PyLith/trunk/TODO	2007-06-04 02:10:17 UTC (rev 7054)
@@ -2,16 +2,10 @@
 MAIN PRIORITIES (Brad)
 ======================================================================
 
+0. Need to change order of basis functions in FIATLagrange cells.
 
-
-0. Incorporate Quad/Hex basis stuff (waiting for Matt to fix)
-
 Replace specific object bins with ObjectBin.
 
-Python unit tests
-  Integrator.finalize()
-  Constraint.finalize()
-
 C++ unit test
   Dirichlet
     test with no fixedDOF

Modified: short/3D/PyLith/trunk/unittests/libtests/bc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/Makefile.am	2007-06-03 03:02:01 UTC (rev 7053)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/Makefile.am	2007-06-04 02:10:17 UTC (rev 7054)
@@ -24,6 +24,7 @@
 	TestBoundaryCondition.cc \
 	TestDirichlet.cc \
 	TestDirichletLine2.cc \
+	TestDirichletLine2b.cc \
 	TestDirichletTri3.cc \
 	TestDirichletQuad4.cc \
 	TestDirichletTet4.cc \
@@ -36,6 +37,7 @@
 	TestBoundaryCondition.hh \
 	TestDirichlet.hh \
 	TestDirichletLine2.hh \
+	TestDirichletLine2b.hh \
 	TestDirichletTri3.hh \
 	TestDirichletQuad4.hh \
 	TestDirichletTet4.hh \
@@ -47,6 +49,7 @@
 testbc_SOURCES += \
 	data/DirichletData.cc \
 	data/DirichletDataLine2.cc \
+	data/DirichletDataLine2b.cc \
 	data/DirichletDataTri3.cc \
 	data/DirichletDataQuad4.cc \
 	data/DirichletDataTet4.cc \
@@ -57,6 +60,7 @@
 noinst_HEADERS += \
 	data/DirichletData.hh \
 	data/DirichletDataLine2.hh \
+	data/DirichletDataLine2b.hh \
 	data/DirichletDataTri3.hh \
 	data/DirichletDataQuad4.hh \
 	data/DirichletDataTet4.hh \

Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichlet.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichlet.cc	2007-06-03 03:02:01 UTC (rev 7053)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichlet.cc	2007-06-04 02:10:17 UTC (rev 7054)
@@ -65,15 +65,18 @@
 
   const int numCells = mesh->heightStratum(0)->size();
 
+  const int numFixedDOF = _data->numFixedDOF;
+  const size_t numPoints = _data->numConstrainedPts;
+
   // Check points
   const int offset = numCells;
-  const size_t numPoints = _data->numConstrainedPts;
-  CPPUNIT_ASSERT_EQUAL(numPoints, bc._points.size());
-  for (int i=0; i < numPoints; ++i)
-    CPPUNIT_ASSERT_EQUAL(_data->constrainedPoints[i]+offset, bc._points[i]);
+  if (numFixedDOF > 0) {
+    CPPUNIT_ASSERT_EQUAL(numPoints, bc._points.size());
+    for (int i=0; i < numPoints; ++i)
+      CPPUNIT_ASSERT_EQUAL(_data->constrainedPoints[i]+offset, bc._points[i]);
+  } // if
 
   // Check values
-  const int numFixedDOF = _data->numFixedDOF;
   const size_t size = numPoints * numFixedDOF;
   CPPUNIT_ASSERT_EQUAL(size, bc._values.size());
   const double tolerance = 1.0e-06;
@@ -232,6 +235,7 @@
   iohandler.filename(_data->meshFilename);
   iohandler.read(mesh);
   CPPUNIT_ASSERT(!mesh->isNull());
+  (*mesh)->getFactory()->clear();
 
   spatialdata::geocoords::CSCart cs;
   cs.setSpaceDim((*mesh)->getDimension());

Added: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletLine2b.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletLine2b.cc	2007-06-03 03:02:01 UTC (rev 7053)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletLine2b.cc	2007-06-04 02:10:17 UTC (rev 7054)
@@ -0,0 +1,39 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDirichletLine2b.hh" // Implementation of class methods
+
+#include "data/DirichletDataLine2b.hh" // USES DirichletDataLine2b
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletLine2b );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::bc::TestDirichletLine2b::setUp(void)
+{ // setUp
+  _data = new DirichletDataLine2b();
+} // setUp
+
+// ----------------------------------------------------------------------
+// Tear down testing data.
+void
+pylith::bc::TestDirichletLine2b::tearDown(void)
+{ // tearDown
+  delete _data;
+} // tearDown
+
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletLine2b.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletLine2b.hh	2007-06-03 03:02:01 UTC (rev 7053)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletLine2b.hh	2007-06-04 02:10:17 UTC (rev 7054)
@@ -0,0 +1,59 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/bc/TestDirichletLine2b.hh
+ *
+ * @brief C++ TestDirichlet object.
+ *
+ * C++ unit testing for Dirichlet for mesh with 1-D line cells.
+ */
+
+#if !defined(pylith_bc_testdirichletline2b_hh)
+#define pylith_bc_testdirichletline2b_hh
+
+#include "TestDirichlet.hh" // ISA TestDirichlet
+
+/// Namespace for pylith package
+namespace pylith {
+  namespace bc {
+    class TestDirichletLine2b;
+  } // bc
+} // pylith
+
+/// C++ unit testing for Dirichlet for mesh with 1-D line cells.
+class pylith::bc::TestDirichletLine2b : public TestDirichlet
+{ // class TestDirichlet
+
+  // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+  CPPUNIT_TEST_SUITE( TestDirichletLine2b );
+  CPPUNIT_TEST( testInitialize );
+  CPPUNIT_TEST( testSetConstraintSizes );
+  CPPUNIT_TEST( testSetConstraints );
+  CPPUNIT_TEST( testSetField );
+  CPPUNIT_TEST_SUITE_END();
+
+  // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+  /// Setup testing data.
+  void setUp(void);
+
+  /// Tear down testing data.
+  void tearDown(void);
+
+}; // class TestDirichletLine2b
+
+#endif // pylith_bc_dirichletline2b_hh
+
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/bc/data/DirichletDataLine2b.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/data/DirichletDataLine2b.cc	2007-06-03 03:02:01 UTC (rev 7053)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/data/DirichletDataLine2b.cc	2007-06-04 02:10:17 UTC (rev 7054)
@@ -0,0 +1,60 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/* Mesh: meshLine2.txt
+ *
+ * Dirichlet BC at vertices 0 and 2.
+ *
+ * Fixed DOF: None
+ */
+
+#include "DirichletDataLine2b.hh"
+
+const int pylith::bc::DirichletDataLine2b::_id = 0;
+
+const char* pylith::bc::DirichletDataLine2b::_label = "bc0";
+
+const int pylith::bc::DirichletDataLine2b::_numDOF = 1;
+const int pylith::bc::DirichletDataLine2b::_numFixedDOF = 0;
+const int pylith::bc::DirichletDataLine2b::_fixedDOF[] = {};
+
+const int pylith::bc::DirichletDataLine2b::_numConstrainedPts = 2;
+const int pylith::bc::DirichletDataLine2b::_constrainedPoints[] = { 0, 2 };
+const double pylith::bc::DirichletDataLine2b::_values[] = {};
+
+const char* pylith::bc::DirichletDataLine2b::_meshFilename = 
+  "data/line2.mesh";
+const char* pylith::bc::DirichletDataLine2b::_dbFilename =
+  "data/line2.spatialdb";
+
+pylith::bc::DirichletDataLine2b::DirichletDataLine2b(void)
+{ // constructor
+  id = _id;
+  label = const_cast<char*>(_label);
+
+  numDOF = _numDOF;
+  numFixedDOF = _numFixedDOF;
+  fixedDOF = const_cast<int*>(_fixedDOF);
+
+  numConstrainedPts = _numConstrainedPts;
+  constrainedPoints = const_cast<int*>(_constrainedPoints);
+  values = const_cast<double*>(_values);
+
+  meshFilename = const_cast<char*>(_meshFilename);
+  dbFilename = const_cast<char*>(_dbFilename);
+} // constructor
+
+pylith::bc::DirichletDataLine2b::~DirichletDataLine2b(void)
+{}
+
+
+// End of file

Added: short/3D/PyLith/trunk/unittests/libtests/bc/data/DirichletDataLine2b.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/data/DirichletDataLine2b.hh	2007-06-03 03:02:01 UTC (rev 7053)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/data/DirichletDataLine2b.hh	2007-06-04 02:10:17 UTC (rev 7054)
@@ -0,0 +1,58 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_bc_dirichletdataline2b_hh)
+#define pylith_bc_dirichletdataline2b_hh
+
+#include "DirichletData.hh"
+
+namespace pylith {
+  namespace bc {
+     class DirichletDataLine2b;
+  } // pylith
+} // bc
+
+class pylith::bc::DirichletDataLine2b : public DirichletData
+{
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public: 
+
+  /// Constructor
+  DirichletDataLine2b(void);
+
+  /// Destructor
+  ~DirichletDataLine2b(void);
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private:
+
+  static const int _numDOF; ///< Number of degrees of freedom at each point.
+
+  static const int _numFixedDOF; ///< Number of fixedDOF at constrained points.
+  static const int _numConstrainedPts; ///< Number of points constrained.
+
+  static const int _id; ///< Boundary condition identifier
+  static const char* _label; /// Label for boundary condition group
+
+  static const int _fixedDOF[]; ///< Degrees of freedom constrained at points
+
+  static const int _constrainedPoints[]; ///< Array of indices of constrained pts.
+  static const double _values[]; ///< Values at constrained points.
+
+  static const char* _meshFilename; ///< Filename of input mesh.
+  static const char* _dbFilename; ///< Filename of simple spatial database.
+};
+
+#endif // pylith_bc_dirichletdataline2b_hh
+
+// End of file

Modified: short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichlet.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichlet.py	2007-06-03 03:02:01 UTC (rev 7053)
+++ short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichlet.py	2007-06-04 02:10:17 UTC (rev 7054)
@@ -50,6 +50,22 @@
     return
 
 
+  def test_finalize(self):
+    """
+    Test finalize().
+
+    WARNING: This is not a rigorous test of finalize() because we
+    don't verify the results.
+    """
+    from pylith.bc.Dirichlet import Dirichlet
+    bc = Dirichlet()
+    bc.finalize()
+
+    # We should really add something here to check to make sure things
+    # actually initialized correctly    
+    return
+
+
   def test_setConstraintSizes(self):
     """
     Test setConstraintSizes().

Modified: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestIntegrator.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestIntegrator.py	2007-06-03 03:02:01 UTC (rev 7053)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestIntegrator.py	2007-06-04 02:10:17 UTC (rev 7054)
@@ -23,7 +23,7 @@
   Unit testing of Python Integrator object.
   """
 
-  def test_constructors(self):
+  def test_constructor(self):
     """
     Test constructor.
     """
@@ -31,4 +31,13 @@
     return
 
 
+  def test_finalize(self):
+    """
+    Test constructor.
+    """
+    i = Integrator()
+    i.finalize()
+    return
+
+
 # End of file 

Modified: short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenSimple.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenSimple.py	2007-06-03 03:02:01 UTC (rev 7053)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenSimple.py	2007-06-04 02:10:17 UTC (rev 7054)
@@ -48,7 +48,7 @@
     io.coordsys = CSCart()
     mesh.coordsys = CSCart()
     io.open(mesh)
-    io.writeTopology(mesh)
+    io.writeTopology()
     io.close()
 
     #from pylith.topology.Distributor import Distributor



More information about the cig-commits mailing list