[cig-commits] r21806 - short/3D/PyLith/trunk/unittests/libtests/meshio

brad at geodynamics.org brad at geodynamics.org
Wed Apr 10 17:02:17 PDT 2013


Author: brad
Date: 2013-04-10 17:02:17 -0700 (Wed, 10 Apr 2013)
New Revision: 21806

Modified:
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterMesh.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMesh.cc
Log:
Code cleanup.

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterMesh.cc	2013-04-11 00:01:54 UTC (rev 21805)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterMesh.cc	2013-04-11 00:02:17 UTC (rev 21806)
@@ -27,6 +27,8 @@
 #include "pylith/topology/Mesh.hh" // USES Mesh
 #include "pylith/topology/Field.hh" // USES Field
 #include "pylith/topology/Fields.hh" // USES Fields
+#include "pylith/topology/Stratum.hh" // USES Stratum
+#include "pylith/topology/VisitorMesh.hh" // USES VecVisitorMesh
 #include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
 #include "pylith/meshio/DataWriter.hh" // USES DataWriter
 #include "pylith/faults/FaultCohesiveKin.hh" // USES FaultCohesiveKin
@@ -41,9 +43,13 @@
 void
 pylith::meshio::TestDataWriterMesh::setUp(void)
 { // setUp
+  PYLITH_METHOD_BEGIN;
+
   _data = 0;
   _mesh = 0;
   _flipFault = false;
+
+  PYLITH_METHOD_END;
 } // setUp
 
 // ----------------------------------------------------------------------
@@ -51,8 +57,12 @@
 void
 pylith::meshio::TestDataWriterMesh::tearDown(void)
 { // tearDown
+  PYLITH_METHOD_BEGIN;
+
   delete _data; _data = 0;
   delete _mesh; _mesh = 0;
+
+  PYLITH_METHOD_END;
 } // tearDown
 
 // ----------------------------------------------------------------------
@@ -60,9 +70,11 @@
 void
 pylith::meshio::TestDataWriterMesh::_initialize(void)
 { // _initialize
-  CPPUNIT_ASSERT(0 != _data);
+  PYLITH_METHOD_BEGIN;
 
-  delete _mesh; _mesh = new topology::Mesh;
+  CPPUNIT_ASSERT(_data);
+
+  delete _mesh; _mesh = new topology::Mesh;CPPUNIT_ASSERT(_mesh);
   MeshIOAscii iohandler;
   iohandler.filename(_data->meshFilename);
   iohandler.read(_mesh);
@@ -71,138 +83,121 @@
   cs.setSpaceDim(_mesh->dimension());
   _mesh->coordsys(&cs);
 
-  if (0 != _data->faultLabel) {
+  if (_data->faultLabel) {
     faults::FaultCohesiveKin fault;
-    int firstFaultVertex    = 0;
-    int firstLagrangeVertex = _mesh->sieveMesh()->getIntSection(_data->faultLabel)->size();
-    int firstFaultCell      = _mesh->sieveMesh()->getIntSection(_data->faultLabel)->size();
-    if (fault.useLagrangeConstraints()) {
-      firstFaultCell += _mesh->sieveMesh()->getIntSection(_data->faultLabel)->size();
-    }
+    const bool useLagrangeConstraints = true;
+    PetscInt firstFaultVertex = 0;
+    PetscInt firstLagrangeVertex = 0, firstFaultCell = 0;
+    PetscErrorCode err = DMPlexGetStratumSize(_mesh->dmMesh(), _data->faultLabel, 1, &firstLagrangeVertex);CHECK_PETSC_ERROR(err);
+    firstFaultCell = firstLagrangeVertex;
+    if (useLagrangeConstraints) {
+      firstFaultCell += firstLagrangeVertex;
+    } // if
     fault.label(_data->faultLabel);
     fault.id(_data->faultId);
     fault.adjustTopology(_mesh, &firstFaultVertex, &firstLagrangeVertex, &firstFaultCell, _flipFault);
   } // if
+
+  PYLITH_METHOD_END;
 } // _initialize
 
 // ----------------------------------------------------------------------
 // Create vertex fields.
 void
-pylith::meshio::TestDataWriterMesh::_createVertexFields(
-	    topology::Fields<MeshField>* fields) const
+pylith::meshio::TestDataWriterMesh::_createVertexFields(topology::Fields<MeshField>* fields) const
 { // _createVertexFields
-  CPPUNIT_ASSERT(0 != fields);
-  CPPUNIT_ASSERT(0 != _mesh);
-  CPPUNIT_ASSERT(0 != _data);
+  PYLITH_METHOD_BEGIN;
 
-  try {
-    const int nfields = _data->numVertexFields;
+  CPPUNIT_ASSERT(fields);
+  CPPUNIT_ASSERT(_mesh);
+  CPPUNIT_ASSERT(_data);
 
-    DM dmMesh = _mesh->dmMesh();
-    PetscInt       vStart, vEnd;
-    PetscErrorCode err;
-
-    CPPUNIT_ASSERT(dmMesh);
-    err = DMPlexGetDepthStratum(dmMesh, 0, &vStart, &vEnd);CHECK_PETSC_ERROR(err);
-
-    // Set vertex fields
-    for (int i=0; i < nfields; ++i) {
-      const char* name = _data->vertexFieldsInfo[i].name;
-      const int fiberDim = _data->vertexFieldsInfo[i].fiber_dim;
-      fields->add(name, name);
-      MeshField& field = fields->get(name);
-      field.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
-      field.allocate();
-      field.vectorFieldType(_data->vertexFieldsInfo[i].field_type);
-
-      PetscSection section = field.petscSection();
-      Vec          vec     = field.localVector();
-      PetscScalar *a;
-      CPPUNIT_ASSERT(section);CPPUNIT_ASSERT(vec);
-      err = VecGetArray(vec, &a);CHECK_PETSC_ERROR(err);
-      for(PetscInt v = vStart; v < vEnd; ++v) {
-        PetscInt dof, off;
-
-        err = PetscSectionGetDof(section, v, &dof);CHECK_PETSC_ERROR(err);
-        err = PetscSectionGetOffset(section, v, &off);CHECK_PETSC_ERROR(err);
-        for(PetscInt d = 0; d < dof; ++d) {
-          a[off+d] = _data->vertexFields[i][(v-vStart)*dof+d];
-        }
+  const int nfields = _data->numVertexFields;
+  
+  PetscDM dmMesh = _mesh->dmMesh();CPPUNIT_ASSERT(dmMesh);  
+  topology::Stratum verticesStratum(dmMesh, topology::Stratum::DEPTH, 0);
+  const PetscInt vStart = verticesStratum.begin();
+  const PetscInt vEnd = verticesStratum.end();
+  
+  // Set vertex fields
+  for (int i=0; i < nfields; ++i) {
+    const char* name = _data->vertexFieldsInfo[i].name;
+    const int fiberDim = _data->vertexFieldsInfo[i].fiber_dim;
+    fields->add(name, name);
+    MeshField& field = fields->get(name);
+    field.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
+    field.allocate();
+    field.vectorFieldType(_data->vertexFieldsInfo[i].field_type);
+    
+    topology::VecVisitorMesh fieldVisitor(field);
+    PetscScalar* fieldArray = fieldVisitor.localArray();CPPUNIT_ASSERT(fieldArray);
+    
+    for(PetscInt v = vStart, index=0; v < vEnd; ++v) {
+      const PetscInt off = fieldVisitor.sectionOffset(v);
+      CPPUNIT_ASSERT_EQUAL(fiberDim, fieldVisitor.sectionDof(v));
+      for(PetscInt d = 0; d < fiberDim; ++d, ++index) {
+	fieldArray[off+d] = _data->vertexFields[i][index];
       } // for
-      err = VecRestoreArray(vec, &a);CHECK_PETSC_ERROR(err);
-      CPPUNIT_ASSERT_EQUAL(_data->numVertices, vEnd-vStart);
     } // for
-  } catch (const ALE::Exception& err) {
-    throw std::runtime_error(err.msg());
-  } catch (...) {
-    throw;
-  } // catch
+    CPPUNIT_ASSERT_EQUAL(_data->numVertices, vEnd-vStart);
+  } // for
+
+  PYLITH_METHOD_END;
 } // _createVertexFields
 
 // ----------------------------------------------------------------------
 // Create cell fields.
 void
-pylith::meshio::TestDataWriterMesh::_createCellFields(
-	     topology::Fields<MeshField>* fields) const
+pylith::meshio::TestDataWriterMesh::_createCellFields(topology::Fields<MeshField>* fields) const
 { // _createCellFields
-  CPPUNIT_ASSERT(0 != fields);
-  CPPUNIT_ASSERT(0 != _mesh);
-  CPPUNIT_ASSERT(0 != _data);
+  PYLITH_METHOD_BEGIN;
 
-  try {
-    const int nfields = _data->numCellFields;
+  CPPUNIT_ASSERT(fields);
+  CPPUNIT_ASSERT(_mesh);
+  CPPUNIT_ASSERT(_data);
 
-    DM              dmMesh = _mesh->dmMesh();
-    IS              cellIS = PETSC_NULL;
-    const PetscInt *cells  = PETSC_NULL;
-    PetscInt        cStart, cEnd, numCells;
-    PetscErrorCode  err;
+  const int nfields = _data->numCellFields;
 
-    CPPUNIT_ASSERT(dmMesh);
-    err = DMPlexGetHeightStratum(dmMesh, 0, &cStart, &cEnd);CHECK_PETSC_ERROR(err);
-    numCells = cEnd - cStart;
-    if (_data->cellsLabel) {
-      err = DMPlexGetStratumIS(dmMesh, _data->cellsLabel, _data->labelId, &cellIS);CHECK_PETSC_ERROR(err);
-      err = ISGetSize(cellIS, &numCells);CHECK_PETSC_ERROR(err);
-      err = ISGetIndices(cellIS, &cells);CHECK_PETSC_ERROR(err);
-    }
+  PetscDM dmMesh = _mesh->dmMesh();CPPUNIT_ASSERT(dmMesh);  
+  topology::Stratum cellsStratum(dmMesh, topology::Stratum::HEIGHT, 0);
+  const PetscInt cStart = cellsStratum.begin();
+  const PetscInt cEnd = cellsStratum.end();
+  PetscInt numCells = cellsStratum.size();
 
-    // Set cell fields
-    for (int i=0; i < nfields; ++i) {
-      const char* name = _data->cellFieldsInfo[i].name;
-      const int fiberDim = _data->cellFieldsInfo[i].fiber_dim;
-      fields->add(name, name);
-      MeshField& field = fields->get(name);
-      field.newSection(topology::FieldBase::CELLS_FIELD, fiberDim);
-      field.allocate();
-      field.vectorFieldType(_data->cellFieldsInfo[i].field_type);
+  topology::StratumIS* cellsIS = (_data->cellsLabel) ? new topology::StratumIS(dmMesh, _data->cellsLabel, _data->labelId) : 0;
+  const PetscInt *cells  = NULL;
+  if (cellsIS) {
+    numCells = cellsIS->size();
+    cells = cellsIS->points();
+  } // if
 
-      PetscSection section = field.petscSection();
-      Vec          vec     = field.localVector();
-      PetscScalar *a;
-      CPPUNIT_ASSERT(section);CPPUNIT_ASSERT(vec);
-      err = VecGetArray(vec, &a);CHECK_PETSC_ERROR(err);
-      for(PetscInt c = 0; c < numCells; ++c) {
-        const PetscInt cell = cells ? cells[c] : c+cStart;
-        PetscInt       dof, off;
+  // Set cell fields
+  for (int i=0; i < nfields; ++i) {
+    const char* name = _data->cellFieldsInfo[i].name;
+    const int fiberDim = _data->cellFieldsInfo[i].fiber_dim;
+    fields->add(name, name);
+    MeshField& field = fields->get(name);
+    field.newSection(topology::FieldBase::CELLS_FIELD, fiberDim);
+    field.allocate();
+    field.vectorFieldType(_data->cellFieldsInfo[i].field_type);
 
-        err = PetscSectionGetDof(section, cell, &dof);CHECK_PETSC_ERROR(err);
-        err = PetscSectionGetOffset(section, cell, &off);CHECK_PETSC_ERROR(err);
-        for(PetscInt d = 0; d < dof; ++d) {
-          a[off+d] = _data->cellFields[i][c*dof+d];
-        }
+    topology::VecVisitorMesh fieldVisitor(field);
+    PetscScalar* fieldArray = fieldVisitor.localArray();CPPUNIT_ASSERT(fieldArray);
+    
+    for(PetscInt c = 0, index = 0; c < numCells; ++c) {
+      const PetscInt cell = cells ? cells[c] : c+cStart;
+      
+      const PetscInt off = fieldVisitor.sectionOffset(cell);
+      CPPUNIT_ASSERT_EQUAL(fiberDim, fieldVisitor.sectionDof(cell));
+      for(PetscInt d = 0; d < fiberDim; ++d, ++index) {
+	fieldArray[off+d] = _data->cellFields[i][index];
       } // for
-      err = VecRestoreArray(vec, &a);CHECK_PETSC_ERROR(err);
-      CPPUNIT_ASSERT_EQUAL(_data->numCells, numCells);
     } // for
-    if (_data->cellsLabel) {
-      err = ISRestoreIndices(cellIS, &cells);CHECK_PETSC_ERROR(err);
-    }
-  } catch (const ALE::Exception& err) {
-    throw std::runtime_error(err.msg());
-  } catch (...) {
-    throw;
-  } // catch
+    CPPUNIT_ASSERT_EQUAL(_data->numCells, numCells);
+  } // for
+  delete cellsIS; cellsIS = 0;
+
+  PYLITH_METHOD_END;
 } // _createCellFields
 
 

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.cc	2013-04-11 00:01:54 UTC (rev 21805)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.cc	2013-04-11 00:02:17 UTC (rev 21806)
@@ -20,6 +20,8 @@
 
 #include "TestDataWriterVTK.hh" // Implementation of class methods
 
+#include "pylith/utils/petscerror.h" // USES PYLITH_METHOD_BEGIN/END
+
 #include <cppunit/extensions/HelperMacros.h>
 
 #include <string.h> // USES strcmp()
@@ -34,6 +36,7 @@
 					     const PylithScalar t,
 					     const char* timeFormat)
 { // checkFile
+  PYLITH_METHOD_BEGIN;
 
   const std::string& fileroot = filenameRoot;
 
@@ -46,8 +49,7 @@
   const int pos = timestamp.find(".");
   if (pos != timestamp.length())
     timestamp.erase(pos, 1);
-  buffer
-    << std::string(fileroot, 0, indexExt) << "_t" << timestamp << ".vtk";
+  buffer << std::string(fileroot, 0, indexExt) << "_t" << timestamp << ".vtk";
   
   const std::string& filename = buffer.str();
   const std::string filenameE = "data/" + filename;
@@ -82,6 +84,8 @@
 
   fileInE.close();
   fileIn.close();
+
+  PYLITH_METHOD_END;
 } // checkFile
 
 

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMesh.cc	2013-04-11 00:01:54 UTC (rev 21805)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMesh.cc	2013-04-11 00:02:17 UTC (rev 21806)
@@ -40,7 +40,11 @@
 void
 pylith::meshio::TestDataWriterVTKMesh::setUp(void)
 { // setUp
+  PYLITH_METHOD_BEGIN;
+
   TestDataWriterMesh::setUp();
+
+  PYLITH_METHOD_END;
 } // setUp
 
 // ----------------------------------------------------------------------
@@ -48,7 +52,11 @@
 void
 pylith::meshio::TestDataWriterVTKMesh::tearDown(void)
 { // tearDown
+  PYLITH_METHOD_BEGIN;
+
   TestDataWriterMesh::tearDown();
+
+  PYLITH_METHOD_END;
 } // tearDown
 
 // ----------------------------------------------------------------------
@@ -56,11 +64,15 @@
 void
 pylith::meshio::TestDataWriterVTKMesh::testConstructor(void)
 { // testConstructor
+  PYLITH_METHOD_BEGIN;
+
   DataWriterVTK<topology::Mesh, MeshField> writer;
 
-  CPPUNIT_ASSERT(0 == writer._viewer);
-  CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
-  CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+  CPPUNIT_ASSERT(!writer._viewer);
+  CPPUNIT_ASSERT_EQUAL(false, writer._wroteVertexHeader);
+  CPPUNIT_ASSERT_EQUAL(false, writer._wroteCellHeader);
+
+  PYLITH_METHOD_END;
 } // testConstructor
 
 // ----------------------------------------------------------------------
@@ -68,11 +80,15 @@
 void
 pylith::meshio::TestDataWriterVTKMesh::testFilename(void)
 { // testDebug
+  PYLITH_METHOD_BEGIN;
+
   DataWriterVTK<topology::Mesh, MeshField> writer;
 
   const char* filename = "data.vtk";
   writer.filename(filename);
   CPPUNIT_ASSERT_EQUAL(std::string(filename), writer._filename);
+
+  PYLITH_METHOD_END;
 } // testFilename
 
 // ----------------------------------------------------------------------
@@ -80,11 +96,15 @@
 void
 pylith::meshio::TestDataWriterVTKMesh::testTimeFormat(void)
 { // testTimeFormat
+  PYLITH_METHOD_BEGIN;
+
   DataWriterVTK<topology::Mesh, MeshField> writer;
 
   const char* format = "%4.1f";
   writer.timeFormat(format);
   CPPUNIT_ASSERT_EQUAL(std::string(format), writer._timeFormat);
+
+  PYLITH_METHOD_END;
 } // testTimeFormat
 
 // ----------------------------------------------------------------------
@@ -92,11 +112,15 @@
 void
 pylith::meshio::TestDataWriterVTKMesh::testTimeConstant(void)
 { // testTimeConstant
+  PYLITH_METHOD_BEGIN;
+
   DataWriterVTK<topology::Mesh, MeshField> writer;
 
   const PylithScalar value = 4.5;
   writer.timeConstant(value);
   CPPUNIT_ASSERT_EQUAL(value, writer._timeConstant);
+
+  PYLITH_METHOD_END;
 } // testTimeConstant
 
 // ----------------------------------------------------------------------
@@ -104,11 +128,15 @@
 void
 pylith::meshio::TestDataWriterVTKMesh::testPrecision(void)
 { // testPrecision
+  PYLITH_METHOD_BEGIN;
+
   DataWriterVTK<topology::Mesh, MeshField> writer;
 
   const int value = 4;
   writer.precision(value);
   CPPUNIT_ASSERT_EQUAL(value, writer._precision);
+
+  PYLITH_METHOD_END;
 } // testPrecision
 
 // ----------------------------------------------------------------------
@@ -116,20 +144,22 @@
 void
 pylith::meshio::TestDataWriterVTKMesh::testTimeStep(void)
 { // testTimeStep
-  CPPUNIT_ASSERT(0 != _mesh);
-  CPPUNIT_ASSERT(0 != _data);
+  PYLITH_METHOD_BEGIN;
 
+  CPPUNIT_ASSERT(_mesh);
+  CPPUNIT_ASSERT(_data);
+
   DataWriterVTK<topology::Mesh, MeshField> writer;
 
   writer.filename(_data->timestepFilename);
   writer.timeFormat(_data->timeFormat);
 
-  CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
-  CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+  CPPUNIT_ASSERT_EQUAL(false, writer._wroteVertexHeader);
+  CPPUNIT_ASSERT_EQUAL(false, writer._wroteCellHeader);
 
   const PylithScalar t = _data->time;
   const int numTimeSteps = 1;
-  if (0 == _data->cellsLabel) {
+  if (!_data->cellsLabel) {
     writer.open(*_mesh, numTimeSteps);
     writer.openTimeStep(t, *_mesh);
   } else {
@@ -139,17 +169,18 @@
     writer.openTimeStep(t, *_mesh, label, id);
   } // else
 
-  CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
-  CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+  CPPUNIT_ASSERT_EQUAL(false, writer._wroteVertexHeader);
+  CPPUNIT_ASSERT_EQUAL(false, writer._wroteCellHeader);
 
   writer.closeTimeStep();
   writer.close();
 
-  CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
-  CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+  CPPUNIT_ASSERT_EQUAL(false, writer._wroteVertexHeader);
+  CPPUNIT_ASSERT_EQUAL(false, writer._wroteCellHeader);
 
-  // We do not create empty VTK files anymore
-  //checkFile(_data->timestepFilename, t, _data->timeFormat);
+  // Nothing to check. We do not create VTK files without fields anymore.
+
+  PYLITH_METHOD_END;
 } // testTimeStep
 
 // ----------------------------------------------------------------------
@@ -157,9 +188,11 @@
 void
 pylith::meshio::TestDataWriterVTKMesh::testWriteVertexField(void)
 { // testWriteVertexField
-  CPPUNIT_ASSERT(0 != _mesh);
-  CPPUNIT_ASSERT(0 != _data);
+  PYLITH_METHOD_BEGIN;
 
+  CPPUNIT_ASSERT(_mesh);
+  CPPUNIT_ASSERT(_data);
+
   DataWriterVTK<topology::Mesh, MeshField> writer;
 
   topology::Fields<MeshField> vertexFields(*_mesh);
@@ -172,7 +205,7 @@
 
   const PylithScalar t = _data->time;
   const int numTimeSteps = 1;
-  if (0 == _data->cellsLabel) {
+  if (!_data->cellsLabel) {
     writer.open(*_mesh, numTimeSteps);
     writer.openTimeStep(t, *_mesh);
   } else {
@@ -185,14 +218,16 @@
     MeshField& field = vertexFields.get(_data->vertexFieldsInfo[i].name);
     writer.writeVertexField(t, field, *_mesh);
     CPPUNIT_ASSERT(writer._wroteVertexHeader);
-    CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+    CPPUNIT_ASSERT_EQUAL(false, writer._wroteCellHeader);
   } // for
   writer.closeTimeStep();
   writer.close();
-  CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
-  CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+  CPPUNIT_ASSERT_EQUAL(false, writer._wroteVertexHeader);
+  CPPUNIT_ASSERT_EQUAL(false, writer._wroteCellHeader);
   
   checkFile(_data->vertexFilename, t, _data->timeFormat);
+
+  PYLITH_METHOD_END;
 } // testWriteVertexField
 
 // ----------------------------------------------------------------------
@@ -200,9 +235,11 @@
 void
 pylith::meshio::TestDataWriterVTKMesh::testWriteCellField(void)
 { // testWriteCellField
-  CPPUNIT_ASSERT(0 != _mesh);
-  CPPUNIT_ASSERT(0 != _data);
+  PYLITH_METHOD_BEGIN;
 
+  CPPUNIT_ASSERT(_mesh);
+  CPPUNIT_ASSERT(_data);
+
   DataWriterVTK<topology::Mesh, MeshField> writer;
 
   topology::Fields<MeshField> cellFields(*_mesh);
@@ -215,13 +252,13 @@
 
   const PylithScalar t = _data->time;
   const int numTimeSteps = 1;
-  if (0 == _data->cellsLabel) {
+  if (!_data->cellsLabel) {
     writer.open(*_mesh, numTimeSteps);
     writer.openTimeStep(t, *_mesh);
     for (int i=0; i < nfields; ++i) {
       MeshField& field = cellFields.get(_data->cellFieldsInfo[i].name);
       writer.writeCellField(t, field);
-      CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+      CPPUNIT_ASSERT_EQUAL(false, writer._wroteVertexHeader);
       CPPUNIT_ASSERT(writer._wroteCellHeader);
     } // for
   } else {
@@ -232,22 +269,26 @@
     for (int i=0; i < nfields; ++i) {
       MeshField& field = cellFields.get(_data->cellFieldsInfo[i].name);
       writer.writeCellField(t, field, label, id);
-      CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+      CPPUNIT_ASSERT_EQUAL(false, writer._wroteVertexHeader);
       CPPUNIT_ASSERT(writer._wroteCellHeader);
     } // for
   } // else
   writer.closeTimeStep();
   writer.close();
-  CPPUNIT_ASSERT(false == writer._wroteCellHeader);
-  CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+  CPPUNIT_ASSERT_EQUAL(false, writer._wroteCellHeader);
+  CPPUNIT_ASSERT_EQUAL(false, writer._wroteCellHeader);
   
   checkFile(_data->cellFilename, t, _data->timeFormat);
+
+  PYLITH_METHOD_END;
 } // testWriteCellField
 
 // ----------------------------------------------------------------------
 // Test _vtkFilename.
 void pylith::meshio::TestDataWriterVTKMesh::testVtkFilename(void)
 { // testVtkFilename
+  PYLITH_METHOD_BEGIN;
+
   DataWriterVTK<topology::Mesh, MeshField> writer;
 
   // Append info to filename if number of time steps is 0.
@@ -269,6 +310,8 @@
   writer.timeConstant(20.0);
   CPPUNIT_ASSERT_EQUAL(std::string("output_t0250.vtk"), 
 		       writer._vtkFilename(50.0));
+
+  PYLITH_METHOD_END;
 } // testVtkFilename
 
 



More information about the CIG-COMMITS mailing list