[cig-commits] [commit] baagaard/fix-friction-initial-state: Fault: Replace logic using clamped label with logic using _cohesiveVertices[] - This makes all parts agree on fault definition (c51f9ba)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Wed Jul 16 13:04:40 PDT 2014


Repository : https://github.com/geodynamics/pylith

On branch  : baagaard/fix-friction-initial-state
Link       : https://github.com/geodynamics/pylith/compare/8fb67f577a99f36e359c13bba4e3ea8285f7c1f1...78ec935d3813bf7682983b88d043a477899265be

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

commit c51f9ba2a0a50c27f37f59bdc2f37da2eedd2daf
Author: Matthew G. Knepley <knepley at gmail.com>
Date:   Wed Jul 16 15:04:17 2014 -0500

    Fault: Replace logic using clamped label with logic using _cohesiveVertices[]
    - This makes all parts agree on fault definition


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

c51f9ba2a0a50c27f37f59bdc2f37da2eedd2daf
 libsrc/pylith/faults/FaultCohesiveLagrange.cc | 74 +++++++--------------------
 1 file changed, 19 insertions(+), 55 deletions(-)

diff --git a/libsrc/pylith/faults/FaultCohesiveLagrange.cc b/libsrc/pylith/faults/FaultCohesiveLagrange.cc
index 8bd3b5a..53575ee 100644
--- a/libsrc/pylith/faults/FaultCohesiveLagrange.cc
+++ b/libsrc/pylith/faults/FaultCohesiveLagrange.cc
@@ -126,64 +126,28 @@ pylith::faults::FaultCohesiveLagrange::initialize(const topology::Mesh& mesh,
   const PetscInt vStart = verticesStratum.begin();
   const PetscInt vEnd = verticesStratum.end();
 
-  if (strlen(edge()) > 0 && numPoints > 0) {
-    PetscDMLabel label = NULL;
-    PetscIS clampedIS = NULL;
-    const PetscInt* clampedPoints = NULL;
-    PetscInt numClampedPoints;
-    PetscErrorCode err;
-
-    err = DMPlexGetLabel(mesh.dmMesh(), edge(), &label);PYLITH_CHECK_ERROR(err);
-    err = DMLabelGetStratumIS(label, 1, &clampedIS);PYLITH_CHECK_ERROR(err);
-    if (clampedIS) {
-      err = ISGetLocalSize(clampedIS, &numClampedPoints);PYLITH_CHECK_ERROR(err);
-      err = ISGetIndices(clampedIS, &clampedPoints);PYLITH_CHECK_ERROR(err);
-      for (int i = 0; i < numClampedPoints; ++i) {
-	PetscInt v_fault;
-	err = PetscFindInt(clampedPoints[i], numPoints, points, &v_fault);PYLITH_CHECK_ERROR(err);
-	if (v_fault < vStart || v_fault >= vEnd) { // skip non-vertices
-	  continue;
-	} // if
-
-	err = PetscSectionSetConstraintDof(dispRel.petscSection(), v_fault, spaceDim);PYLITH_CHECK_ERROR(err);
-      } // for
-      err = ISRestoreIndices(clampedIS, &clampedPoints);PYLITH_CHECK_ERROR(err);
-      err = ISDestroy(&clampedIS);PYLITH_CHECK_ERROR(err);
-    } // if
-  } // if
+  const int numVertices = _cohesiveVertices.size();
+  PetscErrorCode err;
+
+  for (int iVertex=0; iVertex < numVertices; ++iVertex) {
+    const int e_lagrange = _cohesiveVertices[iVertex].lagrange;
+    const int v_fault    = _cohesiveVertices[iVertex].fault;
+
+    if (e_lagrange < 0) {err = PetscSectionSetConstraintDof(dispRel.petscSection(), -v_fault, spaceDim);PYLITH_CHECK_ERROR(err);}
+  }
   dispRel.allocate();
-  if (strlen(edge()) > 0 && numPoints > 0) {
-    PetscDMLabel label = NULL;
-    PetscIS clampedIS = NULL;
-    const PetscInt *clampedPoints = NULL;
-    PetscInt numClampedPoints;
-    PetscErrorCode err;
-
-    err = DMPlexGetLabel(mesh.dmMesh(), edge(), &label);PYLITH_CHECK_ERROR(err);
-    err = DMLabelGetStratumIS(label, 1, &clampedIS);PYLITH_CHECK_ERROR(err);
-    if (clampedIS) {
-      err = ISGetLocalSize(clampedIS, &numClampedPoints);PYLITH_CHECK_ERROR(err);
-      err = ISGetIndices(clampedIS, &clampedPoints);PYLITH_CHECK_ERROR(err);
-
-      PetscInt* ind = (spaceDim > 0) ? new PetscInt[spaceDim] : 0;
-      for (int i = 0; i < spaceDim; ++i) { 
-	ind[i] = i;
-      } // for
+  {
+    PetscInt *ind = (spaceDim > 0) ? new PetscInt[spaceDim] : 0;
 
-      for (int i = 0; i < numClampedPoints; ++i) {
-	PetscInt v_fault;
-	err = PetscFindInt(clampedPoints[i], numPoints, points, &v_fault);PYLITH_CHECK_ERROR(err);
-	if (v_fault < vStart || v_fault >= vEnd) { // skip non-vertices
-	  continue;
-	} // if
+    for (int i = 0; i < spaceDim; ++i) ind[i] = i;
+    for (int iVertex = 0; iVertex < numVertices; ++iVertex) {
+      const int e_lagrange = _cohesiveVertices[iVertex].lagrange;
+      const int v_fault    = _cohesiveVertices[iVertex].fault;
 
-	err = PetscSectionSetConstraintIndices(dispRel.petscSection(), v_fault, ind);PYLITH_CHECK_ERROR(err);
-      } // for
-      err = ISRestoreIndices(clampedIS, &clampedPoints);PYLITH_CHECK_ERROR(err);
-      err = ISDestroy(&clampedIS);PYLITH_CHECK_ERROR(err);
-      delete[] ind; ind = 0;
-    } // if
-  } // if
+      if (e_lagrange < 0) {err = PetscSectionSetConstraintIndices(dispRel.petscSection(), -v_fault, ind);PYLITH_CHECK_ERROR(err);}
+    }
+    delete[] ind; ind = 0;
+  }
   dispRel.vectorFieldType(topology::FieldBase::VECTOR);
   dispRel.scale(_normalizer->lengthScale());
 



More information about the CIG-COMMITS mailing list