[cig-commits] r6929 - in short/3D/PyLith/trunk: .
unittests/libtests/topology unittests/libtests/topology/data
brad at geodynamics.org
brad at geodynamics.org
Fri May 18 20:58:53 PDT 2007
Author: brad
Date: 2007-05-18 20:58:53 -0700 (Fri, 18 May 2007)
New Revision: 6929
Added:
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.cc
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.hh
short/3D/PyLith/trunk/unittests/libtests/topology/data/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/topology/data/tri3.mesh
Modified:
short/3D/PyLith/trunk/configure.ac
short/3D/PyLith/trunk/unittests/libtests/topology/Makefile.am
Log:
Started work on C++ FieldsManager unit tests.
Modified: short/3D/PyLith/trunk/configure.ac
===================================================================
--- short/3D/PyLith/trunk/configure.ac 2007-05-19 00:33:56 UTC (rev 6928)
+++ short/3D/PyLith/trunk/configure.ac 2007-05-19 03:58:53 UTC (rev 6929)
@@ -230,6 +230,7 @@
unittests/libtests/meshio/Makefile
unittests/libtests/meshio/data/Makefile
unittests/libtests/topology/Makefile
+ unittests/libtests/topology/data/Makefile
unittests/pytests/Makefile
unittests/pytests/bc/Makefile
unittests/pytests/bc/data/Makefile
Modified: short/3D/PyLith/trunk/unittests/libtests/topology/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/Makefile.am 2007-05-19 00:33:56 UTC (rev 6928)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/Makefile.am 2007-05-19 03:58:53 UTC (rev 6929)
@@ -13,6 +13,8 @@
subpackage = topology
include $(top_srcdir)/subpackage.am
+SUBDIRS = data
+
TESTS = testtopology
check_PROGRAMS = testtopology
@@ -20,6 +22,7 @@
# Primary source files
testtopology_SOURCES = \
TestCellGeometry.cc \
+ TestFieldsManager.cc \
TestGeometryPoint1D.cc \
TestGeometryPoint2D.cc \
TestGeometryPoint3D.cc \
@@ -36,6 +39,7 @@
noinst_HEADERS =
TestCellGeometry.hh \
+ TestFieldsManager.hh \
TestGeometryPoint1D.hh \
TestGeometryPoint2D.hh \
TestGeometryPoint3D.hh \
Added: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.cc 2007-05-19 00:33:56 UTC (rev 6928)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.cc 2007-05-19 03:58:53 UTC (rev 6929)
@@ -0,0 +1,120 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestFieldsManager.hh" // Implementation of class methods
+
+#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
+
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+
+#include <stdexcept> // TEMPORARY
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestFieldsManager );
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::topology::TestFieldsManager::testConstructor(void)
+{ // testConstructor
+ ALE::Obj<Mesh> mesh;
+ _initialize(&mesh);
+ FieldsManager manager(mesh);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test addReal().
+void
+pylith::topology::TestFieldsManager::testAddReal(void)
+{ // testAddReal
+ ALE::Obj<Mesh> mesh;
+ _initialize(&mesh);
+ FieldsManager manager(mesh);
+
+ const char* label = "field";
+ manager.addReal(label);
+ const size_t size = 1;
+ CPPUNIT_ASSERT_EQUAL(size, manager._real.size());
+} // testAddReal
+
+// ----------------------------------------------------------------------
+// Test getReal().
+void
+pylith::topology::TestFieldsManager::testGetReal(void)
+{ // testGetReal
+ ALE::Obj<Mesh> mesh;
+ _initialize(&mesh);
+ FieldsManager manager(mesh);
+
+ const char* label = "field";
+ manager.addReal(label);
+ const ALE::Obj<real_section_type>& field = manager.getReal(label);
+ CPPUNIT_ASSERT(!field.isNull());
+} // testGetReal
+
+// ----------------------------------------------------------------------
+// Test delReal().
+void
+pylith::topology::TestFieldsManager::testDelReal(void)
+{ // testDelReal
+ ALE::Obj<Mesh> mesh;
+ _initialize(&mesh);
+ FieldsManager manager(mesh);
+
+ const char* labelA = "field A";
+ manager.addReal(labelA);
+
+ const char* labelB = "field B";
+ manager.addReal(labelB);
+
+ size_t size = 2;
+ CPPUNIT_ASSERT_EQUAL(size, manager._real.size());
+ manager.delReal(labelA);
+ size = 1;
+ CPPUNIT_ASSERT_EQUAL(size, manager._real.size());
+ const ALE::Obj<real_section_type>& field = manager.getReal(labelB);
+ CPPUNIT_ASSERT(!field.isNull());
+} // testDelReal
+
+// ----------------------------------------------------------------------
+// Test copyLayout().
+void
+pylith::topology::TestFieldsManager::testCopyLayout(void)
+{ // testCopyLayout
+ throw std::logic_error("Unit test not implemented.");
+} // testCopyLayout
+
+// ----------------------------------------------------------------------
+// Test copyLayoutFromField().
+void
+pylith::topology::TestFieldsManager::testCopyLayoutFromField(void)
+{ // testCopyLayoutFromField
+ throw std::logic_error("Unit test not implemented.");
+} // testCopyLayoutFromField
+
+// ----------------------------------------------------------------------
+void
+pylith::topology::TestFieldsManager::_initialize(ALE::Obj<Mesh>* mesh) const
+{ // _initialize
+ CPPUNIT_ASSERT(0 != mesh);
+
+ meshio::MeshIOAscii iohandler;
+ iohandler.filename("data/tri3.mesh");
+ iohandler.read(mesh);
+ CPPUNIT_ASSERT(!mesh->isNull());
+} // _initialize
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.hh 2007-05-19 00:33:56 UTC (rev 6928)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.hh 2007-05-19 03:58:53 UTC (rev 6929)
@@ -0,0 +1,86 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/topology/TestFieldsManager.hh
+ *
+ * @brief C++ TestFieldsManager object.
+ *
+ * C++ unit testing for FieldsManager.
+ */
+
+#if !defined(pylith_topology_testfieldsmanager_hh)
+#define pylith_topology_testfieldsmanager_hh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "pylith/utils/sievefwd.hh" // USES PETSc Mesh
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace topology {
+ class TestFieldsManager;
+
+ class FieldsManager;
+ } // topology
+} // pylith
+
+/// C++ unit testing for FieldsManager.
+class pylith::topology::TestFieldsManager : public CppUnit::TestFixture
+{ // class TestFieldsManager
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestFieldsManager );
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testAddReal );
+ CPPUNIT_TEST( testGetReal );
+ CPPUNIT_TEST( testDelReal );
+ CPPUNIT_TEST( testCopyLayout );
+ CPPUNIT_TEST( testCopyLayoutFromField );
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Test constructor.
+ void testConstructor(void);
+
+ /// Test addReal().
+ void testAddReal(void);
+
+ /// Test getReal().
+ void testGetReal(void);
+
+ /// Test delReal().
+ void testDelReal(void);
+
+ /// Test copyLayout().
+ void testCopyLayout(void);
+
+ /// Test copyLayoutFromField().
+ void testCopyLayoutFromField(void);
+
+ // PRIVATE METHODS ////////////////////////////////////////////////////
+private :
+
+ /** Initialize FieldsManager boundary condition.
+ *
+ * @param mesh PETSc mesh to initialize
+ */
+ void _initialize(ALE::Obj<ALE::Mesh>* mesh) const;
+
+}; // class TestFieldsManager
+
+#endif // pylith_topology_fieldsmanager_hh
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/topology/data/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/data/Makefile.am 2007-05-19 00:33:56 UTC (rev 6928)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/data/Makefile.am 2007-05-19 03:58:53 UTC (rev 6929)
@@ -0,0 +1,27 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+noinst_DATA = \
+ tri3.mesh
+
+# 'export' the input files by performing a mock install
+export_datadir = $(top_builddir)/unittests/libtests/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/libtests/topology/data/tri3.mesh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/data/tri3.mesh 2007-05-19 00:33:56 UTC (rev 6928)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/data/tri3.mesh 2007-05-19 03:58:53 UTC (rev 6929)
@@ -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