[cig-commits] [commit] knepley/upgrade-petsc-interface: Added simple checksum for coordinates of cell vertices to reordering test. (1162fc6)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Mon Nov 4 17:18:50 PST 2013


Repository : ssh://geoshell/pylith

On branch  : knepley/upgrade-petsc-interface
Link       : https://github.com/geodynamics/pylith/compare/eb2a274e7c39b6610ad0ae306ac79a71e8e4d8a1...1162fc69f725ebda40f5cb40d68e96ca6fbda4e9

>---------------------------------------------------------------

commit 1162fc69f725ebda40f5cb40d68e96ca6fbda4e9
Author: Brad Aagaard <baagaard at usgs.gov>
Date:   Mon Nov 4 17:21:08 2013 -0800

    Added simple checksum for coordinates of cell vertices to reordering test.


>---------------------------------------------------------------

1162fc69f725ebda40f5cb40d68e96ca6fbda4e9
 .../libtests/topology/TestReverseCuthillMcKee.cc   | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/unittests/libtests/topology/TestReverseCuthillMcKee.cc b/unittests/libtests/topology/TestReverseCuthillMcKee.cc
index 276837e..7856449 100644
--- a/unittests/libtests/topology/TestReverseCuthillMcKee.cc
+++ b/unittests/libtests/topology/TestReverseCuthillMcKee.cc
@@ -28,6 +28,8 @@
 #include "pylith/topology/Jacobian.hh" // USES Field
 #include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
 #include "pylith/faults/FaultCohesiveKin.hh" // USES FaultCohesiveKin
+#include "pylith/topology/Stratum.hh" // USES Stratum
+#include "pylith/topology/CoordsVisitor.hh" // USES CoordsVisitor
 
 // ----------------------------------------------------------------------
 CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestReverseCuthillMcKee );
@@ -216,6 +218,46 @@ pylith::topology::TestReverseCuthillMcKee::_testReorder(const char* filename,
     CPPUNIT_ASSERT_EQUAL(numPointsE, numPoints);
   } // for
 
+  // Check element centroids
+  PylithScalar coordsCheckOrig = 0.0;
+  { // original
+    Stratum cellsStratum(dmOrig, Stratum::HEIGHT, 0);
+    const PetscInt cStart = cellsStratum.begin();
+    const PetscInt cEnd = cellsStratum.end();
+    topology::CoordsVisitor coordsVisitor(dmOrig);
+    for (PetscInt cell = cStart; cell < cEnd; ++cell) {
+      PetscScalar* coordsCell = NULL;
+      PetscInt coordsSize = 0;
+      PylithScalar value = 0.0;
+      coordsVisitor.getClosure(&coordsCell, &coordsSize, cell);
+      for (int i=0; i < coordsSize; ++i) {
+	value += coordsCell[i];
+      } // for
+      coordsCheckOrig += value*value;
+      coordsVisitor.restoreClosure(&coordsCell, &coordsSize, cell);
+    } // for
+  } // original
+  PylithScalar coordsCheck = 0.0;
+  { // reordered
+    Stratum cellsStratum(dmMesh, Stratum::HEIGHT, 0);
+    const PetscInt cStart = cellsStratum.begin();
+    const PetscInt cEnd = cellsStratum.end();
+    topology::CoordsVisitor coordsVisitor(dmMesh);
+    for (PetscInt cell = cStart; cell < cEnd; ++cell) {
+      PetscScalar* coordsCell = NULL;
+      PetscInt coordsSize = 0;
+      PylithScalar value = 0.0;
+      coordsVisitor.getClosure(&coordsCell, &coordsSize, cell);
+      for (int i=0; i < coordsSize; ++i) {
+	value += coordsCell[i];
+      } // for
+      coordsCheck += value*value;
+      coordsVisitor.restoreClosure(&coordsCell, &coordsSize, cell);
+    } // for
+  } // reordered
+  const PylithScalar tolerance = 1.0e-6;
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(coordsCheckOrig, coordsCheck, tolerance*coordsCheckOrig);
+
   // Verify reduction in Jacobian bandwidth
   Field fieldOrig(meshOrig);
   fieldOrig.newSection(FieldBase::VERTICES_FIELD, meshOrig.dimension());



More information about the CIG-COMMITS mailing list