@@ -135,19 +135,21 @@ pylith::faults::FaultCohesiveLagrange::initialize(const topology::Mesh& mesh,
135135
136136 err = DMPlexGetLabel (mesh.dmMesh (), edge (), &label);PYLITH_CHECK_ERROR (err);
137137 err = DMLabelGetStratumIS (label, 1 , &clampedIS);PYLITH_CHECK_ERROR (err);
138- err = ISGetLocalSize (clampedIS, &numClampedPoints);PYLITH_CHECK_ERROR (err);
139- err = ISGetIndices (clampedIS, &clampedPoints);PYLITH_CHECK_ERROR (err);
140- for (int i = 0 ; i < numClampedPoints; ++i) {
141- PetscInt v_fault;
142- err = PetscFindInt (clampedPoints[i], numPoints, points, &v_fault);PYLITH_CHECK_ERROR (err);
143- if (v_fault < vStart || v_fault >= vEnd) { // skip non-vertices
144- continue ;
145- } // if
146-
147- err = PetscSectionSetConstraintDof (dispRel.petscSection (), v_fault, spaceDim);PYLITH_CHECK_ERROR (err);
148- } // for
149- err = ISRestoreIndices (clampedIS, &clampedPoints);PYLITH_CHECK_ERROR (err);
150- err = ISDestroy (&clampedIS);PYLITH_CHECK_ERROR (err);
138+ if (clampedIS) {
139+ err = ISGetLocalSize (clampedIS, &numClampedPoints);PYLITH_CHECK_ERROR (err);
140+ err = ISGetIndices (clampedIS, &clampedPoints);PYLITH_CHECK_ERROR (err);
141+ for (int i = 0 ; i < numClampedPoints; ++i) {
142+ PetscInt v_fault;
143+ err = PetscFindInt (clampedPoints[i], numPoints, points, &v_fault);PYLITH_CHECK_ERROR (err);
144+ if (v_fault < vStart || v_fault >= vEnd) { // skip non-vertices
145+ continue ;
146+ } // if
147+
148+ err = PetscSectionSetConstraintDof (dispRel.petscSection (), v_fault, spaceDim);PYLITH_CHECK_ERROR (err);
149+ } // for
150+ err = ISRestoreIndices (clampedIS, &clampedPoints);PYLITH_CHECK_ERROR (err);
151+ err = ISDestroy (&clampedIS);PYLITH_CHECK_ERROR (err);
152+ } // if
151153 } // if
152154 dispRel.allocate ();
153155 if (strlen (edge ()) > 0 && numPoints > 0 ) {
@@ -157,28 +159,31 @@ pylith::faults::FaultCohesiveLagrange::initialize(const topology::Mesh& mesh,
157159 PetscInt numClampedPoints;
158160 PetscErrorCode err;
159161
160- PetscInt* ind = (spaceDim > 0 ) ? new PetscInt[spaceDim] : 0 ;
161- for (int i = 0 ; i < spaceDim; ++i) {
162- ind[i] = i;
163- } // for
164-
165162 err = DMPlexGetLabel (mesh.dmMesh (), edge (), &label);PYLITH_CHECK_ERROR (err);
166163 err = DMLabelGetStratumIS (label, 1 , &clampedIS);PYLITH_CHECK_ERROR (err);
167- err = ISGetLocalSize (clampedIS, &numClampedPoints);PYLITH_CHECK_ERROR (err);
168- err = ISGetIndices (clampedIS, &clampedPoints);PYLITH_CHECK_ERROR (err);
169- for (int i = 0 ; i < numClampedPoints; ++i) {
170- PetscInt v_fault;
171- err = PetscFindInt (clampedPoints[i], numPoints, points, &v_fault);PYLITH_CHECK_ERROR (err);
172- if (v_fault < vStart || v_fault >= vEnd) { // skip non-vertices
173- continue ;
174- } // if
164+ if (clampedIS) {
165+ err = ISGetLocalSize (clampedIS, &numClampedPoints);PYLITH_CHECK_ERROR (err);
166+ err = ISGetIndices (clampedIS, &clampedPoints);PYLITH_CHECK_ERROR (err);
175167
176- err = PetscSectionSetConstraintIndices (dispRel.petscSection (), v_fault, ind);PYLITH_CHECK_ERROR (err);
177- } // for
178- err = ISRestoreIndices (clampedIS, &clampedPoints);PYLITH_CHECK_ERROR (err);
179- err = ISDestroy (&clampedIS);PYLITH_CHECK_ERROR (err);
180- delete[] ind; ind = 0 ;
181- } // for
168+ PetscInt* ind = (spaceDim > 0 ) ? new PetscInt[spaceDim] : 0 ;
169+ for (int i = 0 ; i < spaceDim; ++i) {
170+ ind[i] = i;
171+ } // for
172+
173+ for (int i = 0 ; i < numClampedPoints; ++i) {
174+ PetscInt v_fault;
175+ err = PetscFindInt (clampedPoints[i], numPoints, points, &v_fault);PYLITH_CHECK_ERROR (err);
176+ if (v_fault < vStart || v_fault >= vEnd) { // skip non-vertices
177+ continue ;
178+ } // if
179+
180+ err = PetscSectionSetConstraintIndices (dispRel.petscSection (), v_fault, ind);PYLITH_CHECK_ERROR (err);
181+ } // for
182+ err = ISRestoreIndices (clampedIS, &clampedPoints);PYLITH_CHECK_ERROR (err);
183+ err = ISDestroy (&clampedIS);PYLITH_CHECK_ERROR (err);
184+ delete[] ind; ind = 0 ;
185+ } // if
186+ } // if
182187 dispRel.vectorFieldType (topology::FieldBase::VECTOR);
183188 dispRel.scale (_normalizer->lengthScale ());
184189
0 commit comments