[cig-commits] r21827 - in short/3D/PyLith/trunk: libsrc/pylith/meshio unittests/libtests/meshio

brad at geodynamics.org brad at geodynamics.org
Thu Apr 11 16:29:04 PDT 2013


Author: brad
Date: 2013-04-11 16:29:03 -0700 (Thu, 11 Apr 2013)
New Revision: 21827

Modified:
   short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPointsCases.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnPoints.cc
Log:
Code cleanup.

Modified: short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.cc	2013-04-11 22:45:29 UTC (rev 21826)
+++ short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.cc	2013-04-11 23:29:03 UTC (rev 21827)
@@ -21,6 +21,8 @@
 #include "OutputSolnPoints.hh" // implementation of class methods
 
 #include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Stratum.hh" // USES Stratum
+#include "pylith/topology/VisitorMesh.hh" // USES VecVisitorMesh
 #include "MeshBuilder.hh" // USES MeshBuilder
 
 #include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
@@ -50,6 +52,8 @@
 void
 pylith::meshio::OutputSolnPoints::deallocate(void)
 { // deallocate
+  PYLITH_METHOD_BEGIN;
+
   OutputManager<topology::Mesh, topology::Field<topology::Mesh> >::deallocate();
 
   if (_interpolator) {
@@ -58,6 +62,8 @@
 
   _mesh = 0; // :TODO: Use shared pointer
   delete _pointsMesh; _pointsMesh = 0;
+
+  PYLITH_METHOD_END;
 } // deallocate
   
 // ----------------------------------------------------------------------
@@ -65,8 +71,10 @@
 const pylith::topology::Mesh&
 pylith::meshio::OutputSolnPoints::pointsMesh(void)
 { // pointsMesh
+  PYLITH_METHOD_BEGIN;
+
   assert(_pointsMesh);
-  return *_pointsMesh;
+  PYLITH_METHOD_RETURN(*_pointsMesh);
 } // pointsMesh
 
 
@@ -79,6 +87,8 @@
 						    const int spaceDim,
 						    const spatialdata::units::Nondimensional& normalizer)
 { // setupInterpolator
+  PYLITH_METHOD_BEGIN;
+
   assert(mesh);
   assert(points);
 
@@ -103,33 +113,26 @@
   } // for
 #endif
 
-  const spatialdata::geocoords::CoordSys* csMesh = mesh->coordsys();
-  assert(csMesh);
+  const spatialdata::geocoords::CoordSys* csMesh = mesh->coordsys();assert(csMesh);
   assert(csMesh->spaceDim() == spaceDim);
 
   // Setup interpolator object
-  DM dm = _mesh->dmMesh();
-  MPI_Comm       comm;
+  PetscDM dmMesh = _mesh->dmMesh();assert(dmMesh);
   PetscErrorCode err = 0;
 
-  assert(dm);
-  err = PetscObjectGetComm((PetscObject) dm, &comm);CHECK_PETSC_ERROR(err);
-  err = DMInterpolationCreate(comm, &_interpolator);CHECK_PETSC_ERROR(err);
-  
+  err = DMInterpolationCreate(_mesh->comm(), &_interpolator);CHECK_PETSC_ERROR(err);
   err = DMInterpolationSetDim(_interpolator, spaceDim);CHECK_PETSC_ERROR(err);
-
   err = DMInterpolationAddPoints(_interpolator, numPoints, (PetscReal*) &pointsNondim[0]);CHECK_PETSC_ERROR(err);
   const PetscBool pointsAllProcs = PETSC_TRUE;
-  err = DMInterpolationSetUp(_interpolator, dm, pointsAllProcs);CHECK_PETSC_ERROR(err);
+  err = DMInterpolationSetUp(_interpolator, dmMesh, pointsAllProcs);CHECK_PETSC_ERROR(err);
 
   // Create mesh corresponding to points.
   const int meshDim = 0;
-  delete _pointsMesh; _pointsMesh = new topology::Mesh(meshDim);
+  delete _pointsMesh; _pointsMesh = new topology::Mesh(meshDim);assert(_pointsMesh);
   _pointsMesh->createDMMesh(meshDim);
-  assert(_pointsMesh);
 
   const int numPointsLocal = _interpolator->n;
-  PylithScalar* pointsLocal = 0;
+  PylithScalar* pointsLocal = NULL;
   err = VecGetArray(_interpolator->coords, &pointsLocal);CHECK_PETSC_ERROR(err);
   scalar_array pointsArray(numPointsLocal*spaceDim);
   const int sizeLocal = numPointsLocal*spaceDim;
@@ -138,8 +141,9 @@
     pointsArray[i] = pointsLocal[i]*normalizer.lengthScale();
   } // for
   int_array cells(numPointsLocal);
-  for (int i=0; i < numPointsLocal; ++i)
+  for (int i=0; i < numPointsLocal; ++i) {
     cells[i] = i;
+  } // for
   const int numCells = numPointsLocal;
   const int numCorners = 1;
   const bool interpolate = false;
@@ -151,15 +155,16 @@
   // Set coordinate system and create nondimensionalized coordinates
   _pointsMesh->coordsys(_mesh->coordsys());
   _pointsMesh->nondimensionalize(normalizer);
-
+  
 #if 0 // DEBUGGING
   _pointsMesh->view("POINTS MESH");
 #endif
 
   if (!_fields) {
-    _fields = new topology::Fields<topology::Field<topology::Mesh> >(*_pointsMesh);
+    _fields = new topology::Fields<topology::Field<topology::Mesh> >(*_pointsMesh);assert(_fields);
   } // if
 
+  PYLITH_METHOD_END;
 } // setupInterpolator
 
 
@@ -171,11 +176,15 @@
 				       const char* label,
 				       const int labelId)
 { // open
+  PYLITH_METHOD_BEGIN;
+
   assert(!label);
   assert(!labelId);
 
   assert(_pointsMesh);
   OutputManager<topology::Mesh, topology::Field<topology::Mesh> >::open(*_pointsMesh, numTimeSteps, label, labelId);
+
+  PYLITH_METHOD_END;
 } // open
 
 
@@ -187,11 +196,15 @@
 					       const char* label,
 					       const int labelId)
 { // openTimeStep
+  PYLITH_METHOD_BEGIN;
+
   assert(!label);
   assert(!labelId);
 
   assert(_pointsMesh);
   OutputManager<topology::Mesh, topology::Field<topology::Mesh> >::openTimeStep(t, *_pointsMesh, label, labelId);
+
+  PYLITH_METHOD_END;
 } // openTimeStep
 
 
@@ -199,38 +212,36 @@
 // Append finite-element vertex field to file.
 void
 pylith::meshio::OutputSolnPoints::appendVertexField(const PylithScalar t,
-			       topology::Field<topology::Mesh>& field,
-			       const topology::Mesh& mesh)
+						    topology::Field<topology::Mesh>& field,
+						    const topology::Mesh& mesh)
 { // appendVertexField
+  PYLITH_METHOD_BEGIN;
+
   assert(_mesh);
   assert(_fields);
 
-  DM             pointsDMMesh = _pointsMesh->dmMesh();
-  PetscInt       pvStart, pvEnd;
+  PetscDM pointsDMMesh = _pointsMesh->dmMesh();assert(pointsDMMesh);
+
   PetscErrorCode err;
 
-  assert(pointsDMMesh);
-  err = DMPlexGetDepthStratum(pointsDMMesh, 0, &pvStart, &pvEnd);CHECK_PETSC_ERROR(err);
+  PetscDM dmMesh = field.dmMesh();assert(dmMesh);
+  topology::Stratum verticesStratum(dmMesh, topology::Stratum::DEPTH, 0);
+  const PetscInt vStart = verticesStratum.begin();
+  const PetscInt numVertices = verticesStratum.size();
 
-  DM       dmMesh = field.dmMesh();
-  PetscInt vStart, vEnd;
-
-  assert(dmMesh);
-  err = DMPlexGetDepthStratum(dmMesh, 0, &vStart, &vEnd);CHECK_PETSC_ERROR(err);
-  PetscSection section = field.petscSection();
   PetscInt fiberDimLocal = 0;
+  if (numVertices > 0) {
+    topology::VecVisitorMesh fieldVisitor(field);
+    fiberDimLocal = fieldVisitor.sectionDof(vStart);
+  } // if
   PetscInt fiberDim = 0;
-
-  if (vEnd > vStart) {err = PetscSectionGetDof(section, vStart, &fiberDimLocal);CHECK_PETSC_ERROR(err);}
   MPI_Allreduce(&fiberDimLocal, &fiberDim, 1, MPIU_INT, MPI_MAX, field.mesh().comm());
   assert(fiberDim > 0);
 
   // Create field if necessary for interpolated values or recreate
   // field if mismatch in size between buffer and field.
-  ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
-  logger.stagePush("Output");
   std::ostringstream fieldName;
-  const char   *context = field.label();
+  const char* context = field.label();
   fieldName << context << " (interpolated)" << std::endl;
 
   if (_fields->hasField(fieldName.str().c_str())) {
@@ -239,7 +250,7 @@
     throw std::logic_error(msg.str());
   } // if
   _fields->add(fieldName.str().c_str(), field.label());
-
+  
   topology::Field<topology::Mesh>& fieldInterp = _fields->get(fieldName.str().c_str());
   fieldInterp.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
   fieldInterp.allocate();
@@ -247,18 +258,19 @@
   fieldInterp.label(field.label());
   fieldInterp.vectorFieldType(field.vectorFieldType());
   fieldInterp.scale(field.scale());
-  logger.stagePop();
 
   fieldInterp.createScatter(*_pointsMesh, context);
+
   PetscVec fieldInterpVec = fieldInterp.vector(context);
   assert(fieldInterpVec);
-  
   err = DMInterpolationSetDof(_interpolator, fiberDim);CHECK_PETSC_ERROR(err);
   err = DMInterpolationEvaluate(_interpolator, dmMesh, field.localVector(), fieldInterpVec);CHECK_PETSC_ERROR(err);
 
   fieldInterp.scatterVectorToSection(context);
 
   OutputManager<topology::Mesh, topology::Field<topology::Mesh> >::appendVertexField(t, fieldInterp, *_pointsMesh);
+
+  PYLITH_METHOD_END;
 } // appendVertexField
 
 
@@ -266,9 +278,9 @@
 // Append finite-element cell field to file.
 void
 pylith::meshio::OutputSolnPoints::appendCellField(const PylithScalar t,
-			   topology::Field<topology::Mesh>& field,
-			   const char* label,
-			   const int labelId)
+						  topology::Field<topology::Mesh>& field,
+						  const char* label,
+						  const int labelId)
 { // appendCellField
   throw std::logic_error("OutputSolnPoints::appendCellField() not implemented.");
 } // appendCellField

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.cc	2013-04-11 22:45:29 UTC (rev 21826)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.cc	2013-04-11 23:29:03 UTC (rev 21827)
@@ -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::TestDataWriterPoints::setUp(void)
 { // setUp
+  PYLITH_METHOD_BEGIN;
+
   _data = 0;
   _mesh = 0;
   _flipFault = false;
+
+  PYLITH_METHOD_END;
 } // setUp
 
 // ----------------------------------------------------------------------
@@ -51,8 +57,12 @@
 void
 pylith::meshio::TestDataWriterPoints::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::TestDataWriterPoints::_initialize(void)
 { // _initialize
+  PYLITH_METHOD_BEGIN;
+
   CPPUNIT_ASSERT(_data);
 
-  delete _mesh; _mesh = new topology::Mesh;
+  delete _mesh; _mesh = new topology::Mesh;CPPUNIT_ASSERT(_mesh);
   MeshIOAscii iohandler;
   iohandler.filename(_data->meshFilename);
   iohandler.read(_mesh);
@@ -73,70 +85,64 @@
 
   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::TestDataWriterPoints::_createVertexFields(
-	    topology::Fields<MeshField>* fields) const
+pylith::meshio::TestDataWriterPoints::_createVertexFields(topology::Fields<MeshField>* fields) const
 { // _createVertexFields
+  PYLITH_METHOD_BEGIN;
+
   CPPUNIT_ASSERT(fields);
   CPPUNIT_ASSERT(_mesh);
   CPPUNIT_ASSERT(_data);
 
-  try {
-    const int nfields = _data->numVertexFields;
+  const int nfields = _data->numVertexFields;
 
-    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];
-        }
+  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
 
 

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.cc	2013-04-11 22:45:29 UTC (rev 21826)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.cc	2013-04-11 23:29:03 UTC (rev 21827)
@@ -41,7 +41,11 @@
 void
 pylith::meshio::TestDataWriterVTKPoints::setUp(void)
 { // setUp
+  PYLITH_METHOD_BEGIN;
+
   TestDataWriterPoints::setUp();
+
+  PYLITH_METHOD_END;
 } // setUp
 
 // ----------------------------------------------------------------------
@@ -49,7 +53,11 @@
 void
 pylith::meshio::TestDataWriterVTKPoints::tearDown(void)
 { // tearDown
+  PYLITH_METHOD_BEGIN;
+
   TestDataWriterPoints::tearDown();
+
+  PYLITH_METHOD_END;
 } // tearDown
 
 // ----------------------------------------------------------------------
@@ -57,11 +65,15 @@
 void
 pylith::meshio::TestDataWriterVTKPoints::testConstructor(void)
 { // testConstructor
+  PYLITH_METHOD_BEGIN;
+
   DataWriterVTK<topology::Mesh, MeshField> writer;
 
   CPPUNIT_ASSERT(!writer._viewer);
-  CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
-  CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+  CPPUNIT_ASSERT_EQUAL(false, writer._wroteVertexHeader);
+  CPPUNIT_ASSERT_EQUAL(false, writer._wroteCellHeader);
+
+  PYLITH_METHOD_END;
 } // testConstructor
 
 // ----------------------------------------------------------------------
@@ -69,6 +81,8 @@
 void
 pylith::meshio::TestDataWriterVTKPoints::testTimeStep(void)
 { // testTimeStep
+  PYLITH_METHOD_BEGIN;
+
   CPPUNIT_ASSERT(_mesh);
   CPPUNIT_ASSERT(_data);
 
@@ -79,8 +93,7 @@
   writer.filename(_data->timestepFilename);
   writer.timeFormat(_data->timeFormat);
   output.writer(&writer);
-  output.setupInterpolator(_mesh, _data->points, 
-			   _data->numPoints, _data->spaceDim, normalizer);
+  output.setupInterpolator(_mesh, _data->points, _data->numPoints, _data->spaceDim, normalizer);
 
   const PylithScalar t = _data->time;
   const int numTimeSteps = 1;
@@ -97,8 +110,9 @@
   output.closeTimeStep();
   output.close();
 
-  // 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
 
 // ----------------------------------------------------------------------
@@ -106,6 +120,8 @@
 void
 pylith::meshio::TestDataWriterVTKPoints::testWriteVertexField(void)
 { // testWriteVertexField
+  PYLITH_METHOD_BEGIN;
+
   CPPUNIT_ASSERT(_mesh);
   CPPUNIT_ASSERT(_data);
 
@@ -119,8 +135,7 @@
   writer.filename(_data->vertexFilename);
   writer.timeFormat(_data->timeFormat);
   output.writer(&writer);
-  output.setupInterpolator(_mesh, _data->points, 
-			   _data->numPoints, _data->spaceDim, normalizer);
+  output.setupInterpolator(_mesh, _data->points, _data->numPoints, _data->spaceDim, normalizer);
 
   const int nfields = _data->numVertexFields;
 
@@ -140,14 +155,16 @@
     // field.view("FIELD"); // DEBUGGING
     output.appendVertexField(t, field, *_mesh);
     CPPUNIT_ASSERT(writer._wroteVertexHeader);
-    CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+    CPPUNIT_ASSERT_EQUAL(false, writer._wroteCellHeader);
   } // for
   output.closeTimeStep();
   output.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
 
 

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPointsCases.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPointsCases.cc	2013-04-11 22:45:29 UTC (rev 21826)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPointsCases.cc	2013-04-11 23:29:03 UTC (rev 21827)
@@ -20,6 +20,8 @@
 
 #include "TestDataWriterVTKPointsCases.hh" // Implementation of class methods
 
+#include "pylith/utils/petscerror.h" // USES PYLITH_METHOD_BEGIN/END
+
 #include "data/DataWriterVTKDataPointsTri3.hh" // USES DataWriterVTKDataPointsTri3
 #include "data/DataWriterVTKDataPointsQuad4.hh" // USES DataWriterVTKDataPointsQuad4
 #include "data/DataWriterVTKDataPointsTet4.hh" // USES DataWriterVTKDataPointsTet4
@@ -38,10 +40,14 @@
 void
 pylith::meshio::TestDataWriterVTKPointsTri3::setUp(void)
 { // setUp
+  PYLITH_METHOD_BEGIN;
+
   TestDataWriterVTKPoints::setUp();
   _data = new DataWriterVTKDataPointsTri3;
   _flipFault = true;
   _initialize();
+
+  PYLITH_METHOD_END;
 } // setUp
 
 
@@ -50,10 +56,14 @@
 void
 pylith::meshio::TestDataWriterVTKPointsQuad4::setUp(void)
 { // setUp
+  PYLITH_METHOD_BEGIN;
+
   TestDataWriterVTKPoints::setUp();
   _data = new DataWriterVTKDataPointsQuad4;
   _flipFault = false;
   _initialize();
+
+  PYLITH_METHOD_END;
 } // setUp
 
 
@@ -62,10 +72,14 @@
 void
 pylith::meshio::TestDataWriterVTKPointsTet4::setUp(void)
 { // setUp
+  PYLITH_METHOD_BEGIN;
+
   TestDataWriterVTKPoints::setUp();
   _data = new DataWriterVTKDataPointsTet4;
   _flipFault = true;
   _initialize();
+
+  PYLITH_METHOD_END;
 } // setUp
 
 
@@ -74,10 +88,14 @@
 void
 pylith::meshio::TestDataWriterVTKPointsHex8::setUp(void)
 { // setUp
+  PYLITH_METHOD_BEGIN;
+
   TestDataWriterVTKPoints::setUp();
   _data = new DataWriterVTKDataPointsHex8;
   _flipFault = false;
   _initialize();
+
+  PYLITH_METHOD_END;
 } // setUp
 
 

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnPoints.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnPoints.cc	2013-04-11 22:45:29 UTC (rev 21826)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnPoints.cc	2013-04-11 23:29:03 UTC (rev 21827)
@@ -24,6 +24,7 @@
 
 #include "pylith/topology/Mesh.hh" // USES Mesh
 #include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Stratum.hh" // USES Stratum
 #include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
 
 #include "spatialdata/geocoords/CSCart.hh" // USES CSCart
@@ -39,15 +40,15 @@
 CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestOutputSolnPoints );
 
 // ----------------------------------------------------------------------
-typedef pylith::topology::Mesh::SieveMesh SieveMesh;
-typedef pylith::topology::Mesh::RealSection RealSection;
-
-// ----------------------------------------------------------------------
 // Test constructor
 void
 pylith::meshio::TestOutputSolnPoints::testConstructor(void)
 { // testConstructor
+  PYLITH_METHOD_BEGIN;
+
   OutputSolnPoints output;
+
+  PYLITH_METHOD_END;
 } // testConstructor
 
 
@@ -56,10 +57,14 @@
 void
 pylith::meshio::TestOutputSolnPoints::testSetupInterpolatorTri3(void)
 { // testSetupInterpolatorTri3
+  PYLITH_METHOD_BEGIN;
+
   OutputSolnPoints output;
   OutputSolnPointsDataTri3 data;
 
   _testSetupInterpolator(data);
+
+  PYLITH_METHOD_END;
 } // testSetupInterpolatorTri3
 
 
@@ -68,10 +73,14 @@
 void
 pylith::meshio::TestOutputSolnPoints::testSetupInterpolatorQuad4(void)
 { // testSetupInterpolatorQuad4
+  PYLITH_METHOD_BEGIN;
+
   OutputSolnPoints output;
   OutputSolnPointsDataQuad4 data;
 
   _testSetupInterpolator(data);
+
+  PYLITH_METHOD_END;
 } // testSetupInterpolatorQuad4
 
 
@@ -80,10 +89,14 @@
 void
 pylith::meshio::TestOutputSolnPoints::testSetupInterpolatorTet4(void)
 { // testSetupInterpolatorTet4
+  PYLITH_METHOD_BEGIN;
+
   OutputSolnPoints output;
   OutputSolnPointsDataTet4 data;
 
   _testSetupInterpolator(data);
+
+  PYLITH_METHOD_END;
 } // testSetupInterpolatorTet4
 
 
@@ -92,10 +105,14 @@
 void
 pylith::meshio::TestOutputSolnPoints::testSetupInterpolatorHex8(void)
 { // testSetupInterpolatorHex8
+  PYLITH_METHOD_BEGIN;
+
   OutputSolnPoints output;
   OutputSolnPointsDataHex8 data;
 
   _testSetupInterpolator(data);
+
+  PYLITH_METHOD_END;
 } // testSetupInterpolatorHex8
 
 
@@ -104,6 +121,8 @@
 void
 pylith::meshio::TestOutputSolnPoints::_testSetupInterpolator(const OutputSolnPointsData& data)
 { // _testSetupInterpolator
+  PYLITH_METHOD_BEGIN;
+
   const int numPoints = data.numPoints;
   const int spaceDim = data.spaceDim;
 
@@ -126,46 +145,43 @@
   CPPUNIT_ASSERT(data.points);
   output.setupInterpolator(&mesh, data.points, numPoints, spaceDim, normalizer);
 
-  const topology::Mesh& pointsMesh = output.pointsMesh();
-  const ALE::Obj<SieveMesh>& sievePointsMesh = pointsMesh.sieveMesh();
-  CPPUNIT_ASSERT(!sievePointsMesh.isNull());
+  PetscDM dmMesh = output.pointsMesh().dmMesh();CPPUNIT_ASSERT(dmMesh);
 
-  //pointsMesh.view("POINTS MESH"); // DEBUGGING
-
   // Check vertices
-  const ALE::Obj<SieveMesh::label_sequence>& vertices = 
-    sievePointsMesh->depthStratum(0);
-  const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
-  CPPUNIT_ASSERT_EQUAL(numVerticesE, int(vertices->size()));
-  int ipt = 0;
-  for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
-       v_iter != verticesEnd;
-       ++v_iter, ++ipt) {
-    const int vertexE = numCellsE + ipt;
-    CPPUNIT_ASSERT_EQUAL(vertexE, *v_iter);
+  topology::Stratum verticesStratum(dmMesh, topology::Stratum::DEPTH, 0);
+  const PetscInt vStart = verticesStratum.begin();
+  const PetscInt vEnd = verticesStratum.end();
+  CPPUNIT_ASSERT_EQUAL(numVerticesE, verticesStratum.size());
+  for (PetscInt v=vStart, index = 0; v < vEnd; ++v, ++index) {
+    const int vertexE = numCellsE + index;
+    CPPUNIT_ASSERT_EQUAL(vertexE, v);
   } // for
 
   // Check cells
-  const ALE::Obj<SieveMesh::label_sequence>& cells = 
-    sievePointsMesh->heightStratum(0);
-  const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
-  const ALE::Obj<SieveMesh::sieve_type>& sieve = sievePointsMesh->getSieve();
-  assert(!sieve.isNull());
-
-  CPPUNIT_ASSERT_EQUAL(numCellsE, int(cells->size()));
-
-  ALE::ISieveVisitor::PointRetriever<SieveMesh::sieve_type> pV(sieve->getMaxConeSize());
-  int i = 0;
-  for (SieveMesh::label_sequence::iterator c_iter=cells->begin(); c_iter != cellsEnd; ++c_iter) {
-    sieve->cone(*c_iter, pV);
-    const SieveMesh::point_type* cone = pV.getPoints();
-    CPPUNIT_ASSERT_EQUAL(numCornersE, (int) pV.getSize());
-    for(int p = 0; p < pV.getSize(); ++p, ++i) {
-      const int coneE = numCellsE+i;
-      CPPUNIT_ASSERT_EQUAL(coneE, cone[p]);
+  topology::Stratum cellsStratum(dmMesh, topology::Stratum::HEIGHT, 0);
+  const PetscInt cStart = cellsStratum.begin();
+  const PetscInt cEnd = cellsStratum.end();
+  PetscErrorCode err = 0;
+  CPPUNIT_ASSERT_EQUAL(numCellsE, cellsStratum.size());
+  for (PetscInt c = cStart, index = 0; c < cEnd; ++c) {
+    PetscInt *closure = NULL;
+    PetscInt closureSize = 0;
+    err = DMPlexGetTransitiveClosure(dmMesh, c, PETSC_TRUE, &closureSize, &closure);CHECK_PETSC_ERROR(err);
+    int count = 0;
+    for (int i=0; i < closureSize; ++i) {
+      const PetscInt p = closure[2*i];
+      if (p >= vStart && p < vEnd) {
+	const int coneE = numCellsE+index;
+	CPPUNIT_ASSERT_EQUAL(coneE, p);
+	++count;
+	++index;
+      } // if
     } // for
-    pV.clear();
+    CPPUNIT_ASSERT_EQUAL(numCornersE, count);
+    err = DMPlexRestoreTransitiveClosure(dmMesh, c, PETSC_TRUE, &closureSize, &closure);CHECK_PETSC_ERROR(err);
   } // for
+  
+  PYLITH_METHOD_END;
 } // _testSetupInterpolator
 
 



More information about the CIG-COMMITS mailing list