[cig-commits] [commit] knepley/upgrade-petsc-interface: Throw exception with error message instead of assert. (056b660)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Tue Nov 12 10:30:51 PST 2013
Repository : ssh://geoshell/pylith
On branch : knepley/upgrade-petsc-interface
Link : https://github.com/geodynamics/pylith/compare/1955c80cd1c5ef0e23fe374bbad2ea204453c7a8...056b66054f792da728de46f7d51d922eb18f9188
>---------------------------------------------------------------
commit 056b66054f792da728de46f7d51d922eb18f9188
Author: Brad Aagaard <baagaard at usgs.gov>
Date: Tue Nov 12 10:33:27 2013 -0800
Throw exception with error message instead of assert.
>---------------------------------------------------------------
056b66054f792da728de46f7d51d922eb18f9188
libsrc/pylith/faults/FaultCohesiveLagrange.cc | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/libsrc/pylith/faults/FaultCohesiveLagrange.cc b/libsrc/pylith/faults/FaultCohesiveLagrange.cc
index 06f584a..ad88709 100644
--- a/libsrc/pylith/faults/FaultCohesiveLagrange.cc
+++ b/libsrc/pylith/faults/FaultCohesiveLagrange.cc
@@ -1381,6 +1381,7 @@ pylith::faults::FaultCohesiveLagrange::_calcOrientation(const PylithScalar upDir
// Update orientation
const PetscInt ooff = orientationVisitor.sectionOffset(closure[v*2]);
+
for(PetscInt d = 0; d < orientationSize; ++d) {
orientationArray[ooff+d] += orientationVertex[d];
} // for
@@ -1406,10 +1407,22 @@ pylith::faults::FaultCohesiveLagrange::_calcOrientation(const PylithScalar upDir
} // for
for (int iDim = 0; iDim < spaceDim; ++iDim) {
PylithScalar mag = 0;
- for (int jDim = 0, index = iDim * spaceDim; jDim < spaceDim; ++jDim)
+ for (int jDim = 0, index = iDim * spaceDim; jDim < spaceDim; ++jDim) {
mag += pow(orientationVertex[index + jDim], 2);
+ } // for
+
+ if (mag <= 0.0) {
+ std::ostringstream msg;
+ msg << "Error calculating fault orientation at fault vertex " << v << ".\n"
+ << "Orientation vector " << iDim << ": (";
+ for (int jDim = 0, index = iDim * spaceDim; jDim < spaceDim; ++jDim) {
+ msg << " " << orientationVertex[index + jDim];
+ } // for
+ msg << " )" << std::endl;
+ throw std::runtime_error(msg.str());
+ } // if
+
mag = sqrt(mag);
- assert(mag > 0.0);
for (int jDim = 0, index = iDim * spaceDim; jDim < spaceDim; ++jDim)
orientationVertex[index + jDim] /= mag;
} // for
More information about the CIG-COMMITS
mailing list