← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 1752: 1. Enabling O.timingEnabled when running will not produce garbage values for current engine anymore

 

------------------------------------------------------------
revno: 1752
committer: Václav Šmilauer <vaclav@flux>
branch nick: trunk
timestamp: Tue 2009-09-01 11:01:20 +0200
message:
  1. Enabling O.timingEnabled when running will not produce garbage values for current engine anymore
  2. Add maxRefRelStep to VelocityBins, to limit speed fo maximum velocity changes
  3. Fix epydoc format for utils.encodeVideoFromFrames and utils.uniaxialTestFeatures 
modified:
  core/MetaBody.cpp
  examples/mill.py
  pkg/common/DataClass/VelocityBins.cpp
  pkg/common/Engine/StandAloneEngine/InsertionSortCollider.cpp
  pkg/common/Engine/StandAloneEngine/InsertionSortCollider.hpp
  py/utils.py


--
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/MetaBody.cpp'
--- core/MetaBody.cpp	2009-08-06 21:05:28 +0000
+++ core/MetaBody.cpp	2009-09-01 09:01:20 +0000
@@ -87,11 +87,12 @@
 		needsInitializers=false;
 	}
 	//bex.reset(); // uncomment if PhysicalActionContainerReseter is removed
-	TimingInfo::delta last=TimingInfo::getNow();
+	bool TimingInfo_enabled=TimingInfo::enabled; // cache the value, so that when it is changed inside the step, the engine that was just running doesn't get bogus values
+	TimingInfo::delta last=TimingInfo::getNow(); // actually does something only if TimingInfo::enabled, no need to put the condition here
 	FOREACH(const shared_ptr<Engine>& e, engines){
 		if(e->isActivated(this)){
 			e->action(this);
-			if(TimingInfo::enabled) {TimingInfo::delta now=TimingInfo::getNow(); e->timingInfo.nsec+=now-last; e->timingInfo.nExec+=1; last=now;}
+			if(TimingInfo_enabled) {TimingInfo::delta now=TimingInfo::getNow(); e->timingInfo.nsec+=now-last; e->timingInfo.nExec+=1; last=now;}
 		}
 	}
 }

=== modified file 'examples/mill.py'
--- examples/mill.py	2009-08-28 06:41:57 +0000
+++ examples/mill.py	2009-09-01 09:01:20 +0000
@@ -1,4 +1,12 @@
 # encoding: utf-8
+"""
+Small showcase posted at http://www.youtube.com/watch?v=KUv26xlh89I,
+in response to pfc3d's http://www.youtube.com/watch?v=005rdDBoe4w.
+Physical correctness is not the focus, the geometry and similar look is.
+
+You can take this file as instruction on how to build parametric surfaces,
+and how to make videos as well.
+"""
 from yade import pack
 from numpy import linspace
 # geometry parameters

=== modified file 'pkg/common/DataClass/VelocityBins.cpp'
--- pkg/common/DataClass/VelocityBins.cpp	2009-08-20 09:38:22 +0000
+++ pkg/common/DataClass/VelocityBins.cpp	2009-09-01 09:01:20 +0000
@@ -41,7 +41,14 @@
 		if(refMaxVelSq<0){ refMaxVelSq=currMaxVelSq; /* first time */}
 		else {
 			// there should be some maximum speed change parameter, so that bins do not change their limits (and therefore bodies, also!) too often, depending on 1 particle going crazy
-			if(maxRefRelStep>0) refMaxVelSq=min(max(refMaxVelSq/pow(1+maxRefRelStep,2),currMaxVelSq),refMaxVelSq*pow(1+maxRefRelStep,2));
+			if(maxRefRelStep>0){
+				Real limVelSq=pow(sqrt(refMaxVelSq)+(sqrt(currMaxVelSq)-sqrt(refMaxVelSq))*maxRefRelStep,2);
+				// LOG_INFO("limVel="<<sqrt(limVelSq)<<",currMaxVel="<<sqrt(currMaxVelSq)<<",refMaxVel="<<sqrt(refMaxVelSq));
+				if(currMaxVelSq>refMaxVelSq) refMaxVelSq=min(limVelSq,currMaxVelSq);
+				else refMaxVelSq=max(limVelSq,currMaxVelSq);
+				// LOG_INFO("new refMaxVelSq="<<sqrt(refMaxVelSq));
+			}
+			//}refMaxVelSq=min(max(refMaxVelSq/pow(1+maxRefRelStep,2),currMaxVelSq),refMaxVelSq*pow(1+maxRefRelStep,2));
 			else refMaxVelSq=currMaxVelSq;
 			if(refMaxVelSq==0) refMaxVelSq=currMaxVelSq;
 		}

=== modified file 'pkg/common/Engine/StandAloneEngine/InsertionSortCollider.cpp'
--- pkg/common/Engine/StandAloneEngine/InsertionSortCollider.cpp	2009-09-01 08:51:57 +0000
+++ pkg/common/Engine/StandAloneEngine/InsertionSortCollider.cpp	2009-09-01 09:01:20 +0000
@@ -174,8 +174,9 @@
 				} else { // nBins>=1
 					if(!newton->velocityBins){ newton->velocityBins=shared_ptr<VelocityBins>(new VelocityBins(nBins,newton->maxVelocitySq,binCoeff,binOverlap)); }
 					if(!boundDispatcher->velocityBins) boundDispatcher->velocityBins=newton->velocityBins;
-					newton->velocityBins->nBins=nBins; newton->velocityBins->binCoeff=binCoeff; newton->velocityBins->binOverlap=binOverlap; // update things 
-					boundDispatcher->sweepDist=0;
+					// update things:
+					newton->velocityBins->nBins=nBins; newton->velocityBins->binCoeff=binCoeff; newton->velocityBins->binOverlap=binOverlap; newton->velocityBins->maxRefRelStep=maxRefRelStep; newton->velocityBins->histInterval=histInterval;  
+					boundDispatcher->sweepDist=0; // not used with bins at all
 					// re-bin bodies
 					newton->velocityBins->setBins(rb,newton->maxVelocitySq,sweepLength);
 				}

=== modified file 'pkg/common/Engine/StandAloneEngine/InsertionSortCollider.hpp'
--- pkg/common/Engine/StandAloneEngine/InsertionSortCollider.hpp	2009-09-01 08:51:57 +0000
+++ pkg/common/Engine/StandAloneEngine/InsertionSortCollider.hpp	2009-09-01 09:01:20 +0000
@@ -69,7 +69,7 @@
 		//! maximum distance that the fastest body could have travelled since the last run; if >= sweepLength, we could get out of bboxes and will trigger full run
 		Real fastestBodyMaxDist;
 		// parameters to be passed to VelocityBins, if nBins>0
-		int nBins; Real binCoeff, binOverlap;
+		int nBins; Real binCoeff, binOverlap, maxRefRelStep; long histInterval; // this last one is debugging-only
 	#endif
 	private:
 	//! storage for bounds
@@ -102,7 +102,7 @@
 
 	InsertionSortCollider():
 	#ifdef COLLIDE_STRIDED
-		strideActive(false), sweepLength(-1), sweepFactor(1.05), fastestBodyMaxDist(-1), nBins(0), binCoeff(5), binOverlap(0.8),
+		strideActive(false), sweepLength(-1), sweepFactor(1.05), fastestBodyMaxDist(-1), nBins(0), binCoeff(5), binOverlap(0.8), maxRefRelStep(.3), histInterval(100),
 	#endif
 		sortAxis(0), sortThenCollide(false){
 			#ifdef ISC_TIMING
@@ -113,7 +113,7 @@
 	REGISTER_CLASS_AND_BASE(InsertionSortCollider,Collider);
 	REGISTER_ATTRIBUTES(Collider,(sortAxis)(sortThenCollide)
 		#ifdef COLLIDE_STRIDED
-			(strideActive)(sweepLength)(sweepFactor)(fastestBodyMaxDist)(nBins)(binCoeff)(binOverlap)
+			(strideActive)(sweepLength)(sweepFactor)(fastestBodyMaxDist)(nBins)(binCoeff)(binOverlap)(maxRefRelStep)(histInterval)
 		#endif
 	);
 	DECLARE_LOGGER;

=== modified file 'py/utils.py'
--- py/utils.py	2009-08-26 09:10:54 +0000
+++ py/utils.py	2009-09-01 09:01:20 +0000
@@ -312,10 +312,10 @@
 def encodeVideoFromFrames(frameSpec,out,renameNotOverwrite=True,fps=24):
 	"""Create .ogg video from external image files.
 	
-	@param frameSpec If string, wildcard in format understood by GStreamer's multifilesrc plugin (e.g. '/tmp/frame-%04d.png'). If list or tuple, filenames to be encoded in given order.
-	@param out file to save video into
-	@param renameNotOverwrite if True, existing same-named video file will have ~[number] appended; will be overwritten otherwise.
-	@param fps Frames per second.
+	@param frameSpec: If string, wildcard in format understood by GStreamer's multifilesrc plugin (e.g. '/tmp/frame-%04d.png'). If list or tuple, filenames to be encoded in given order. B{Warning:} GStreamer is picky about the wildcard; if you pass a wrong one, if will not complain, but silently stall.
+	@param out: file to save video into
+	@param renameNotOverwrite: if True, existing same-named video file will have ~[number] appended; will be overwritten otherwise.
+	@param fps: Frames per second.
 	"""
 	import pygst,sys,gobject,os,tempfile,shutil
 	pygst.require("0.10")
@@ -452,17 +452,19 @@
 def uniaxialTestFeatures(filename=None,areaSections=10,**kw):
 	"""Get some data about the current packing useful for uniaxial test:
 	
-	1. Find the dimensions that is the longest (uniaxial loading axis)
-	2. Find the minimum cross-section area of the speciment by examining several (areaSections)
-		sections perpendicular to axis, computing area of the convex hull for each one. This will
-		work also for non-prismatic specimen.
-	3. Find the bodies that are on the negative/positive boundary, to which the straining condition
-		should be applied.
-
-	@param filename if given, spheres will be loaded from this file (ASCII format); if not, current simulation will be used.
-	@param areaSection number of section that will be used to estimate cross-section
-
-	Returns dictionary with keys 'negIds', 'posIds', 'axis', 'area'.
+		1. Find the dimensions that is the longest (uniaxial loading axis)
+
+		2. Find the minimum cross-section area of the speciment by examining several (areaSections)
+			sections perpendicular to axis, computing area of the convex hull for each one. This will
+			work also for non-prismatic specimen.
+
+		3. Find the bodies that are on the negative/positive boundary, to which the straining condition
+			should be applied.
+
+	@param filename: if given, spheres will be loaded from this file (ASCII format); if not, current simulation will be used.
+	@param areaSection: number of section that will be used to estimate cross-section
+
+	@return: dictionary with keys 'negIds', 'posIds', 'axis', 'area'.
 	"""
 	if filename: ids=spheresFromFile(filename,**kw)
 	else: ids=[b.id for b in O.bodies]