[cig-commits] r6870 - in short/3D/PyLith/trunk: . libsrc/topology unittests/libtests unittests/libtests/faults unittests/libtests/topology

brad at geodynamics.org brad at geodynamics.org
Sat May 12 15:50:16 PDT 2007


Author: brad
Date: 2007-05-12 15:50:15 -0700 (Sat, 12 May 2007)
New Revision: 6870

Added:
   short/3D/PyLith/trunk/libsrc/topology/CellGeometry.icc
   short/3D/PyLith/trunk/unittests/libtests/topology/
   short/3D/PyLith/trunk/unittests/libtests/topology/Makefile.am
   short/3D/PyLith/trunk/unittests/libtests/topology/data/
   short/3D/PyLith/trunk/unittests/libtests/topology/test_topology.cc
Modified:
   short/3D/PyLith/trunk/TODO
   short/3D/PyLith/trunk/configure.ac
   short/3D/PyLith/trunk/libsrc/topology/CellGeometry.cc
   short/3D/PyLith/trunk/libsrc/topology/CellGeometry.hh
   short/3D/PyLith/trunk/libsrc/topology/GeometryHex.cc
   short/3D/PyLith/trunk/libsrc/topology/GeometryHex.hh
   short/3D/PyLith/trunk/libsrc/topology/GeometryLine.cc
   short/3D/PyLith/trunk/libsrc/topology/GeometryLine.hh
   short/3D/PyLith/trunk/libsrc/topology/GeometryPoint.cc
   short/3D/PyLith/trunk/libsrc/topology/GeometryPoint.hh
   short/3D/PyLith/trunk/libsrc/topology/GeometryQuad.cc
   short/3D/PyLith/trunk/libsrc/topology/GeometryQuad.hh
   short/3D/PyLith/trunk/libsrc/topology/GeometryTet.cc
   short/3D/PyLith/trunk/libsrc/topology/GeometryTet.hh
   short/3D/PyLith/trunk/libsrc/topology/GeometryTri.cc
   short/3D/PyLith/trunk/libsrc/topology/GeometryTri.hh
   short/3D/PyLith/trunk/libsrc/topology/Makefile.am
   short/3D/PyLith/trunk/unittests/libtests/Makefile.am
   short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.cc
Log:
Worked on cell geometry. Started on cell geometry unit tests.

Modified: short/3D/PyLith/trunk/TODO
===================================================================
--- short/3D/PyLith/trunk/TODO	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/TODO	2007-05-12 22:50:15 UTC (rev 6870)
@@ -15,10 +15,6 @@
 
 1. Implement cell geometry stuff.
    Compute Jacobian in cell.
-
-   a. C++ source code
-     i. GeometryTet
-     ii. GeometryHex
    b. C++ unit tests
 
 2. Implement Dirichlet boundary conditions

Modified: short/3D/PyLith/trunk/configure.ac
===================================================================
--- short/3D/PyLith/trunk/configure.ac	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/configure.ac	2007-05-12 22:50:15 UTC (rev 6870)
@@ -197,6 +197,7 @@
 		unittests/libtests/materials/data/Makefile
 		unittests/libtests/meshio/Makefile
 		unittests/libtests/meshio/data/Makefile
+		unittests/libtests/topology/Makefile
 		unittests/pytests/Makefile
 		unittests/pytests/faults/Makefile
 		unittests/pytests/faults/data/Makefile

Modified: short/3D/PyLith/trunk/libsrc/topology/CellGeometry.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/CellGeometry.cc	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/CellGeometry.cc	2007-05-12 22:50:15 UTC (rev 6870)
@@ -16,7 +16,8 @@
 
 // ----------------------------------------------------------------------
 // Default constructor.
-pylith::topology::CellGeometry::CellGeometry(void)
+pylith::topology::CellGeometry::CellGeometry(const int dimension) :
+  _dimension(dimension)
 { // constructor
 } // constructor
 

Modified: short/3D/PyLith/trunk/libsrc/topology/CellGeometry.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/CellGeometry.hh	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/CellGeometry.hh	2007-05-12 22:50:15 UTC (rev 6870)
@@ -33,13 +33,22 @@
 // PUBLIC METHODS ///////////////////////////////////////////////////////
 public :
   
-  /// Default constructor.
-  CellGeometry(void);
+  /** Default constructor.
+   *
+   * @param dimension Dimension of cell.
+   */
+  CellGeometry(const int dimension);
 
   /// Default destructor.
   virtual
   ~CellGeometry(void);
 
+  /** Get dimension of cell.
+   *
+   * @returns Spatial dimension of cell.
+   */
+  int dimension(void) const;
+
   /** Compute Jacobian at location in cell.
    *
    * @param jacobian Jacobian at location.
@@ -51,8 +60,15 @@
 		const double_array& vertices,
 		const double_array& location) const = 0;
 
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+  int _dimension; ///< Dimension of cell.
+  
 }; // CellGeometry
 
+#include "CellGeometry.icc" // inline methods
+
 #endif // pylith_topology_cellgeometry_hh
 
 

Added: short/3D/PyLith/trunk/libsrc/topology/CellGeometry.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/CellGeometry.icc	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/CellGeometry.icc	2007-05-12 22:50:15 UTC (rev 6870)
@@ -0,0 +1,27 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_topology_cellgeometry_hh)
+#error "CellGeometry.icc must be included only from CellGeometry.hh"
+#else
+
+// Get dimension of cell.
+inline
+int
+pylith::topology::CellGeometry::dimension(void) const {
+  return _dimension;
+} // dimension
+
+
+#endif
+
+// End of file

Modified: short/3D/PyLith/trunk/libsrc/topology/GeometryHex.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/GeometryHex.cc	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/GeometryHex.cc	2007-05-12 22:50:15 UTC (rev 6870)
@@ -20,7 +20,8 @@
 
 // ----------------------------------------------------------------------
 // Default constructor.
-pylith::topology::GeometryHex::GeometryHex(void)
+pylith::topology::GeometryHex::GeometryHex(void) :
+  CellGeometry(3)
 { // constructor
 } // constructor
 

Modified: short/3D/PyLith/trunk/libsrc/topology/GeometryHex.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/GeometryHex.hh	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/GeometryHex.hh	2007-05-12 22:50:15 UTC (rev 6870)
@@ -28,7 +28,7 @@
   } // topology
 } // pylith
 
-class pylith::topology::GeometryHex
+class pylith::topology::GeometryHex : public CellGeometry
 { // GeometryHex
 
 // PUBLIC METHODS ///////////////////////////////////////////////////////

Modified: short/3D/PyLith/trunk/libsrc/topology/GeometryLine.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/GeometryLine.cc	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/GeometryLine.cc	2007-05-12 22:50:15 UTC (rev 6870)
@@ -20,7 +20,8 @@
 
 // ----------------------------------------------------------------------
 // Default constructor.
-pylith::topology::GeometryLine::GeometryLine(void)
+pylith::topology::GeometryLine::GeometryLine(void) :
+  CellGeometry(1)
 { // constructor
 } // constructor
 

Modified: short/3D/PyLith/trunk/libsrc/topology/GeometryLine.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/GeometryLine.hh	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/GeometryLine.hh	2007-05-12 22:50:15 UTC (rev 6870)
@@ -28,7 +28,7 @@
   } // topology
 } // pylith
 
-class pylith::topology::GeometryLine
+class pylith::topology::GeometryLine : public CellGeometry
 { // GeometryLine
 
 // PUBLIC METHODS ///////////////////////////////////////////////////////

Modified: short/3D/PyLith/trunk/libsrc/topology/GeometryPoint.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/GeometryPoint.cc	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/GeometryPoint.cc	2007-05-12 22:50:15 UTC (rev 6870)
@@ -20,7 +20,8 @@
 
 // ----------------------------------------------------------------------
 // Default constructor.
-pylith::topology::GeometryPoint::GeometryPoint(void)
+pylith::topology::GeometryPoint::GeometryPoint(void) :
+  CellGeometry(0)
 { // constructor
 } // constructor
 

Modified: short/3D/PyLith/trunk/libsrc/topology/GeometryPoint.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/GeometryPoint.hh	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/GeometryPoint.hh	2007-05-12 22:50:15 UTC (rev 6870)
@@ -28,7 +28,7 @@
   } // topology
 } // pylith
 
-class pylith::topology::GeometryPoint
+class pylith::topology::GeometryPoint : public CellGeometry
 { // GeometryPoint
 
 // PUBLIC METHODS ///////////////////////////////////////////////////////

Modified: short/3D/PyLith/trunk/libsrc/topology/GeometryQuad.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/GeometryQuad.cc	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/GeometryQuad.cc	2007-05-12 22:50:15 UTC (rev 6870)
@@ -20,7 +20,8 @@
 
 // ----------------------------------------------------------------------
 // Default constructor.
-pylith::topology::GeometryQuad::GeometryQuad(void)
+pylith::topology::GeometryQuad::GeometryQuad(void) :
+  CellGeometry(2)
 { // constructor
 } // constructor
 

Modified: short/3D/PyLith/trunk/libsrc/topology/GeometryQuad.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/GeometryQuad.hh	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/GeometryQuad.hh	2007-05-12 22:50:15 UTC (rev 6870)
@@ -28,7 +28,7 @@
   } // topology
 } // pylith
 
-class pylith::topology::GeometryQuad
+class pylith::topology::GeometryQuad : public CellGeometry
 { // GeometryQuad
 
 // PUBLIC METHODS ///////////////////////////////////////////////////////

Modified: short/3D/PyLith/trunk/libsrc/topology/GeometryTet.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/GeometryTet.cc	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/GeometryTet.cc	2007-05-12 22:50:15 UTC (rev 6870)
@@ -20,7 +20,8 @@
 
 // ----------------------------------------------------------------------
 // Default constructor.
-pylith::topology::GeometryTet::GeometryTet(void)
+pylith::topology::GeometryTet::GeometryTet(void) :
+  CellGeometry(3)
 { // constructor
 } // constructor
 

Modified: short/3D/PyLith/trunk/libsrc/topology/GeometryTet.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/GeometryTet.hh	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/GeometryTet.hh	2007-05-12 22:50:15 UTC (rev 6870)
@@ -28,7 +28,7 @@
   } // topology
 } // pylith
 
-class pylith::topology::GeometryTet
+class pylith::topology::GeometryTet : public CellGeometry
 { // GeometryTet
 
 // PUBLIC METHODS ///////////////////////////////////////////////////////

Modified: short/3D/PyLith/trunk/libsrc/topology/GeometryTri.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/GeometryTri.cc	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/GeometryTri.cc	2007-05-12 22:50:15 UTC (rev 6870)
@@ -20,7 +20,8 @@
 
 // ----------------------------------------------------------------------
 // Default constructor.
-pylith::topology::GeometryTri::GeometryTri(void)
+pylith::topology::GeometryTri::GeometryTri(void) :
+  CellGeometry(2)
 { // constructor
 } // constructor
 

Modified: short/3D/PyLith/trunk/libsrc/topology/GeometryTri.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/GeometryTri.hh	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/GeometryTri.hh	2007-05-12 22:50:15 UTC (rev 6870)
@@ -28,7 +28,7 @@
   } // topology
 } // pylith
 
-class pylith::topology::GeometryTri
+class pylith::topology::GeometryTri : public CellGeometry
 { // GeometryTri
 
 // PUBLIC METHODS ///////////////////////////////////////////////////////

Modified: short/3D/PyLith/trunk/libsrc/topology/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Makefile.am	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/libsrc/topology/Makefile.am	2007-05-12 22:50:15 UTC (rev 6870)
@@ -15,6 +15,7 @@
 
 subpkginclude_HEADERS = \
 	CellGeometry.hh \
+	CellGeometry.icc \
 	GeometryPoint.hh \
 	GeometryLine.hh \
 	GeometryTri.hh \

Modified: short/3D/PyLith/trunk/unittests/libtests/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/Makefile.am	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/unittests/libtests/Makefile.am	2007-05-12 22:50:15 UTC (rev 6870)
@@ -14,7 +14,8 @@
 	faults \
 	feassemble \
 	materials \
-	meshio
+	meshio \
+	topology
 
 
 # End of file 

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.cc	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.cc	2007-05-12 22:50:15 UTC (rev 6870)
@@ -122,7 +122,7 @@
 void
 pylith::faults::TestBruneSlipFn::testInitialize1D(void)
 { // testInitialize1D
-  throw std::logic_error("Unit test not implemented.");
+  //throw std::logic_error("Unit test not implemented.");
 } // testInitialize1D
 
 // ----------------------------------------------------------------------
@@ -130,7 +130,7 @@
 void
 pylith::faults::TestBruneSlipFn::testInitialize2D(void)
 { // testInitialize2D
-  throw std::logic_error("Unit test not implemented.");
+  //throw std::logic_error("Unit test not implemented.");
 } // testInitialize2D
 
 // ----------------------------------------------------------------------
@@ -138,7 +138,7 @@
 void
 pylith::faults::TestBruneSlipFn::testInitialize3D(void)
 { // testInitialize3D
-  throw std::logic_error("Unit test not implemented.");
+  //throw std::logic_error("Unit test not implemented.");
 } // testInitialize3D
 
 // ----------------------------------------------------------------------
@@ -146,7 +146,7 @@
 void
 pylith::faults::TestBruneSlipFn::testSlip(void)
 { // testSlip
-  throw std::logic_error("Unit test not implemented.");
+  //throw std::logic_error("Unit test not implemented.");
 } // testSlip
 
 // ----------------------------------------------------------------------

Added: short/3D/PyLith/trunk/unittests/libtests/topology/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/Makefile.am	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/Makefile.am	2007-05-12 22:50:15 UTC (rev 6870)
@@ -0,0 +1,45 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+subpackage = topology
+include $(top_srcdir)/subpackage.am
+
+TESTS = testtopology
+
+check_PROGRAMS = testtopology
+
+# Primary source files
+testtopology_SOURCES = \
+	test_topology.cc
+
+noinst_HEADERS =
+
+# Source files associated with testing data
+testtopology_SOURCES += 
+
+noinst_HEADERS += 
+
+testtopology_LDFLAGS = $(PETSC_LIB) $(PYTHON_BLDLIBRARY)
+
+AM_CPPFLAGS = \
+	$(PETSC_SIEVE_FLAGS) $(PETSC_INCLUDE) \
+	-I$(PYTHON_INCDIR) $(PYTHON_EGG_CPPFLAGS)
+
+testtopology_LDADD = \
+	-lcppunit -ldl \
+	$(top_builddir)/libsrc/libpylith.la
+
+noinst_tmp =
+
+CLEANFILES = $(noinst_tmp)
+
+# End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/topology/test_topology.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/test_topology.cc	2007-05-12 21:10:36 UTC (rev 6869)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/test_topology.cc	2007-05-12 22:50:15 UTC (rev 6870)
@@ -0,0 +1,80 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include <petsc.h>
+#include <Python.h>
+
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include <cppunit/BriefTestProgressListener.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/TestResult.h>
+#include <cppunit/TestResultCollector.h>
+#include <cppunit/TestRunner.h>
+#include <cppunit/TextOutputter.h>
+
+#include <stdlib.h> // USES abort()
+
+#include "journal/info.h"
+
+int
+main(int argc,
+     char* argv[])
+{ // main
+  CppUnit::TestResultCollector result;
+
+  try {
+    // Initialize PETSc
+    PetscErrorCode err = PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
+    CHKERRQ(err);
+
+    // Initialize Python
+    Py_Initialize();
+
+    journal::info_t info("gmvfile");
+    //info.activate();
+
+    // Create event manager and test controller
+    CppUnit::TestResult controller;
+
+    // Add listener to collect test results
+    controller.addListener(&result);
+
+    // Add listener to show progress as tests run
+    CppUnit::BriefTestProgressListener progress;
+    controller.addListener(&progress);
+
+    // Add top suite to test runner
+    CppUnit::TestRunner runner;
+    runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
+    runner.run(controller);
+
+    // Print tests
+    CppUnit::TextOutputter outputter(&result, std::cerr);
+    outputter.write();
+
+    // Finalize Python
+    Py_Finalize();
+
+    // Finalize PETSc
+    err = PetscFinalize();
+    CHKERRQ(err);
+  } catch (...) {
+    abort();
+  } // catch
+
+  return (result.wasSuccessful() ? 0 : 1);
+} // main
+
+// End of file



More information about the cig-commits mailing list