[cig-commits] r14056 - in short/3D/PyLith/branches/pylith-swig: libsrc libsrc/bc unittests/libtests/topology
brad at geodynamics.org
brad at geodynamics.org
Sun Feb 15 20:00:41 PST 2009
Author: brad
Date: 2009-02-15 20:00:41 -0800 (Sun, 15 Feb 2009)
New Revision: 14056
Added:
short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestSolutionFields.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestSolutionFields.hh
Removed:
short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldsManager.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldsManager.hh
Modified:
short/3D/PyLith/branches/pylith-swig/libsrc/Makefile.am
short/3D/PyLith/branches/pylith-swig/libsrc/bc/Neumann.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/Makefile.am
Log:
Replaced FieldsManager with SolutionFields.
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/Makefile.am 2009-02-16 04:00:18 UTC (rev 14055)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/Makefile.am 2009-02-16 04:00:41 UTC (rev 14056)
@@ -61,8 +61,9 @@
meshio/PsetFileAscii.cc \
meshio/PsetFileBinary.cc \
topology/Mesh.cc \
+ topology/MeshOps.cc \
topology/SubMesh.cc \
- topology/MeshOps.cc \
+ topology/SolutionFields.cc \
utils/EventLogger.cc
# faults/BruneSlipFn.cc \
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/bc/Neumann.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/bc/Neumann.cc 2009-02-16 04:00:18 UTC (rev 14055)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/bc/Neumann.cc 2009-02-16 04:00:41 UTC (rev 14056)
@@ -251,7 +251,6 @@
assert(0 != _quadrature);
assert(0 != _boundaryMesh);
assert(0 != _tractions);
- assert(0 != fields);
PetscErrorCode err = 0;
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/Makefile.am 2009-02-16 04:00:18 UTC (rev 14055)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/Makefile.am 2009-02-16 04:00:41 UTC (rev 14056)
@@ -28,6 +28,7 @@
TestFieldSubMesh.cc \
TestFieldsMesh.cc \
TestFieldsSubMesh.cc \
+ TestSolutionFields.cc \
test_topology.cc
@@ -38,7 +39,8 @@
TestFieldMesh.hh \
TestFieldSubMesh.hh \
TestFieldsMesh.hh \
- TestFieldsSubMesh.hh
+ TestFieldsSubMesh.hh \
+ TestSolutionFields.hh
# Source files associated with testing data
Deleted: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldsManager.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldsManager.cc 2009-02-16 04:00:18 UTC (rev 14055)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldsManager.cc 2009-02-16 04:00:41 UTC (rev 14056)
@@ -1,413 +0,0 @@
-// -*- 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
-
-// ----------------------------------------------------------------------
-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 setFiberDimension().
-void
-pylith::topology::TestFieldsManager::testSetFiberDimension(void)
-{ // testSetFiberDimension
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const int fiberDim = 3;
-
- const char* labelA = "field A";
- manager.addReal(labelA);
- manager.setFiberDimension(labelA, fiberDim, "vertices");
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(labelA);
- CPPUNIT_ASSERT(!fieldA.isNull());
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- fieldA->allocateStorage();
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter)
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldA->getFiberDimension(*v_iter));
-
- const char* labelB = "field B";
- manager.addReal(labelB);
- manager.setFiberDimension(labelB, fiberDim, "cells");
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(labelB);
- CPPUNIT_ASSERT(!fieldB.isNull());
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
- fieldB->allocateStorage();
- for (Mesh::label_sequence::iterator c_iter = cells->begin();
- c_iter != cells->end();
- ++c_iter)
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldB->getFiberDimension(*c_iter));
-} // testSetFiberDimension
-
-// ----------------------------------------------------------------------
-// Test allocate().
-void
-pylith::topology::TestFieldsManager::testAllocate(void)
-{ // testAllocate
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const int fiberDim = 3;
-
- const char* labelA = "field A";
- manager.addReal(labelA);
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(labelA);
- manager.setFiberDimension(labelA, fiberDim, "vertices");
- manager.allocate(labelA);
-
- const char* labelB = "field B";
- manager.addReal(labelB);
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(labelB);
- manager.setFiberDimension(labelB, fiberDim, "cells");
- manager.allocate(labelB);
-} // testAllocate
-
-// ----------------------------------------------------------------------
-// Test copyLayout().
-void
-pylith::topology::TestFieldsManager::testCopyLayout(void)
-{ // testCopyLayout
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
-
- const char* labelA = "field A";
- manager.addReal(labelA);
- const int fiberDim = 3;
- const int fixedDim = 1;
- const Mesh::point_type fixedPt = offset + 2;
-
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(labelA);
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- fieldA->setChart(mesh->getSieve()->getChart());
- fieldA->setFiberDimension(vertices, fiberDim);
- fieldA->setConstraintDimension(fixedPt, 1);
- fieldA->allocateStorage();
- fieldA->setConstraintDof(fixedPt, &fixedDim);
-
- const char* labelB = "field B";
- manager.addReal(labelB);
-
- manager.copyLayout(labelA);
-
- size_t size = 2;
- CPPUNIT_ASSERT_EQUAL(size, manager._real.size());
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(labelB);
-
- CPPUNIT_ASSERT_EQUAL(fieldA->size(), fieldB->size());
- CPPUNIT_ASSERT_EQUAL(fieldA->sizeWithBC(), fieldB->sizeWithBC());
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- if (*v_iter != fixedPt) {
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldB->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(0, fieldB->getConstraintDimension(*v_iter));
- } else {
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldB->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(1, fieldB->getConstraintDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(fixedDim, fieldB->getConstraintDof(*v_iter)[0]);
- } // if/else
- } // for
-} // testCopyLayout
-
-// ----------------------------------------------------------------------
-// Test copyLayoutFromField().
-void
-pylith::topology::TestFieldsManager::testCopyLayoutFromField(void)
-{ // testCopyLayoutFromField
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
-
- const char* labelA = "field A";
- const ALE::Obj<real_section_type>& fieldA =
- new real_section_type(mesh->comm(), mesh->debug());
- const int fiberDim = 3;
- const int fixedDim = 1;
- const Mesh::point_type fixedPt = offset + 2;
-
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- fieldA->setChart(mesh->getSieve()->getChart());
- fieldA->setFiberDimension(vertices, fiberDim);
- fieldA->setConstraintDimension(fixedPt, 1);
- fieldA->allocateStorage();
- fieldA->setConstraintDof(fixedPt, &fixedDim);
-
- const char* labelB = "field B";
- manager.addReal(labelB);
- const char* labelC = "field C";
- manager.addReal(labelC);
-
- manager.copyLayout(fieldA);
-
- size_t size = 2;
- CPPUNIT_ASSERT_EQUAL(size, manager._real.size());
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(labelB);
- const ALE::Obj<real_section_type>& fieldC = manager.getReal(labelC);
-
- CPPUNIT_ASSERT_EQUAL(fieldA->size(), fieldB->size());
- CPPUNIT_ASSERT_EQUAL(fieldA->sizeWithBC(), fieldB->sizeWithBC());
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- if (*v_iter != fixedPt) {
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldB->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(0, fieldB->getConstraintDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldC->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(0, fieldC->getConstraintDimension(*v_iter));
- } else {
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldB->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(1, fieldB->getConstraintDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(fixedDim, fieldB->getConstraintDof(*v_iter)[0]);
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldC->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(1, fieldC->getConstraintDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(fixedDim, fieldC->getConstraintDof(*v_iter)[0]);
- } // if/else
- } // for
-} // testCopyLayoutFromField
-
-// ----------------------------------------------------------------------
-// Test solutionField().
-void
-pylith::topology::TestFieldsManager::testSolutionField(void)
-{ // testSolutionField
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const std::string& name = "my solution";
- manager.addReal(name.c_str());
- manager.solutionField(name.c_str());
- CPPUNIT_ASSERT_EQUAL(name, manager._solutionName);
-} // testSolutionField
-
-// ----------------------------------------------------------------------
-// Test getSolution().
-void
-pylith::topology::TestFieldsManager::testGetSolution(void)
-{ // testGetSolution
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const char* labels[] = { "field A", "field B", "field C" };
- const int size = 3;
- const int fiberDimA = 2;
- const int fiberDimB = 3;
- const int fiberDimC = 4;
-
- for (int i=0; i < size; ++i)
- manager.addReal(labels[i]);
-
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(labels[0]);
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(labels[1]);
- const ALE::Obj<real_section_type>& fieldC = manager.getReal(labels[2]);
- fieldA->setChart(mesh->getSieve()->getChart());
- fieldA->setFiberDimension(vertices, fiberDimA);
- fieldB->setChart(mesh->getSieve()->getChart());
- fieldB->setFiberDimension(vertices, fiberDimB);
- fieldC->setChart(mesh->getSieve()->getChart());
- fieldC->setFiberDimension(vertices, fiberDimC);
-
- manager.solutionField(labels[1]);
- const ALE::Obj<real_section_type>& solution = manager.getSolution();
- CPPUNIT_ASSERT_EQUAL(fiberDimB,
- solution->getFiberDimension(*(vertices->begin())));
-} // testGetSolution
-
-// ----------------------------------------------------------------------
-// Test createHistory().
-void
-pylith::topology::TestFieldsManager::testCreateHistory(void)
-{ // testCreateHistory
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const char* labels[] = { "field A", "field B", "field C" };
- const int totalSize = 3;
- const int historySize = 2;
-
- // Add fields
- for (int i=0; i < totalSize; ++i)
- manager.addReal(labels[i]);
-
- manager.createHistory(labels, historySize);
- for (int i=0; i < historySize; ++i)
- CPPUNIT_ASSERT_EQUAL(std::string(labels[i]), manager._history[i]);
-} // testCreateHistory
-
-// ----------------------------------------------------------------------
-// Test shiftHistory().
-void
-pylith::topology::TestFieldsManager::testShiftHistory(void)
-{ // testShiftHistory
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const char* fieldNames[] = { "field A", "field B" };
- const int numFields = 2;
- const int fiberDimA = 2;
- const int fiberDimB = 3;
-
- for (int i=0; i < numFields; ++i)
- manager.addReal(fieldNames[i]);
- manager.createHistory(fieldNames, numFields);
-
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(fieldNames[0]);
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(fieldNames[1]);
- fieldA->setChart(mesh->getSieve()->getChart());
- fieldA->setFiberDimension(vertices, fiberDimA);
- fieldB->setChart(mesh->getSieve()->getChart());
- fieldB->setFiberDimension(vertices, fiberDimB);
-
- manager.shiftHistory();
- const ALE::Obj<real_section_type>& testA = manager.getReal(fieldNames[0]);
- const ALE::Obj<real_section_type>& testB = manager.getReal(fieldNames[1]);
- CPPUNIT_ASSERT_EQUAL(fiberDimB,
- testA->getFiberDimension(*(vertices->begin())));
- CPPUNIT_ASSERT_EQUAL(fiberDimA,
- testB->getFiberDimension(*(vertices->begin())));
-
-} // testShiftHistory
-
-// ----------------------------------------------------------------------
-// Test getFieldByHistory().
-void
-pylith::topology::TestFieldsManager::testGetFieldByHistory(void)
-{ // testGetFieldByHistory
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const char* labels[] = { "field A", "field B" };
- const int size = 2;
- const int fiberDimA = 2;
- const int fiberDimB = 3;
-
- for (int i=0; i < size; ++i)
- manager.addReal(labels[i]);
- manager.createHistory(labels, size);
-
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(labels[0]);
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(labels[1]);
- fieldA->setChart(mesh->getSieve()->getChart());
- fieldA->setFiberDimension(vertices, fiberDimA);
- fieldB->setChart(mesh->getSieve()->getChart());
- fieldB->setFiberDimension(vertices, fiberDimB);
-
- const ALE::Obj<real_section_type>& testA = manager.getFieldByHistory(0);
- CPPUNIT_ASSERT_EQUAL(fiberDimA,
- testA->getFiberDimension(*(vertices->begin())));
-
- const ALE::Obj<real_section_type>& testB = manager.getFieldByHistory(1);
- CPPUNIT_ASSERT_EQUAL(fiberDimB,
- testB->getFiberDimension(*(vertices->begin())));
-} // testGetFieldByHistory
-
-// ----------------------------------------------------------------------
-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
Deleted: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldsManager.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldsManager.hh 2009-02-16 04:00:18 UTC (rev 14055)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldsManager.hh 2009-02-16 04:00:41 UTC (rev 14056)
@@ -1,116 +0,0 @@
-// -*- 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/sievetypes.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( testSetFiberDimension );
- CPPUNIT_TEST( testAllocate );
- CPPUNIT_TEST( testCopyLayout );
- CPPUNIT_TEST( testCopyLayoutFromField );
- CPPUNIT_TEST( testSolutionField );
- CPPUNIT_TEST( testGetSolution );
- CPPUNIT_TEST( testCreateHistory );
- CPPUNIT_TEST( testShiftHistory );
- CPPUNIT_TEST( testGetFieldByHistory );
-
- 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 setFiberDimension().
- void testSetFiberDimension(void);
-
- /// Test allocate().
- void testAllocate(void);
-
- /// Test copyLayout().
- void testCopyLayout(void);
-
- /// Test copyLayoutFromField().
- void testCopyLayoutFromField(void);
-
- /// Test solutionField().
- void testSolutionField(void);
-
- /// Test getSolution().
- void testGetSolution(void);
-
- /// Test createHistory().
- void testCreateHistory(void);
-
- /// Test shiftHistory().
- void testShiftHistory(void);
-
- /// Test getFieldByHistory().
- void testGetFieldByHistory(void);
-
- // PRIVATE METHODS ////////////////////////////////////////////////////
-private :
-
- /** Initialize FieldsManager boundary condition.
- *
- * @param mesh PETSc mesh to initialize
- */
- void _initialize(ALE::Obj<Mesh>* mesh) const;
-
-}; // class TestFieldsManager
-
-#endif // pylith_topology_fieldsmanager_hh
-
-
-// End of file
Added: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestSolutionFields.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestSolutionFields.cc (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestSolutionFields.cc 2009-02-16 04:00:41 UTC (rev 14056)
@@ -0,0 +1,159 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestSolutionFields.hh" // Implementation of class methods
+
+#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
+
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestSolutionFields );
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::topology::TestSolutionFields::testConstructor(void)
+{ // testConstructor
+ Mesh mesh;
+ _initialize(&mesh);
+ SolutionFields manager(mesh);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test solutionField().
+void
+pylith::topology::TestSolutionFields::testSolutionField(void)
+{ // testSolutionField
+ Mesh mesh;
+ _initialize(&mesh);
+ SolutionFields manager(mesh);
+
+ const std::string& name = "my solution";
+ manager.add(name.c_str());
+ manager.solutionField(name.c_str());
+ CPPUNIT_ASSERT_EQUAL(name, manager._solutionName);
+} // testSolutionField
+
+// ----------------------------------------------------------------------
+// Test getSolution().
+void
+pylith::topology::TestSolutionFields::testGetSolution(void)
+{ // testGetSolution
+ Mesh mesh;
+ _initialize(&mesh);
+ SolutionFields manager(mesh);
+
+ const char* labels[] = { "field A", "field B", "field C" };
+ const int size = 3;
+ const int fiberDimA = 2;
+ const int fiberDimB = 3;
+ const int fiberDimC = 4;
+
+ for (int i=0; i < size; ++i)
+ manager.add(labels[i]);
+
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ Field<Mesh>& fieldA = manager.get(labels[0]);
+ Field<Mesh>& fieldB = manager.get(labels[1]);
+ Field<Mesh>& fieldC = manager.get(labels[2]);
+ fieldA.newSection(vertices, fiberDimA);
+
+ const ALE::Obj<Mesh::RealSection>& section = fieldA.section();
+ const Mesh::RealSection::chart_type& chart = section->getChart();
+ fieldB.newSection(chart, fiberDimB);
+ fieldC.newSection(chart, fiberDimC);
+
+ manager.solutionField(labels[1]);
+ const Field<Mesh>& solution = manager.getSolution();
+ const ALE::Obj<Mesh::RealSection>& sectionSoln = solution.section();
+ CPPUNIT_ASSERT_EQUAL(fiberDimB,
+ sectionSoln->getFiberDimension(*(vertices->begin())));
+} // testGetSolution
+
+// ----------------------------------------------------------------------
+// Test createHistory().
+void
+pylith::topology::TestSolutionFields::testCreateHistory(void)
+{ // testCreateHistory
+ Mesh mesh;
+ _initialize(&mesh);
+ SolutionFields manager(mesh);
+
+ const char* labels[] = { "field A", "field B", "field C" };
+ const int totalSize = 3;
+ const int historySize = 2;
+
+ // Add fields
+ for (int i=0; i < totalSize; ++i)
+ manager.add(labels[i]);
+
+ manager.createHistory(labels, historySize);
+ for (int i=0; i < historySize; ++i)
+ CPPUNIT_ASSERT_EQUAL(std::string(labels[i]), manager._history[i]);
+} // testCreateHistory
+
+// ----------------------------------------------------------------------
+// Test shiftHistory().
+void
+pylith::topology::TestSolutionFields::testShiftHistory(void)
+{ // testShiftHistory
+ Mesh mesh;
+ _initialize(&mesh);
+ SolutionFields manager(mesh);
+
+ const char* fieldNames[] = { "field A", "field B" };
+ const int numFields = 2;
+ const int fiberDimA = 2;
+ const int fiberDimB = 3;
+
+ for (int i=0; i < numFields; ++i)
+ manager.add(fieldNames[i]);
+ manager.createHistory(fieldNames, numFields);
+
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ Field<Mesh>& fieldA = manager.get(fieldNames[0]);
+ Field<Mesh>& fieldB = manager.get(fieldNames[1]);
+ fieldA.newSection(vertices, fiberDimA);
+ fieldB.newSection(vertices, fiberDimB);
+
+ manager.shiftHistory();
+ const Field<Mesh>& testA = manager.get(fieldNames[0]);
+ const ALE::Obj<Mesh::RealSection>& sectionA = testA.section();
+ const Field<Mesh>& testB = manager.get(fieldNames[1]);
+ const ALE::Obj<Mesh::RealSection>& sectionB = testB.section();
+ CPPUNIT_ASSERT_EQUAL(fiberDimB,
+ sectionA->getFiberDimension(*(vertices->begin())));
+ CPPUNIT_ASSERT_EQUAL(fiberDimA,
+ sectionB->getFiberDimension(*(vertices->begin())));
+
+} // testShiftHistory
+
+// ----------------------------------------------------------------------
+void
+pylith::topology::TestSolutionFields::_initialize(Mesh* mesh) const
+{ // _initialize
+ CPPUNIT_ASSERT(0 != mesh);
+
+ meshio::MeshIOAscii iohandler;
+ iohandler.filename("data/tri3.mesh");
+ iohandler.read(mesh);
+} // _initialize
+
+
+// End of file
Added: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestSolutionFields.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestSolutionFields.hh (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestSolutionFields.hh 2009-02-16 04:00:41 UTC (rev 14056)
@@ -0,0 +1,85 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/topology/TestSolutionFields.hh
+ *
+ * @brief C++ TestSolutionFields object.
+ *
+ * C++ unit testing for SolutionFields.
+ */
+
+#if !defined(pylith_topology_testsolutionfields_hh)
+#define pylith_topology_testsolutionfields_hh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "pylith/topology/topologyfwd.hh"
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace topology {
+ class TestSolutionFields;
+ } // topology
+} // pylith
+
+/// C++ unit testing for SolutionFields.
+class pylith::topology::TestSolutionFields : public CppUnit::TestFixture
+{ // class TestSolutionFields
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestSolutionFields );
+
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testSolutionField );
+ CPPUNIT_TEST( testGetSolution );
+ CPPUNIT_TEST( testCreateHistory );
+ CPPUNIT_TEST( testShiftHistory );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Test constructor.
+ void testConstructor(void);
+
+ /// Test solutionField().
+ void testSolutionField(void);
+
+ /// Test getSolution().
+ void testGetSolution(void);
+
+ /// Test createHistory().
+ void testCreateHistory(void);
+
+ /// Test shiftHistory().
+ void testShiftHistory(void);
+
+ /// Test getFieldByHistory().
+ void testGetFieldByHistory(void);
+
+ // PRIVATE METHODS ////////////////////////////////////////////////////
+private :
+
+ /** Initialize mesh for SolutionFields.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ void _initialize(Mesh* mesh) const;
+
+}; // class TestSolutionFields
+
+#endif // pylith_topology_solutionfields_hh
+
+
+// End of file
More information about the CIG-COMMITS
mailing list