[cig-commits] r14202 - long/3D/SNAC/trunk/Snac/plugins/hillSlope
cstark at geodynamics.org
cstark at geodynamics.org
Tue Mar 3 09:23:34 PST 2009
Author: cstark
Date: 2009-03-03 09:23:34 -0800 (Tue, 03 Mar 2009)
New Revision: 14202
Modified:
long/3D/SNAC/trunk/Snac/plugins/hillSlope/ConstructExtensions.c
long/3D/SNAC/trunk/Snac/plugins/hillSlope/Context.h
long/3D/SNAC/trunk/Snac/plugins/hillSlope/CreateWeakPoints.c
long/3D/SNAC/trunk/Snac/plugins/hillSlope/InitialConditions.c
long/3D/SNAC/trunk/Snac/plugins/hillSlope/Track.c
long/3D/SNAC/trunk/Snac/plugins/hillSlope/make.log
Log:
Major changes to Track.c, minor to CreateWeakPoints.c and others
1) Elastic eqm flagging now coordinated between parallel processes
2) Threshold used to detect eqm now given as absolute (dbl) value in input.xml
Details:
1a) Flagging in Track.c used to detect slowing down of surface motions without regard for parallel processes. This led to termination of processing in one thread when eqm was detected in that thread, while other threads kept going.
Now we use a "consensus" global (between threads) elastic eqm flag that is a logical AND of all the individual thread flags. This flag can be set in the input xml to ensure that we don't wait for elastic eqm and weak points are created immediately.
1b) The local time step limit is set to the current time step when the consensus flag is TRUE. This is another change: before, simulation was set to continue by another "dump" time steps to ensure printing of the final state (which became annoying when plastic strain set in quickly).
NB: the parallelization of tracking has not been tested yet. This revsion is therefore a "test" commit.
2) The thresholds used to start tracking and identify elastic eqm are now given explicitly (absolute not relative values) in the input xml. Previously the initial velocity, acceln values were used to normalize their instantaneous values and thresholding was done against these relative values.
Thus, all previous input xml files will not work correctly with the new version. Changes must be made to startThreshold and stopThreshold variables. Defaults are 1e-2 and 1e-3.
Modified: long/3D/SNAC/trunk/Snac/plugins/hillSlope/ConstructExtensions.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/hillSlope/ConstructExtensions.c 2009-03-03 15:46:40 UTC (rev 14201)
+++ long/3D/SNAC/trunk/Snac/plugins/hillSlope/ConstructExtensions.c 2009-03-03 17:23:34 UTC (rev 14202)
@@ -135,14 +135,17 @@
contextExt->startThreshold = Dictionary_Entry_Value_AsDouble(
Dictionary_GetDefault( context->dictionary, "startThreshold",
- Dictionary_Entry_Value_FromDouble( 1.0f ) ) );
+ Dictionary_Entry_Value_FromDouble( 1.0e-2f ) ) );
contextExt->stopThreshold = Dictionary_Entry_Value_AsDouble(
Dictionary_GetDefault( context->dictionary, "stopThreshold",
- Dictionary_Entry_Value_FromDouble( 1.0f ) ) );
+ Dictionary_Entry_Value_FromDouble( 1.0e-3f ) ) );
contextExt->startedTrackingFlag = Dictionary_Entry_Value_AsBool(
Dictionary_GetDefault( context->dictionary, "startedTrackingFlag",
Dictionary_Entry_Value_FromBool( 0 ) ) );
+ contextExt->consensusElasticStabilizedFlag = Dictionary_Entry_Value_AsBool(
+ Dictionary_GetDefault( context->dictionary, "consensusElasticStabilizedFlag",
+ Dictionary_Entry_Value_FromBool( 0 ) ) );
contextExt->elasticStabilizedFlag = Dictionary_Entry_Value_AsBool(
Dictionary_GetDefault( context->dictionary, "elasticStabilizedFlag",
Dictionary_Entry_Value_FromBool( 0 ) ) );
Modified: long/3D/SNAC/trunk/Snac/plugins/hillSlope/Context.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/hillSlope/Context.h 2009-03-03 15:46:40 UTC (rev 14201)
+++ long/3D/SNAC/trunk/Snac/plugins/hillSlope/Context.h 2009-03-03 17:23:34 UTC (rev 14202)
@@ -65,6 +65,7 @@
double startThreshold;
double stopThreshold;
int startedTrackingFlag;
+ int consensusElasticStabilizedFlag;
int elasticStabilizedFlag;
int solveElasticEqmOnlyFlag;
int seedingCompletedFlag;
Modified: long/3D/SNAC/trunk/Snac/plugins/hillSlope/CreateWeakPoints.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/hillSlope/CreateWeakPoints.c 2009-03-03 15:46:40 UTC (rev 14201)
+++ long/3D/SNAC/trunk/Snac/plugins/hillSlope/CreateWeakPoints.c 2009-03-03 17:23:34 UTC (rev 14202)
@@ -126,9 +126,9 @@
/*
- * Bail now if initial elastic equilibrium has not been reached
+ * Bail now if initial elastic equilibrium has not been reached on all threads
*/
- if(!contextExt->elasticStabilizedFlag || contextExt->seedingCompletedFlag) return;
+ if(!contextExt->consensusElasticStabilizedFlag || contextExt->seedingCompletedFlag) return;
// fprintf(stderr, "CWP\n");
@@ -297,7 +297,7 @@
} // End if
/*
- * Flag that seeing has been done and don't do any more
+ * Flag that seeding has been done and don't do any more
*/
contextExt->seedingCompletedFlag = TRUE;
}
@@ -341,7 +341,7 @@
plasticStrain = pl1+(pl2-pl1)*( (cohesion-coh1)/(coh2-coh1) );
if( plasticStrain >= pl1 && plasticStrain <= pl2 ) {
#ifdef DEBUG
- fprintf(stderr, "Returning plastic strain = %g from cohesion = %g (%g, %g)\n", plasticStrain, cohesion, coh1,coh2);
+ // fprintf(stderr, "Returning plastic strain = %g from cohesion = %g (%g, %g)\n", plasticStrain, cohesion, coh1,coh2);
#endif
return plasticStrain;
}
Modified: long/3D/SNAC/trunk/Snac/plugins/hillSlope/InitialConditions.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/hillSlope/InitialConditions.c 2009-03-03 15:46:40 UTC (rev 14201)
+++ long/3D/SNAC/trunk/Snac/plugins/hillSlope/InitialConditions.c 2009-03-03 17:23:34 UTC (rev 14202)
@@ -112,10 +112,10 @@
#ifdef DEBUG
printf( "In: %s\n", __func__ );
#endif
- fprintf(stderr, "Slope angle = %g degrees\n", slopeAngle/(M_PI/180.0));
+ // fprintf(stderr, "Slope angle = %g degrees\n", slopeAngle/(M_PI/180.0));
/* Report HillSlope plugin variables picked up (?) from xml parameter file */
- Journal_Printf( context->snacInfo, "\n\tSlope angle = %g degrees\n", slopeAngle/(M_PI/180.0) );
+ Journal_Printf( context->snacInfo, "\nSlope angle = %g degrees\n", slopeAngle/(M_PI/180.0) );
reg_dx = (geometry->max[0]-geometry->min[0])/(double)(full_I_node_range-1);
reg_dy = (geometry->max[1]-geometry->min[1])/(double)(full_J_node_range-1);
Modified: long/3D/SNAC/trunk/Snac/plugins/hillSlope/Track.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/hillSlope/Track.c 2009-03-03 15:46:40 UTC (rev 14201)
+++ long/3D/SNAC/trunk/Snac/plugins/hillSlope/Track.c 2009-03-03 17:23:34 UTC (rev 14202)
@@ -44,7 +44,7 @@
#define FALSE 0
#endif
-//#define DEBUG
+#define DEBUG
void SnacHillSlope_Track( void* _context ) {
Snac_Context *context = (Snac_Context*)_context;
@@ -69,16 +69,22 @@
static char fallingFlag=FALSE;
const double trackLevel=(double)contextExt->trackLevel;
- const double startThreshold=(double)(contextExt->startThreshold<=1?
- (contextExt->startThreshold>=0 ? contextExt->startThreshold : 0) : 1);
- const double stopThreshold=(double)(contextExt->stopThreshold<=1?
- (contextExt->stopThreshold>=0 ? contextExt->stopThreshold : 0) : 1);
+ const double startThreshold=(contextExt->startThreshold>=0.0 ? contextExt->startThreshold : 1e-2);
+ const double stopThreshold=(contextExt->stopThreshold>=0.0 ? contextExt->stopThreshold : 1e-3);
/* if (context->timeStep % context->dumpEvery == 0) { */
/* Journal_Printf( context->snacInfo,"timeStep=%d (in track)\n", context->timeStep ); */
/* } */
+
/*
+ * Bail now if all threads have reached elastic equilibrium
+ */
+ if(contextExt->consensusElasticStabilizedFlag){
+ return;
+ }
+
+ /*
* Set up a tracking grids (slices of mesh) to allow t instance to be compared with t-1, t-2 instances
*/
if(context->timeStep==1) {
@@ -108,9 +114,6 @@
index_J=(int)(((double)full_J_node_range-1.0)*(1.0-trackLevel));
node_gI = index_I + full_I_node_range*index_J + full_I_node_range*full_J_node_range*index_K;
node_lI = Mesh_NodeMapGlobalToLocal( mesh, node_gI );
-/* Journal_Printf( context->snacInfo,"\t\t%d,%d,%d -> %d ->%d \n", index_I,index_J,index_K,node_gI,node_lI ); */
-/* node_lI = _MeshDecomp_Node_GlobalToLocal1D( decomp, node_gI ); */
-/* Journal_Printf( context->snacInfo,"\t\t%d,%d,%d -> %d ->%d \n", index_I,index_J,index_K,node_gI,node_lI ); */
/* If a local node, read its elevation, if not, give a dummy value */
if( node_lI < context->mesh->nodeLocalCount ) { /* a local node */
@@ -132,17 +135,7 @@
max_yVelocity = fabs(node_yVelocity);
if(fabs(node_yAcceln)>max_yAcceln)
max_yAcceln = fabs(node_yAcceln);
-/* if(fabs(node_yVelocity)<min_yVelocity && fabs(node_yVelocity)>0.0) */
-/* min_yVelocity = fabs(node_yVelocity); */
-/* if(fabs(node_yAcceln)<min_yAcceln && fabs(node_yAcceln)>0.0) */
-/* min_yAcceln = fabs(node_yAcceln); */
}
-/* Journal_Printf( context->snacInfo, */
-/* "%d,%d,%d -> %d ->%d : y=%0.8f / oy=%0.8f / ooy=%0.8f -> v%g (%g) , a=%g (%g)\n", */
-/* index_I,index_J,index_K,node_gI,node_lI, */
-/* node_yElevation, *tmp_yGridOldPtr, *tmp_yGridOlderPtr, */
-/* node_yVelocity,max_yVelocity, node_yAcceln,max_yAcceln */
-/* ); */
/*
* Record this elevation field and push previous back to "OlderPtr" array
*/
@@ -150,10 +143,6 @@
*tmp_yGridOldPtr = node_yElevation;
}
}
-/* if(!contextExt->startedTrackingFlag && unit_yVelocity>min_yVelocity && min_yVelocity<1.0) */
-/* unit_yVelocity = min_yVelocity; */
-/* if(!contextExt->startedTrackingFlag && unit_yAcceln>min_yAcceln && min_yAcceln<1.0) */
-/* unit_yAcceln = min_yAcceln; */
if(unit_yVelocity==0.0 && max_yVelocity>0.0)
unit_yVelocity = max_yVelocity;
if(unit_yAcceln==0.0 && max_yAcceln>0.0)
@@ -164,53 +153,37 @@
/*
* Decide whether to stop or to continue simulation
*/
- if(contextExt->startedTrackingFlag && !contextExt->elasticStabilizedFlag){
+ if(contextExt->startedTrackingFlag){
#ifdef DEBUG
- fprintf(stderr,"t=%d: elasticStabilizedFlag=%d startedTrackingFlag=%d\n",
- context->timeStep, contextExt->elasticStabilizedFlag, contextExt->startedTrackingFlag );
+ fprintf(stderr,"t=%d: consensusElasticStabilized=%d elasticStabilized=%d startedTracking=%d: max_vel=%g unit_vel=%g\n",
+ context->timeStep, contextExt->consensusElasticStabilizedFlag, contextExt->elasticStabilizedFlag, contextExt->startedTrackingFlag, max_yVelocity, unit_yVelocity );
#endif
fallingFlag = CheckFallingFn(max_yVelocity,max_yAcceln,old_max_yVelocity,old_max_yAcceln);
- if(CheckStabilizingFn(max_yVelocity/unit_yVelocity,
- max_yAcceln/unit_yAcceln, stopThreshold, fallingFlag)==TRUE
- && context->maxTimeSteps!=context->timeStep) {
+/* if(CheckStabilizingFn(max_yVelocity/unit_yVelocity, max_yAcceln/unit_yAcceln, stopThreshold, fallingFlag)==TRUE */
+ if( !contextExt->elasticStabilizedFlag
+ && CheckStabilizingFn(max_yVelocity, max_yAcceln, stopThreshold, fallingFlag)==TRUE
+ && context->maxTimeSteps!=context->timeStep ) {
/*
- * Stabilizing! Therefore terminate processing at the next time step
+ * Stabilizing on this thread
*/
- contextExt->elasticStabilizedFlag=TRUE;
- if(contextExt->solveElasticEqmOnlyFlag)
- context->maxTimeSteps=context->timeStep+context->dumpEvery;
-
-/* Journal_Printf( context->snacInfo,"Stabilizing (falling?=%d) on level %d (%g)\n", */
-/* fallingFlag, index_J, trackLevel ); */
- } else {
- /*
- * Still working...
- */
-/* if (context->timeStep % context->dumpEvery == 0) { */
-/* Journal_Printf( context->snacInfo,"Changing (rising?=%d) on level %d (%g) (t steps=%d/%d)\n", */
-/* fallingFlag, index_J, trackLevel, */
-/* context->timeStep, context->maxTimeSteps ); */
-/* } */
+ contextExt->elasticStabilizedFlag = TRUE;
}
+ /*
+ * Check all threads to see if global equilibration has been reached
+ */
+ MPI_Allreduce( &(contextExt->elasticStabilizedFlag), &(contextExt->consensusElasticStabilizedFlag),
+ 1, MPI_INT, MPI_LAND, context->communicator );
+ /*
+ * If all threads agree to elastic eqm, and we only want to run to this point,
+ * tell the simulation to stop at this time step
+ */
+ if(contextExt->consensusElasticStabilizedFlag) {
+ if(contextExt->solveElasticEqmOnlyFlag) {
+ context->maxTimeSteps=context->timeStep/*+context->dumpEvery*/;
+ }
+ }
}
-
-/* if (context->timeStep % context->dumpEvery == 0) { */
-/* Journal_Printf( context->snacInfo,"\tTracking?=%d unit vel=%g, unit accel=%g\n", */
-/* contextExt->startedTrackingFlag, */
-/* unit_yVelocity/geometry->max[1], unit_yAcceln/geometry->max[1] */
-/* ); */
-/* Journal_Printf( context->snacInfo,"\tmax vel=%g (was %g) , max accel=%g (was %g)\n", */
-/* max_yVelocity/(unit_yVelocity>0.0?unit_yVelocity:1), */
-/* old_max_yVelocity/(unit_yVelocity>0.0?unit_yVelocity:1), */
-/* max_yAcceln/(unit_yAcceln>0.0?unit_yAcceln:1), */
-/* old_max_yAcceln/(unit_yAcceln>0.0?unit_yAcceln:1) */
-/* ); */
-/* Journal_Printf( context->snacInfo,"\tfalling?=%d tracking?=%d stabilized?=%d\n", */
-/* fallingFlag, contextExt->startedTrackingFlag, contextExt->elasticStabilizedFlag); */
-/* } */
-
-
/*
* Record the current mesh slice velocity and acceln for use next iteration
*/
Modified: long/3D/SNAC/trunk/Snac/plugins/hillSlope/make.log
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/hillSlope/make.log 2009-03-03 15:46:40 UTC (rev 14201)
+++ long/3D/SNAC/trunk/Snac/plugins/hillSlope/make.log 2009-03-03 17:23:34 UTC (rev 14202)
@@ -1,8 +1,8 @@
make[1]: Entering directory `/usr/local/SNAC/Snac/plugins/hillSlope'
-/usr/bin/cc -pipe -DVERSION=\"14159\" -DCURR_MODULE_NAME=\"SnacHillSlope\" -DPLUGIN_NAME=SnacHillSlope -Wall -g -fPIC -c -o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/Track.o -I/usr/local/SNAC/build/include -I/usr/local/SNAC/build/include/StGermain -I/usr/local/SNAC/build/include -I/usr/local/include -I/usr/include/libxml2 Track.c
+/usr/bin/cc -pipe -DVERSION=\"14177\" -DCURR_MODULE_NAME=\"SnacHillSlope\" -DPLUGIN_NAME=SnacHillSlope -Wall -g -fPIC -c -o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/Track.o -I/usr/local/SNAC/build/include -I/usr/local/SNAC/build/include/StGermain -I/usr/local/SNAC/build/include -I/usr/local/include -I/usr/include/libxml2 Track.c
Track.c: In function `SnacHillSlope_Track':
-Track.c:56: warning: unused variable `geometry'
-Track.c:70: warning: unused variable `startThreshold'
-/usr/bin/cc -pipe -DVERSION=\"14159\" -DCURR_MODULE_NAME=\"SnacHillSlope\" -DPLUGIN_NAME=SnacHillSlope -Wall -g -o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/SnacHillSlopemodule.so /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/Register.o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/ConstructExtensions.o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/Build.o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/Context.o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/InitialConditions.o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/Track.o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/CreateWeakPoints.o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/DeleteExtensions.o -shared -L/usr/local/SNAC/build/lib -L/usr/local/SNAC/build/lib -lSnac -lStGermain -L/usr/local/lib -lmpich -lpmpich -lpthread -lrt -lxml2 -lz -lpthread -lm -lm -Xlinker -rpath -Xlinker /usr/local/lib
+Track.c:58: warning: unused variable `geometry'
+Track.c:72: warning: unused variable `startThreshold'
+/usr/bin/cc -pipe -DVERSION=\"14177\" -DCURR_MODULE_NAME=\"SnacHillSlope\" -DPLUGIN_NAME=SnacHillSlope -Wall -g -o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/SnacHillSlopemodule.so /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/Register.o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/ConstructExtensions.o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/Build.o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/Context.o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/InitialConditions.o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/Track.o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/CreateWeakPoints.o /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/DeleteExtensions.o -shared -L/usr/local/SNAC/build/lib -L/usr/local/SNAC/build/lib -lSnac -lStGermain -L/usr/local/lib -lmpich -lpmpich -lpthread -lrt -lxml2 -lz -lpthread -lm -lm -Xlinker -rpath -Xlinker /usr/local/lib
/bin/cp -f /usr/local/SNAC/build/tmp/mod-SnacHillSlopemodule.so/SnacHillSlopemodule.so /usr/local/SNAC/build/lib/SnacHillSlopemodule.so
make[1]: Leaving directory `/usr/local/SNAC/Snac/plugins/hillSlope'
More information about the CIG-COMMITS
mailing list