← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 3034: 1. Fix a compilation error with eigen2

 

------------------------------------------------------------
revno: 3034
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Fri 2012-02-17 08:11:54 +0100
message:
  1. Fix a compilation error with eigen2
  2. Add a variable to define number of steps, which are taken into account by speed calculation.
modified:
  core/Scene.cpp
  core/Scene.hpp


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

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'core/Scene.cpp'
--- core/Scene.cpp	2012-02-16 21:43:12 +0000
+++ core/Scene.cpp	2012-02-17 07:11:54 +0000
@@ -98,15 +98,20 @@
 			if(unlikely(TimingInfo_enabled)) {TimingInfo::delta now=TimingInfo::getNow(); e->timingInfo.nsec+=now-last; e->timingInfo.nExec+=1; last=now;}
 		}
 		// ** 3. ** epilogue
+				// Calculation speed
 		if (iter==0) {				//For the first time
 			prevTime = boost::posix_time::microsec_clock::local_time();
 		} else {
 			boost::posix_time::ptime timeNow = boost::posix_time::microsec_clock::local_time();
 			boost::posix_time::time_duration duration = timeNow - prevTime;
 			long dif = duration.total_microseconds();
+			SpeedElements(iter%nSpeedIter,0)=1000000.0 / dif;
 			
-			SpeedElements(iter%10,0)=1000000.0 / dif;
-			speed = SpeedElements.mean();
+			#if EIGEN_WORLD_VERSION==2
+				speed = SpeedElements.sum()/nSpeedIter;
+			#elif EIGEN_WORLD_VERSION==3
+				speed = SpeedElements.mean();
+			#endif
 			
 			prevTime = timeNow;
 		}

=== modified file 'core/Scene.hpp'
--- core/Scene.hpp	2012-02-16 21:43:12 +0000
+++ core/Scene.hpp	2012-02-17 07:11:54 +0000
@@ -54,7 +54,8 @@
 		bool timeStepperActive();
 		// (de)activate TimeStepper; returns whether the operation was successful (i.e. whether a TimeStepper was found)
 		bool timeStepperActivate(bool activate);
-		Eigen::Matrix<Real,10,1> SpeedElements; //Array for saving speed-values for last 10 iterations
+		static const int nSpeedIter = 10;       //Number of iterations, which are taking into account for speed calculation
+		Eigen::Matrix<Real,nSpeedIter,1> SpeedElements; //Array for saving speed-values for last "nSpeedIter"-iterations
 
 
 		shared_ptr<Engine> engineByName(const string& s);