[cig-commits] r14586 - in short/3D/PyLith/branches/pylith-swig: . unittests/libtests/meshio

brad at geodynamics.org brad at geodynamics.org
Fri Apr 3 17:38:42 PDT 2009


Author: brad
Date: 2009-04-03 17:38:42 -0700 (Fri, 03 Apr 2009)
New Revision: 14586

Modified:
   short/3D/PyLith/branches/pylith-swig/TODO
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/Makefile.am
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.cc
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.hh
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestOutputManager.cc
Log:
More work on updating output unit tests.

Modified: short/3D/PyLith/branches/pylith-swig/TODO
===================================================================
--- short/3D/PyLith/branches/pylith-swig/TODO	2009-04-04 00:38:13 UTC (rev 14585)
+++ short/3D/PyLith/branches/pylith-swig/TODO	2009-04-04 00:38:42 UTC (rev 14586)
@@ -7,6 +7,16 @@
 0. SWIG conversion [Brad]
 
   (1) Output
+    module
+      DataWriterVTK
+      DataWriter
+      OutputManager
+      OutputSolnSubset
+      CellFilter
+      CellFilterAvg
+      VertexFilter
+      VertexFilterVecNorm
+    TestDataWriterVTK
 
   (2) Full-scale tests (few 1-D, 2-D, and 3-D)
 

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/Makefile.am	2009-04-04 00:38:13 UTC (rev 14585)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/Makefile.am	2009-04-04 00:38:42 UTC (rev 14586)
@@ -51,9 +51,9 @@
 # 	TestDataWriterVTKBCMeshQuad4.cc \
 # 	TestDataWriterVTKBCMeshTet4.cc \
 # 	TestDataWriterVTKBCMeshHex8.cc
+#	TestOutputManager.cc \
+#	TestOutputSolnSubset.cc
 
-# 	TestOutputManager.cc \
-# 	TestOutputSolnSubset.cc
 
 
 noinst_HEADERS = \

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.cc	2009-04-04 00:38:13 UTC (rev 14585)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.cc	2009-04-04 00:38:42 UTC (rev 14586)
@@ -18,8 +18,6 @@
 
 #include "pylith/meshio/DataWriterVTK.hh" // USES DataWriterVTK
 
-#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
-
 #include <string.h> // USES strcmp()
 
 // ----------------------------------------------------------------------
@@ -30,6 +28,7 @@
 void
 pylith::meshio::TestDataWriterVTK::setUp(void)
 { // setUp
+  _mesh = 0;
   _data = 0;
   _flipFault = false;
 } // setUp
@@ -48,7 +47,7 @@
 void
 pylith::meshio::TestDataWriterVTK::testConstructor(void)
 { // testConstructor
-  DataWriterVTK writer;
+  DataWriterVTK<topology::Mesh> writer;
 
   CPPUNIT_ASSERT(0 == writer._viewer);
   CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
@@ -60,7 +59,7 @@
 void
 pylith::meshio::TestDataWriterVTK::testFilename(void)
 { // testDebug
-  DataWriterVTK writer;
+  DataWriterVTK<topology::Mesh> writer;
 
   const char* filename = "data.vtk";
   writer.filename(filename);
@@ -72,7 +71,7 @@
 void
 pylith::meshio::TestDataWriterVTK::testTimeFormat(void)
 { // testTimeFormat
-  DataWriterVTK writer;
+  DataWriterVTK<topology::Mesh> writer;
 
   const char* format = "%4.1f";
   writer.timeFormat(format);
@@ -84,7 +83,7 @@
 void
 pylith::meshio::TestDataWriterVTK::testTimeConstant(void)
 { // testTimeConstant
-  DataWriterVTK writer;
+  DataWriterVTK<topology::Mesh> writer;
 
   const double value = 4.5;
   writer.timeConstant(value);
@@ -96,14 +95,11 @@
 void
 pylith::meshio::TestDataWriterVTK::testTimeStep(void)
 { // testTimeStep
-  CPPUNIT_ASSERT(!_mesh.isNull());
+  CPPUNIT_ASSERT(0 != _mesh);
   CPPUNIT_ASSERT(0 != _data);
 
-  DataWriterVTK writer;
+  DataWriterVTK<topology::Mesh> writer;
 
-  spatialdata::geocoords::CSCart cs;
-  cs.setSpaceDim(_mesh->getDimension());
-
   writer.filename(_data->timestepFilename);
   writer.timeFormat(_data->timeFormat);
 
@@ -113,13 +109,13 @@
   const double t = _data->time;
   const int numTimeSteps = 1;
   if (0 == _data->cellsLabel) {
-    writer.open(_mesh, &cs, numTimeSteps);
-    writer.openTimeStep(t, _mesh, &cs);
+    writer.open(*_mesh, numTimeSteps);
+    writer.openTimeStep(t, *_mesh);
   } else {
     const char* label = _data->cellsLabel;
     const int id = _data->labelId;
-    writer.open(_mesh, &cs, numTimeSteps, label, id);
-    writer.openTimeStep(t, _mesh, &cs, label, id);
+    writer.open(*_mesh, numTimeSteps, label, id);
+    writer.openTimeStep(t, *_mesh, label, id);
   } // else
 
   CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
@@ -139,15 +135,12 @@
 void
 pylith::meshio::TestDataWriterVTK::testWriteVertexField(void)
 { // testWriteVertexField
-  CPPUNIT_ASSERT(!_mesh.isNull());
+  CPPUNIT_ASSERT(0 != _mesh);
   CPPUNIT_ASSERT(0 != _data);
 
-  DataWriterVTK writer;
+  DataWriterVTK<topology::Mesh> writer;
 
-  spatialdata::geocoords::CSCart cs;
-  cs.setSpaceDim(_mesh->getDimension());
-
-  std::vector< ALE::Obj<real_section_type> > vertexFields;
+  topology::Fields<topology::Mesh> vertexFields(*_mesh);
   _createVertexFields(&vertexFields);
 
   writer.filename(_data->vertexFilename);
@@ -158,13 +151,13 @@
   const double t = _data->time;
   const int numTimeSteps = 1;
   if (0 == _data->cellsLabel) {
-    writer.open(_mesh, &cs, numTimeSteps);
-    writer.openTimeStep(t, _mesh, &cs);
+    writer.open(*_mesh, numTimeSteps);
+    writer.openTimeStep(t, *_mesh);
   } else {
     const char* label = _data->cellsLabel;
     const int id = _data->labelId;
-    writer.open(_mesh, &cs, numTimeSteps, label, id);
-    writer.openTimeStep(t, _mesh, &cs, label, id);
+    writer.open(*_mesh, numTimeSteps, label, id);
+    writer.openTimeStep(t, *_mesh, label, id);
   } // else
   for (int i=0; i < nfields; ++i) {
     writer.writeVertexField(t, _data->vertexFieldsInfo[i].name,
@@ -187,15 +180,12 @@
 void
 pylith::meshio::TestDataWriterVTK::testWriteCellField(void)
 { // testWriteCellField
-  CPPUNIT_ASSERT(!_mesh.isNull());
+  CPPUNIT_ASSERT(0 != _mesh);
   CPPUNIT_ASSERT(0 != _data);
 
-  DataWriterVTK writer;
+  DataWriterVTK<topology::Mesh> writer;
 
-  spatialdata::geocoords::CSCart cs;
-  cs.setSpaceDim(_mesh->getDimension());
-
-  std::vector< ALE::Obj<real_section_type> > cellFields;
+  std::vector<topology::Field<topology::Mesh> > cellFields;
   _createCellFields(&cellFields);
 
   writer.filename(_data->cellFilename);
@@ -206,8 +196,8 @@
   const double t = _data->time;
   const int numTimeSteps = 1;
   if (0 == _data->cellsLabel) {
-    writer.open(_mesh, &cs, numTimeSteps);
-    writer.openTimeStep(t, _mesh, &cs);
+    writer.open(*_mesh, numTimeSteps);
+    writer.openTimeStep(t, *_mesh);
     for (int i=0; i < nfields; ++i) {
       writer.writeCellField(t, _data->cellFieldsInfo[i].name,
                             cellFields[i], 
@@ -219,7 +209,7 @@
   } else {
     const char* label = _data->cellsLabel;
     const int id = _data->labelId;
-    writer.open(_mesh, &cs, numTimeSteps, label, id);
+    writer.open(*_mesh, numTimeSteps, label, id);
     writer.openTimeStep(t, _mesh, &cs, label, id);
     for (int i=0; i < nfields; ++i) {
       writer.writeCellField(t, _data->cellFieldsInfo[i].name,
@@ -242,7 +232,7 @@
 // Test _vtkFilename.
 void pylith::meshio::TestDataWriterVTK::testVtkFilename(void)
 { // testVtkFilename
-  DataWriterVTK writer;
+  DataWriterVTK<topology::Mesh> writer;
 
   // Append info to filename if number of time steps is 0.
   writer._numTimeSteps = 0;
@@ -269,34 +259,38 @@
 // Create vertex fields.
 void
 pylith::meshio::TestDataWriterVTK::_createVertexFields(
-		      std::vector< ALE::Obj<real_section_type> >* fields) const
+	     topology::Fields<topology::Mesh> >* fields) const
 { // _createVertexFields
   CPPUNIT_ASSERT(0 != fields);
-  CPPUNIT_ASSERT(!_mesh.isNull());
+  CPPUNIT_ASSERT(0 != _mesh);
   CPPUNIT_ASSERT(0 != _data);
 
   try {
     const int nfields = _data->numVertexFields;
 
-    const ALE::Obj<Mesh::label_sequence>& vertices = 
-      _mesh->depthStratum(0);
-    const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+    const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
+    CPPUNIT_ASSERT(!sieveMesh.isNull());
+    const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+    CPPUNIT_ASSERT(!vertices.isNull());
+    const label_sequence::iterator verticesEnd = vertices->end();
 
     // Set vertex fields
-    fields->resize(nfields);
     for (int i=0; i < nfields; ++i) {
-      (*fields)[i] = new real_section_type(_mesh->comm(), _mesh->debug());
-      (*fields)[i]->setChart(_mesh->getSieve()->getChart());
+      const char* name = _data->VertexFieldsInfo[i].label;
       const int fiberDim = _data->vertexFieldsInfo[i].fiber_dim;
-      (*fields)[i]->setFiberDimension(vertices, fiberDim);
-      _mesh->allocate((*fields)[i]);
+      fields->add(name);
+      topology::Field<topology::Mesh>& field = fields->get(name);
+      field.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
+      field.allocate();
 
+      const ALE::Obj<RealSection>& section = field.section();
+      CPPUNIT_ASSERT(!section.isNull());
       int ipt = 0;
-      for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+      for (label_sequence::iterator v_iter=vertices->begin();
 	   v_iter != verticesEnd;
 	   ++v_iter, ++ipt) {
 	const double* values = &_data->vertexFields[i][ipt*fiberDim];
-	(*fields)[i]->updatePoint(*v_iter, values);
+	section->updatePoint(*v_iter, values);
       } // for
       CPPUNIT_ASSERT_EQUAL(_data->numVertices, ipt);
     } // for
@@ -309,10 +303,10 @@
 // Create cell fields.
 void
 pylith::meshio::TestDataWriterVTK::_createCellFields(
-		      std::vector< ALE::Obj<real_section_type> >* fields) const
+                       topology::Fields<topology::Mesh> >* fields) const
 { // _createCellFields
   CPPUNIT_ASSERT(0 != fields);
-  CPPUNIT_ASSERT(!_mesh.isNull());
+  CPPUNIT_ASSERT(0 != _mesh);
   CPPUNIT_ASSERT(0 != _data);
 
   try {

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.hh	2009-04-04 00:38:13 UTC (rev 14585)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.hh	2009-04-04 00:38:42 UTC (rev 14586)
@@ -102,7 +102,7 @@
 protected :
 
   DataWriterVTKData* _data; ///< Data for testing
-  ALE::Obj<Mesh> _mesh; ///< Mesh for data
+  topology::Mesh* _mesh; ///< Mesh for data
   bool _flipFault; ///< If true, flip fault orientation.
 
   // PRIVATE MEMBERS ////////////////////////////////////////////////////
@@ -113,14 +113,14 @@
    * @param fields Vertex fields.
    */
   void
-  _createVertexFields(std::vector< ALE::Obj<real_section_type> >* fields) const;
+  _createVertexFields(topology::Fields<topology::Mesh>* fields) const;
 
   /** Create cell fields.
    *
    * @param fields Cell fields.
    */
   void
-  _createCellFields(std::vector< ALE::Obj<real_section_type> >* fields) const;
+  _createCellFields(topology::Fields<topology::Mesh>* fields) const;
 
 }; // class TestDataWriterVTK
 

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestOutputManager.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestOutputManager.cc	2009-04-04 00:38:13 UTC (rev 14585)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestOutputManager.cc	2009-04-04 00:38:42 UTC (rev 14586)
@@ -37,7 +37,7 @@
 void
 pylith::meshio::TestOutputManager::testConstructor(void)
 { // testConstructor
-  OutputManager manager;
+  OutputManager<topology::Mesh> manager;
 } // testConstructor
 
 // ----------------------------------------------------------------------
@@ -45,7 +45,7 @@
 void
 pylith::meshio::TestOutputManager::testCoordsys(void)
 { // testCoordsys
-  OutputManager manager;
+  OutputManager<topology::Mesh> manager;
 
   CPPUNIT_ASSERT(0 == manager._coordsys);
 
@@ -59,11 +59,11 @@
 void
 pylith::meshio::TestOutputManager::testWriter(void)
 { // testWriter
-  OutputManager manager;
+  OutputManager<topology::Mesh> manager;
 
   CPPUNIT_ASSERT(0 == manager._writer);
 
-  DataWriterVTK writer;
+  DataWriterVTK<topology::Mesh> writer;
   manager.writer(&writer);
   CPPUNIT_ASSERT(0 != manager._writer);
 } // testWriter
@@ -73,12 +73,12 @@
 void
 pylith::meshio::TestOutputManager::testVertexFilter(void)
 { // testVertexFilter
-  OutputManager manager;
+  OutputManager<topology::Mesh> manager;
 
   CPPUNIT_ASSERT(0 == manager._vertexFilter);
   CPPUNIT_ASSERT(0 == manager._cellFilter);
 
-  VertexFilterVecNorm filter;
+  VertexFilterVecNorm<topology::Mesh> filter;
   manager.vertexFilter(&filter);
   CPPUNIT_ASSERT(0 != manager._vertexFilter);
   CPPUNIT_ASSERT(0 == manager._cellFilter);
@@ -89,12 +89,12 @@
 void
 pylith::meshio::TestOutputManager::testCellFilter(void)
 { // testCellFilter
-  OutputManager manager;
+  OutputManager<topology::Mesh> manager;
 
   CPPUNIT_ASSERT(0 == manager._vertexFilter);
   CPPUNIT_ASSERT(0 == manager._cellFilter);
 
-  CellFilterAvg filter;
+  CellFilterAvg<topology::Mesh> filter;
   manager.cellFilter(&filter);
   CPPUNIT_ASSERT(0 != manager._cellFilter);
   CPPUNIT_ASSERT(0 == manager._vertexFilter);
@@ -105,7 +105,7 @@
 void
 pylith::meshio::TestOutputManager::testOpenClose(void)
 { // testOpenClose
-  OutputManager manager;
+  OutputManager<topology::Mesh> manager;
 
   MeshIOAscii iohandler;
   ALE::Obj<Mesh> mesh;
@@ -118,7 +118,7 @@
 
   // TODO Replace DataVTKWriter with writer that has nontrivial
   // open()/close().
-  DataWriterVTK writer;
+  DataWriterVTK<topology::Mesh> writer;
   manager.writer(&writer);
 
   manager.open(mesh, &cs, numTimeSteps);
@@ -130,7 +130,7 @@
 void
 pylith::meshio::TestOutputManager::testOpenCloseTimeStep(void)
 { // testOpenCloseTimeStep
-  OutputManager manager;
+  OutputManager<topology::Mesh> manager;
 
   MeshIOAscii iohandler;
   ALE::Obj<Mesh> mesh;
@@ -144,7 +144,7 @@
   const char* filenameRoot = "output.vtk";
   const char* timeFormat = "%3.1f";
 
-  DataWriterVTK writer;
+  DataWriterVTK<topology::Mesh> writer;
   writer.filename(filenameRoot);
   writer.timeFormat(timeFormat);
   manager.writer(&writer);
@@ -162,13 +162,14 @@
 void
 pylith::meshio::TestOutputManager::testAppendVertexField(void)
 { // testAppendVertexField
-  OutputManager manager;
+  OutputManager<topology::Mesh> manager;
 
   const char* meshFilename = "data/tri3.mesh";
   const int fiberDim = 2;
   const int nvertices = 4;
-  const char* fieldName = "field data";
-  const VectorFieldEnum fieldType = VECTOR_FIELD;
+  const char* label = "field data";
+  const topology::FieldBase::VectorFieldEnum fieldType = 
+    topology::FieldBase::VECTOR;
   const double fieldValues[] = {
     1.1, 1.2,
     2.1, 2.2,
@@ -180,7 +181,6 @@
   ALE::Obj<Mesh> mesh;
   iohandler.filename(meshFilename);
   iohandler.read(&mesh);
-  CPPUNIT_ASSERT(!mesh.isNull());
 
   // Set vertex field
   const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
@@ -247,7 +247,7 @@
   const int fiberDim = 2;
   const int ncells = 2;
   const char* fieldName = "field data";
-  const VectorFieldEnum fieldType = OTHER_FIELD;
+  const topology::FieldBase::VectorFieldEnum fieldType = OTHER_FIELD;
   const double fieldValues[] = {
     1.1, 1.2,
     2.1, 2.2,



More information about the CIG-COMMITS mailing list