[cig-commits] [commit] knepley/upgrade-petsc-interface: Fixed one case of handling NULL PetscIS after DMLabelGetStratumIS(). (f0259ae)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Thu Nov 21 12:02:59 PST 2013


Repository : ssh://geoshell/pylith

On branch  : knepley/upgrade-petsc-interface
Link       : https://github.com/geodynamics/pylith/compare/ecf2a17e6d9b177ca8f9d36d9e824d08dc33cbb7...f0259aec8d6539df4d07e878588af6dc9a41d88f

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

commit f0259aec8d6539df4d07e878588af6dc9a41d88f
Author: Brad Aagaard <baagaard at usgs.gov>
Date:   Thu Nov 21 12:05:43 2013 -0800

    Fixed one case of handling NULL PetscIS after DMLabelGetStratumIS().
    
    Need to fix other cases. If NULL is not expected use assert(myIS);


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

f0259aec8d6539df4d07e878588af6dc9a41d88f
 libsrc/pylith/bc/BoundaryConditionPoints.cc | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/libsrc/pylith/bc/BoundaryConditionPoints.cc b/libsrc/pylith/bc/BoundaryConditionPoints.cc
index dd9518d..61fb631 100644
--- a/libsrc/pylith/bc/BoundaryConditionPoints.cc
+++ b/libsrc/pylith/bc/BoundaryConditionPoints.cc
@@ -72,8 +72,8 @@ pylith::bc::BoundaryConditionPoints::_getPoints(const topology::Mesh& mesh)
   PetscDMLabel label = NULL;
   PetscIS pointIS = NULL;
   const PetscInt *points;
-  PetscInt numPoints, vStart, vEnd, numVertices = 0;
-  PetscBool hasLabel;
+  PetscInt numPoints = 0, vStart = 0, vEnd = 0, numVertices = 0;
+  PetscBool hasLabel = PETSC_FALSE;
   PetscErrorCode err;
   err = DMPlexHasLabel(dmMesh, _label.c_str(), &hasLabel);PYLITH_CHECK_ERROR(err);
   if (!hasLabel) {
@@ -85,12 +85,23 @@ pylith::bc::BoundaryConditionPoints::_getPoints(const topology::Mesh& mesh)
   err = DMPlexGetDepthStratum(dmMesh, 0, &vStart, &vEnd);PYLITH_CHECK_ERROR(err);
   err = DMPlexGetLabel(dmMesh, _label.c_str(), &label);PYLITH_CHECK_ERROR(err);
   err = DMLabelGetStratumIS(label, 1, &pointIS);PYLITH_CHECK_ERROR(err);
-  err = ISGetLocalSize(pointIS, &numPoints);PYLITH_CHECK_ERROR(err);
-  err = ISGetIndices(pointIS, &points);PYLITH_CHECK_ERROR(err);
+  if (pointIS) {
+    err = ISGetLocalSize(pointIS, &numPoints);PYLITH_CHECK_ERROR(err);
+    err = ISGetIndices(pointIS, &points);PYLITH_CHECK_ERROR(err);
+  } // if
+
   // For now, only use vertices
-  for (PetscInt p = 0; p < numPoints; ++p) if ((points[p] >= vStart) && (points[p] < vEnd)) ++numVertices;
+  for (PetscInt p = 0; p < numPoints; ++p) {
+    if ((points[p] >= vStart) && (points[p] < vEnd)) {
+      ++numVertices;
+    } // if
+  } // for
   _points.resize(numVertices);
-  for (PetscInt p = 0, v = 0; p < numPoints; ++p) if ((points[p] >= vStart) && (points[p] < vEnd)) _points[v++] = points[p];
+  for (PetscInt p = 0, v = 0; p < numPoints; ++p) {
+    if ((points[p] >= vStart) && (points[p] < vEnd)) {
+      _points[v++] = points[p];
+    } // if
+  } // for
   err = ISRestoreIndices(pointIS, &points);PYLITH_CHECK_ERROR(err);
   err = ISDestroy(&pointIS);PYLITH_CHECK_ERROR(err);
 



More information about the CIG-COMMITS mailing list