← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 4176: Add firstIterRun parameter to PyRunner.

 

------------------------------------------------------------
revno: 4176
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Mon 2014-09-29 17:31:49 +0200
message:
  Add firstIterRun parameter to PyRunner.
  
  It allows to execute functions, starting not from the
  0 iterations, but defined in firstIterRun.
  
  Backcompatibility is saved.
modified:
  pkg/common/PeriodicEngines.hpp


--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'pkg/common/PeriodicEngines.hpp'
--- pkg/common/PeriodicEngines.hpp	2014-07-19 19:52:41 +0000
+++ pkg/common/PeriodicEngines.hpp	2014-09-29 15:31:49 +0000
@@ -14,6 +14,15 @@
 			const Real& virtNow=scene->time;
 			Real realNow=getClock();
 			const long& iterNow=scene->iter;
+			
+			if((firstIterRun > 0) && (nDone==0)) {
+				if((firstIterRun > 0) && (firstIterRun == iterNow)) {
+					realLast=realNow; virtLast=virtNow; iterLast=iterNow; nDone++;
+					return true;
+				}
+				return false;
+			}
+			
 			if (iterNow<iterLast) nDone=0;//handle O.resetTime(), all counters will be initialized again
 			if((nDo<0 || nDone<nDo) &&
 				((virtPeriod>0 && virtNow-virtLast>=virtPeriod) ||
@@ -22,6 +31,7 @@
 				realLast=realNow; virtLast=virtNow; iterLast=iterNow; nDone++;
 				return true;
 			}
+			
 			if(nDone==0){
 				realLast=realNow; virtLast=virtNow; iterLast=iterNow; nDone++;
 				if(initRun) return true;
@@ -59,6 +69,7 @@
 		((long,iterPeriod,((void)"deactivated",0),,"Periodicity criterion using step number (deactivated if <= 0)"))
 		((long,nDo,((void)"deactivated",-1),,"Limit number of executions by this number (deactivated if negative)"))
 		((bool,initRun,false,,"Run the first time we are called as well."))
+		((long,firstIterRun,0,,"Sets the step number, at each an engine should be executed for the first time (disabled by default)."))
 		((Real,virtLast,0,,"Tracks virtual time of last run |yupdate|."))
 		((Real,realLast,0,,"Tracks real time of last run |yupdate|."))
 		((long,iterLast,0,,"Tracks step number of last run |yupdate|."))