[cig-commits] r20217 - short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/faults
brad at geodynamics.org
brad at geodynamics.org
Tue May 29 09:46:50 PDT 2012
Author: brad
Date: 2012-05-29 09:46:49 -0700 (Tue, 29 May 2012)
New Revision: 20217
Modified:
short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/faults/FaultCohesiveDyn.cc
Log:
Fixed parallel bug in FaultCohesiveDyn. Sum up norm2 and numVertices across processors when computing norm.
Modified: short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/faults/FaultCohesiveDyn.cc
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/faults/FaultCohesiveDyn.cc 2012-05-29 05:59:26 UTC (rev 20216)
+++ short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/faults/FaultCohesiveDyn.cc 2012-05-29 16:46:49 UTC (rev 20217)
@@ -2265,7 +2265,7 @@
bool isOpening = false;
PylithScalar norm2 = 0.0;
- const int numVertices = _cohesiveVertices.size();
+ int numVertices = _cohesiveVertices.size();
for (int iVertex=0; iVertex < numVertices; ++iVertex) {
const int v_lagrange = _cohesiveVertices[iVertex].lagrange;
const int v_fault = _cohesiveVertices[iVertex].fault;
@@ -2429,7 +2429,17 @@
norm2 = PYLITH_MAXFLOAT;
} // if
- return sqrt(norm2) / numVertices;
+ PylithScalar norm2Total = 0.0;
+ int numVerticesTotal = 0;
+ if (sizeof(PylithScalar) == 8) {
+ MPI_Allreduce(&norm2, &norm2Total, 1, MPI_DOUBLE, MPI_SUM, fields->mesh().comm());
+ } else {
+ MPI_Allreduce(&norm2, &norm2Total, 1, MPI_FLOAT, MPI_SUM, fields->mesh().comm());
+ } // if/else
+ MPI_Allreduce(&numVertices, &numVerticesTotal, 1, MPI_INT, MPI_SUM, fields->mesh().comm());
+
+ assert(numVerticesTotal > 0);
+ return sqrt(norm2Total) / numVerticesTotal;
} // _constrainSolnSpaceNorm
More information about the CIG-COMMITS
mailing list