[cig-commits] [commit] knepley/upgrade-petsc-interface: Fixed some parallel issues. (f0a3d32)

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


Repository : ssh://geoshell/pylith

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

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

commit f0a3d32d2b3bec7153f788326e0f49dde49462c4
Author: Brad Aagaard <baagaard at usgs.gov>
Date:   Thu Nov 21 17:15:39 2013 -0800

    Fixed some parallel issues.
    
    Fix errors associated with meshes not having pieces of boundaries,
    faults, or submeshes.


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

f0a3d32d2b3bec7153f788326e0f49dde49462c4
 libsrc/pylith/bc/BoundaryConditionPoints.cc   |  6 ++--
 libsrc/pylith/faults/FaultCohesiveLagrange.cc | 12 ++++---
 libsrc/pylith/topology/Stratum.icc            | 49 ++++++++++++++++-----------
 3 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/libsrc/pylith/bc/BoundaryConditionPoints.cc b/libsrc/pylith/bc/BoundaryConditionPoints.cc
index 61fb631..8e5a1e9 100644
--- a/libsrc/pylith/bc/BoundaryConditionPoints.cc
+++ b/libsrc/pylith/bc/BoundaryConditionPoints.cc
@@ -102,8 +102,10 @@ pylith::bc::BoundaryConditionPoints::_getPoints(const topology::Mesh& mesh)
       _points[v++] = points[p];
     } // if
   } // for
-  err = ISRestoreIndices(pointIS, &points);PYLITH_CHECK_ERROR(err);
-  err = ISDestroy(&pointIS);PYLITH_CHECK_ERROR(err);
+  if (pointIS) {
+    err = ISRestoreIndices(pointIS, &points);PYLITH_CHECK_ERROR(err);
+    err = ISDestroy(&pointIS);PYLITH_CHECK_ERROR(err);
+  } // if
 
   PYLITH_METHOD_END;
 } // _getPoints
diff --git a/libsrc/pylith/faults/FaultCohesiveLagrange.cc b/libsrc/pylith/faults/FaultCohesiveLagrange.cc
index 5fed7df..cf17d50 100644
--- a/libsrc/pylith/faults/FaultCohesiveLagrange.cc
+++ b/libsrc/pylith/faults/FaultCohesiveLagrange.cc
@@ -904,11 +904,6 @@ pylith::faults::FaultCohesiveLagrange::verifyConfiguration(const topology::Mesh&
   PetscInt eMax;
 
   err = DMPlexGetHybridBounds(dmMesh, NULL, NULL, &eMax, NULL);PYLITH_CHECK_ERROR(err);
-  if (eMax < 0) {
-    std::ostringstream msg;
-    msg << "No hybrid edges found in mesh.";
-    throw std::runtime_error(msg.str());
-  } // if  
 
   // Check for fault groups
   PetscBool hasLabel;
@@ -970,6 +965,13 @@ pylith::faults::FaultCohesiveLagrange::verifyConfiguration(const topology::Mesh&
   topology::StratumIS cohesiveIS(dmMesh, "material-id", id(), includeOnlyCells);
   const PetscInt* cells = cohesiveIS.points();
   const PetscInt ncells = cohesiveIS.size();
+
+  if (ncells > 0 && eMax < 0) {
+    std::ostringstream msg;
+    msg << "No hybrid edges found in mesh with cohesive cells.";
+    throw std::runtime_error(msg.str());
+  } // if  
+
   for(PetscInt i = 0; i < ncells; ++i) {
     PetscInt *closure = NULL;
     PetscInt cellNumEdges = 0, closureSize;
diff --git a/libsrc/pylith/topology/Stratum.icc b/libsrc/pylith/topology/Stratum.icc
index 61dbd8d..dd97a2e 100644
--- a/libsrc/pylith/topology/Stratum.icc
+++ b/libsrc/pylith/topology/Stratum.icc
@@ -88,7 +88,10 @@ inline
 pylith::topology::StratumIS::StratumIS(const PetscDM dmMesh,
 				       const char* label,
 				       const int id,
-				       const bool includeOnlyCells)
+				       const bool includeOnlyCells) :
+  _indexSet(0),
+  _points(0),
+  _size(0)
 { // constructor
   assert(dmMesh);
   PetscErrorCode err;
@@ -98,25 +101,29 @@ pylith::topology::StratumIS::StratumIS(const PetscDM dmMesh,
     PetscIS pointsIS = NULL;
     PetscInt numPoints = 0;
     const PetscInt* points = NULL;
-    err = DMPlexGetStratumIS(dmMesh, label, id, &pointsIS);PYLITH_CHECK_ERROR(err);assert(pointsIS);
-    err = ISGetSize(pointsIS, &numPoints);PYLITH_CHECK_ERROR(err);assert(numPoints >= 0);
-    err = ISGetIndices(pointsIS, &points);PYLITH_CHECK_ERROR(err);assert(!numPoints || points);
-    PetscInt cStart, cEnd;
-    err = DMPlexGetHeightStratum(dmMesh, 0, &cStart, &cEnd);PYLITH_CHECK_ERROR(err);
-    PetscInt* cells = (numPoints > 0) ? new PetscInt[numPoints] : 0;
-    PetscInt count = 0;
-    for (PetscInt i=0; i < numPoints; ++i) {
-      if (points[i] >= cStart && points[i] < cEnd) {
-	cells[count++] = points[i];
-      } // if
-    } // for
-    err = ISCreateGeneral(PETSC_COMM_SELF, count, cells, PETSC_COPY_VALUES, &_indexSet);PYLITH_CHECK_ERROR(err);
-    delete[] cells; cells = 0;
-    err = ISDestroy(&pointsIS);PYLITH_CHECK_ERROR(err);assert(!pointsIS);
+    err = DMPlexGetStratumIS(dmMesh, label, id, &pointsIS);PYLITH_CHECK_ERROR(err);
+    if (pointsIS) {
+      err = ISGetSize(pointsIS, &numPoints);PYLITH_CHECK_ERROR(err);assert(numPoints >= 0);
+      err = ISGetIndices(pointsIS, &points);PYLITH_CHECK_ERROR(err);assert(!numPoints || points);
+      PetscInt cStart, cEnd;
+      err = DMPlexGetHeightStratum(dmMesh, 0, &cStart, &cEnd);PYLITH_CHECK_ERROR(err);
+      PetscInt* cells = (numPoints > 0) ? new PetscInt[numPoints] : 0;
+      PetscInt count = 0;
+      for (PetscInt i=0; i < numPoints; ++i) {
+	if (points[i] >= cStart && points[i] < cEnd) {
+	  cells[count++] = points[i];
+	} // if
+      } // for
+      err = ISCreateGeneral(PETSC_COMM_SELF, count, cells, PETSC_COPY_VALUES, &_indexSet);PYLITH_CHECK_ERROR(err);
+      delete[] cells; cells = 0;
+      err = ISDestroy(&pointsIS);PYLITH_CHECK_ERROR(err);assert(!pointsIS);
+    } // if
   } // if/else
     
-  err = ISGetSize(_indexSet, &_size);PYLITH_CHECK_ERROR(err);assert(_size >= 0);
-  err = ISGetIndices(_indexSet, &_points);PYLITH_CHECK_ERROR(err);assert(!_size || _points);
+  if (_indexSet) {
+    err = ISGetSize(_indexSet, &_size);PYLITH_CHECK_ERROR(err);assert(_size >= 0);
+    err = ISGetIndices(_indexSet, &_points);PYLITH_CHECK_ERROR(err);assert(!_size || _points);
+  } // if
 } // constructor
 
 // ----------------------------------------------------------------------
@@ -134,8 +141,10 @@ void
 pylith::topology::StratumIS::deallocate(void)
 { // deallocate
   PetscErrorCode err = 0;
-  err = ISRestoreIndices(_indexSet, &_points);PYLITH_CHECK_ERROR(err);_points=NULL;
-  err = ISDestroy(&_indexSet);PYLITH_CHECK_ERROR(err);assert(!_indexSet);
+  if (_indexSet) {
+    err = ISRestoreIndices(_indexSet, &_points);PYLITH_CHECK_ERROR(err);_points=NULL;
+    err = ISDestroy(&_indexSet);PYLITH_CHECK_ERROR(err);assert(!_indexSet);
+  } // if
 } // deallocate
 
 // ----------------------------------------------------------------------



More information about the CIG-COMMITS mailing list