[cig-commits] r14407 - in short/3D/PyLith/branches/pylith-swig: libsrc/topology unittests/libtests/topology

brad at geodynamics.org brad at geodynamics.org
Fri Mar 20 14:00:53 PDT 2009


Author: brad
Date: 2009-03-20 14:00:53 -0700 (Fri, 20 Mar 2009)
New Revision: 14407

Modified:
   short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldMesh.cc
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldSubMesh.cc
Log:
Improve tests.

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc	2009-03-20 20:26:01 UTC (rev 14406)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc	2009-03-20 21:00:53 UTC (rev 14407)
@@ -449,7 +449,7 @@
     err = VecScatterDestroy(_scatter); _scatter = 0;
     CHECK_PETSC_ERROR(err);
   } // if
-  
+
   err = MeshCreateGlobalScatter(_mesh.sieveMesh(), _section, &_scatter);
   CHECK_PETSC_ERROR(err);
 } // createScatter

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldMesh.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldMesh.cc	2009-03-20 20:26:01 UTC (rev 14406)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldMesh.cc	2009-03-20 21:00:53 UTC (rev 14407)
@@ -163,13 +163,6 @@
 pylith::topology::TestFieldMesh::testNewSectionChart(void)
 { // testNewSectionChart
   const int fiberDim = 3;
-  const int nconstraints[] = { 0, 2, 1, 3 };
-  const int constraints[] = {
-              // 0
-    0, 2,     // 1
-    2,        // 2
-    0, 1, 2,  // 3
-  };
     
   Mesh mesh;
   _buildMesh(&mesh);
@@ -239,12 +232,11 @@
 	 ++v_iter, index += nconstraints[i++])
       section->setConstraintDof(*v_iter, &constraints[index]);
     fieldSrc.zero();
-    fieldSrc.view("ZERO FIELD"); // TEMPORARY
-    fieldSrc.createScatter(); // ERROR (including this line causes error)
+    fieldSrc.createScatter();
   } // Setup source field
 
   Field<Mesh> field(mesh);
-  field.newSection(fieldSrc); // ERROR REALLY HERE?
+  field.newSection(fieldSrc);
   const ALE::Obj<Mesh::RealSection>& section = field.section();
   CPPUNIT_ASSERT(!section.isNull());
   int iV = 0;
@@ -679,12 +671,12 @@
 
   Mesh mesh;
   _buildMesh(&mesh);
-  const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
-  CPPUNIT_ASSERT(!sieveMesh.isNull());
   Field<Mesh> field(mesh);
   field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
   field.allocate();
   
+  const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+  CPPUNIT_ASSERT(!sieveMesh.isNull());
   const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
   CPPUNIT_ASSERT(!vertices.isNull());
@@ -718,8 +710,19 @@
   CPPUNIT_ASSERT(0 == field._vector);
   field.createVector();
   CPPUNIT_ASSERT(0 != field._vector);
-  const PetscVec vector = field.vector();
-  CPPUNIT_ASSERT_EQUAL(field._vector, vector);
+
+  const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+  CPPUNIT_ASSERT(!sieveMesh.isNull());
+  const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices = 
+    sieveMesh->depthStratum(0);
+  CPPUNIT_ASSERT(!vertices.isNull());
+  
+  const PetscVec vec = field.vector();
+  CPPUNIT_ASSERT_EQUAL(field._vector, vec);
+  int size = 0;
+  VecGetSize(vec, &size);
+  const int sizeE = vertices->size() * fiberDim;
+  CPPUNIT_ASSERT_EQUAL(sizeE, size);
 } // testVector
 
 // ----------------------------------------------------------------------
@@ -763,13 +766,16 @@
 
   Mesh mesh;
   _buildMesh(&mesh);
-  const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
   Field<Mesh> field(mesh);
   field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
   field.allocate();
   const ALE::Obj<Mesh::RealSection>& section = field.section();
+  CPPUNIT_ASSERT(!section.isNull());
+  const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+  CPPUNIT_ASSERT(!sieveMesh.isNull());
   const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
+  CPPUNIT_ASSERT(!vertices.isNull());
 
   double_array values(fiberDim);
   int i = 0;

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldSubMesh.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldSubMesh.cc	2009-03-20 20:26:01 UTC (rev 14406)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldSubMesh.cc	2009-03-20 21:00:53 UTC (rev 14407)
@@ -696,12 +696,12 @@
   Mesh mesh;
   SubMesh submesh;
   _buildMesh(&mesh, &submesh);
-  const ALE::Obj<SubMesh::SieveMesh>& sieveMesh = submesh.sieveMesh();
-  CPPUNIT_ASSERT(!sieveMesh.isNull());
   Field<SubMesh> field(submesh);
   field.newSection(FieldBase::VERTICES_FIELD, fiberDim);
   field.allocate();
   
+  const ALE::Obj<SubMesh::SieveMesh>& sieveMesh = submesh.sieveMesh();
+  CPPUNIT_ASSERT(!sieveMesh.isNull());
   const ALE::Obj<SubMesh::SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
   CPPUNIT_ASSERT(!vertices.isNull());
@@ -729,15 +729,27 @@
   Mesh mesh;
   SubMesh submesh;
   _buildMesh(&mesh, &submesh);
+
   Field<SubMesh> field(submesh);
   field.newSection(FieldBase::VERTICES_FIELD, fiberDim);
   field.allocate();
-  
+
   CPPUNIT_ASSERT(0 == field._vector);
   field.createVector();
   CPPUNIT_ASSERT(0 != field._vector);
-  const PetscVec vector = field.vector();
-  CPPUNIT_ASSERT_EQUAL(field._vector, vector);
+
+  const ALE::Obj<SubMesh::SieveMesh>& sieveMesh = submesh.sieveMesh();
+  CPPUNIT_ASSERT(!sieveMesh.isNull());
+  const ALE::Obj<SubMesh::SieveMesh::label_sequence>& vertices = 
+    sieveMesh->depthStratum(0);
+  CPPUNIT_ASSERT(!vertices.isNull());
+  
+  const PetscVec vec = field.vector();
+  CPPUNIT_ASSERT_EQUAL(field._vector, vec);
+  int size = 0;
+  VecGetSize(vec, &size);
+  const int sizeE = vertices->size() * fiberDim;
+  CPPUNIT_ASSERT_EQUAL(sizeE, size);
 } // testVector
 
 // ----------------------------------------------------------------------
@@ -802,12 +814,13 @@
   CPPUNIT_ASSERT(0 != vec);
   int size = 0;
   VecGetSize(vec, &size);
+  const int sizeE = vertices->size() * fiberDim;
+  CPPUNIT_ASSERT_EQUAL(sizeE, size);
+
   double* valuesVec = 0;
   VecGetArray(vec, &valuesVec);
 
   const double tolerance = 1.0e-06;
-  const int sizeE = vertices->size() * fiberDim;
-  CPPUNIT_ASSERT_EQUAL(sizeE, size);
   for (int i=0; i < sizeE; ++i)
     CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesE[i], valuesVec[i], tolerance);
   VecRestoreArray(vec, &valuesVec);
@@ -829,21 +842,22 @@
   SubMesh submesh;
   _buildMesh(&mesh, &submesh);
   Field<SubMesh> field(submesh);
+  field.newSection(FieldBase::VERTICES_FIELD, fiberDim);
+  field.allocate();
+  field.createVector();
+
   const ALE::Obj<SubMesh::SieveMesh>& sieveMesh = submesh.sieveMesh();
   CPPUNIT_ASSERT(!sieveMesh.isNull());
-  field.newSection(FieldBase::VERTICES_FIELD, fiberDim);
-  field.allocate();
-  const ALE::Obj<SubMesh::RealSection>& section = field.section();
   const ALE::Obj<SubMesh::SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
+  CPPUNIT_ASSERT(!vertices.isNull());
 
-  field.createVector();
   const PetscVec vec = field.vector();
   CPPUNIT_ASSERT(0 != vec);
   int size = 0;
   VecGetSize(vec, &size);
   const int sizeE = vertices->size() * fiberDim;
-  CPPUNIT_ASSERT_EQUAL(sizeE, size); // ERROR: sizeE=9, size=12
+  CPPUNIT_ASSERT_EQUAL(sizeE, size);
 
   const double tolerance = 1.0e-06;
   double* valuesVec = 0;
@@ -857,6 +871,8 @@
 
   double_array values(fiberDim);
   int i = 0;
+  const ALE::Obj<SubMesh::RealSection>& section = field.section();
+  CPPUNIT_ASSERT(!section.isNull());
   for (SubMesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
        v_iter != vertices->end();
        ++v_iter) {
@@ -926,4 +942,5 @@
   submesh->createSubMesh(*mesh, _TestFieldSubMesh::label);
 } // _buildMesh
 
+
 // End of file 



More information about the CIG-COMMITS mailing list