------------------------------------------------------------ revno: 3024 committer: Anton Gladky <gladky.an...@gmail.com> branch nick: yade timestamp: Mon 2012-02-13 21:38:28 +0100 message: Add speed-parameter to Scene and Omega modified: core/Scene.cpp core/Scene.hpp py/wrapper/yadeWrapper.cpp
-- 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 2011-03-17 13:47:46 +0000 +++ core/Scene.cpp 2012-02-13 20:38:28 +0000 @@ -98,6 +98,16 @@ if(unlikely(TimingInfo_enabled)) {TimingInfo::delta now=TimingInfo::getNow(); e->timingInfo.nsec+=now-last; e->timingInfo.nExec+=1; last=now;} } // ** 3. ** epilogue + 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(); + speed = 1000000.0 / dif; + prevTime = timeNow; + } + iter++; time+=dt; subStep=-1; === modified file 'core/Scene.hpp' --- core/Scene.hpp 2011-02-27 13:54:43 +0000 +++ core/Scene.hpp 2012-02-13 20:38:28 +0000 @@ -70,6 +70,7 @@ void setLocalCoords(bool d){ if(d) flags|=LOCAL_COORDS; else flags&=~(LOCAL_COORDS); } bool compressionNegative() const { return flags & COMPRESSION_NEGATIVE; } void setCompressionNegative(bool d){ if(d) flags|=COMPRESSION_NEGATIVE; else flags&=~(COMPRESSION_NEGATIVE); } + boost::posix_time::ptime prevTime; //Time value on the previous step YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(Scene,Serializable,"Object comprising the whole simulation.", @@ -78,6 +79,7 @@ ((bool,subStepping,false,,"Whether we currently advance by one engine in every step (rather than by single run through all engines).")) ((int,subStep,-1,Attr::readonly,"Number of sub-step; not to be changed directly. -1 means to run loop prologue (cell integration), 0…n-1 runs respective engines (n is number of engines), n runs epilogue (increment step number and time.")) ((Real,time,0,Attr::readonly,"Simulation time (virtual time) [s]")) + ((Real,speed,0,Attr::readonly,"Current calculation speed [iter/s]")) ((long,stopAtIter,0,,"Iteration after which to stop the simulation.")) #if 0 // not yet implemented === modified file 'py/wrapper/yadeWrapper.cpp' --- py/wrapper/yadeWrapper.cpp 2012-02-13 10:36:56 +0000 +++ py/wrapper/yadeWrapper.cpp 2012-02-13 20:38:28 +0000 @@ -334,6 +334,7 @@ double time(){return OMEGA.getScene()->time;} double realTime(){ return OMEGA.getRealTime(); } + double speed(){ return OMEGA.getScene()->speed; } double dt_get(){return OMEGA.getScene()->dt;} void dt_set(double dt){ Scene* scene=OMEGA.getScene().get(); @@ -535,6 +536,7 @@ .add_property("stopAtIter",&pyOmega::stopAtIter_get,&pyOmega::stopAtIter_set,"Get/set number of iteration after which the simulation will stop.") .add_property("time",&pyOmega::time,"Return virtual (model world) time of the simulation.") .add_property("realtime",&pyOmega::realTime,"Return clock (human world) time the simulation has been running.") + .add_property("speed",&pyOmega::speed,"Return current calculation speed [iter/sec].") .add_property("dt",&pyOmega::dt_get,&pyOmega::dt_set,"Current timestep (Δt) value.\n\n* assigning negative value enables dynamic Δt (by looking for a :yref:`TimeStepper` in :yref:`O.engine<Omega.engines>`) and sets positive timestep ``O.dt=|Δt|`` (will be used until the timestepper is run and updates it)\n* assigning positive value sets Δt to that value and disables dynamic Δt (via :yref:`TimeStepper`, if there is one).\n\n:yref:`dynDt<Omega.dynDt>` can be used to query whether dynamic Δt is in use.") .add_property("dynDt",&pyOmega::dynDt_get,"Whether a :yref:`TimeStepper` is used for dynamic Δt control. See :yref:`dt<Omega.dt>` on how to enable/disable :yref:`TimeStepper`.") .add_property("dynDtAvailable",&pyOmega::dynDtAvailable_get,"Whether a :yref:`TimeStepper` is amongst :yref:`O.engines<Omega.engines>`, activated or not.")
_______________________________________________ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp