← Back to team overview

yade-dev team mailing list archive

[svn] r1699 - in trunk: extra/clump gui/py pkg/common/Engine/StandAloneEngine

 

Author: eudoxos
Date: 2009-02-28 11:26:47 +0100 (Sat, 28 Feb 2009)
New Revision: 1699

Modified:
   trunk/extra/clump/Shop.cpp
   trunk/gui/py/timing.py
   trunk/gui/py/utils.py
   trunk/gui/py/yade-multi
   trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp
Log:
1. Make Shop load 4/5/6 columns text files for spheres (and skip 5-cols)
2. Change evaluation of args in readParamsFromTable to be able to pass strings better (single quotes) and consistently
3. Parameters passed as env. vars by yade-multi are prefixed with !
4. fix typo in timing for resetting timers.


Modified: trunk/extra/clump/Shop.cpp
===================================================================
--- trunk/extra/clump/Shop.cpp	2009-02-26 17:27:54 UTC (rev 1698)
+++ trunk/extra/clump/Shop.cpp	2009-02-28 10:26:47 UTC (rev 1699)
@@ -4,6 +4,7 @@
 #include<limits>
 
 #include<boost/filesystem/convenience.hpp>
+#include<boost/tokenizer.hpp>
 
 #include<yade/core/MetaBody.hpp>
 #include<yade/core/Body.hpp>
@@ -474,21 +475,29 @@
 	vector<pair<Vector3r,Real> > spheres;
 	ifstream sphereFile(fname.c_str());
 	if(!sphereFile.good()) throw std::runtime_error("File with spheres `"+fname+"' couldn't be opened.");
-	int tmp1,tmp2;
 	Vector3r C;
-	Real r;
-	while(!sphereFile.eof()){
-		sphereFile>>C[0]; sphereFile>>C[1]; sphereFile>>C[2];
-		sphereFile>>r;
-		// TRVAR3(spheres.size(),C,r);
-		sphereFile>>tmp1;
-		if(r==1) continue; // arrrgh, boxes have 5 record/line, spheres have 6; 4th number for box is 1 and we assume there is no sphere with radius 1; Wenjie, I'm gonna tell you one day how smart this format is.
-		if(sphereFile.eof()) continue; // prevents trailing newlines from copying last sphere as well
-		sphereFile>>tmp2; // read the 6th (unused) number for spheres
+	Real r=0;
+	string line;
+	size_t lineNo=0;
+	while(std::getline(sphereFile, line, '\n')){
+		lineNo++;
+		boost::tokenizer<boost::char_separator<char> > toks(line,boost::char_separator<char>(" \t"));
+		int i=0;
+		FOREACH(const string& s, toks){
+			if(i<3) C[i]=lexical_cast<Real>(s);
+			if(i==4) r=lexical_cast<Real>(s);
+			i++;
+		}
+		if(i==0) continue; // empty line, skipped (can be the last one)
+		// Wenjie's format: 5 per line are boxes, which should be skipped
+		if(i==5) continue;
+		if((i!=4) and (i!=6)) {
+			LOG_ERROR("Line "+lexical_cast<string>(lineNo)+" in the spheres file "+fname+" has "+lexical_cast<string>(i)+" columns instead of 0,4,5 or 6.");
+			LOG_ERROR("The result may be garbage!");
+		}
 		for(int j=0; j<3; j++) { minXYZ[j]=(spheres.size()>0?min(C[j]-r,minXYZ[j]):C[j]-r); maxXYZ[j]=(spheres.size()>0?max(C[j]+r,maxXYZ[j]):C[j]+r);}
 		spheres.push_back(pair<Vector3r,Real>(C,r));
 	}
-	//TRVAR2(minXYZ,maxXYZ);
 	return spheres;
 }
 

Modified: trunk/gui/py/timing.py
===================================================================
--- trunk/gui/py/timing.py	2009-02-26 17:27:54 UTC (rev 1698)
+++ trunk/gui/py/timing.py	2009-02-28 10:26:47 UTC (rev 1699)
@@ -9,7 +9,7 @@
 	e.execTime,e.execCount=0,0
 
 def reset():
-	for e in O.engines(): _resetEngine(e)
+	for e in O.engines: _resetEngine(e)
 
 _statCols={'label':40,'count':20,'time':20,'relTime':20}
 _maxLev=3

Modified: trunk/gui/py/utils.py
===================================================================
--- trunk/gui/py/utils.py	2009-02-26 17:27:54 UTC (rev 1698)
+++ trunk/gui/py/utils.py	2009-02-28 10:26:47 UTC (rev 1699)
@@ -354,13 +354,13 @@
 		for i in range(len(names)):
 			if names[i]=='description': o.tags['description']=values[i]
 			else:
-				if names[i] not in kw.keys() and not unknownOk: raise NameError("Parameter `%s' has no default value assigned"%names[i])
+				if names[i] not in kw.keys() and (not unknownOk or names[i][0]=='!'): raise NameError("Parameter `%s' has no default value assigned"%names[i])
 				if names[i] in kw.keys(): kw.pop(names[i])
-				eq="%s=%s"%(names[i],values[i])
+				eq="%s=%s"%(names[i],repr(values[i]))
 				exec('__builtin__.%s=%s'%(names[i],values[i])); tagsParams+=['%s=%s'%(names[i],values[i])]; dictParams[names[i]]=values[i]
 	defaults=[]
 	for k in kw.keys():
-		exec("__builtin__.%s=%s"%(k,kw[k]))
+		exec("__builtin__.%s=%s"%(k,repr(kw[k])))
 		defaults+=["%s=%s"%(k,kw[k])]; dictDefaults[k]=kw[k]
 	o.tags['defaultParams']=",".join(defaults)
 	o.tags['params']=",".join(tagsParams)

Modified: trunk/gui/py/yade-multi
===================================================================
--- trunk/gui/py/yade-multi	2009-02-26 17:27:54 UTC (rev 1698)
+++ trunk/gui/py/yade-multi	2009-02-28 10:26:47 UTC (rev 1699)
@@ -125,7 +125,6 @@
 
 ll=['']+open(table,'r').readlines()
 availableLines=[i for i in range(len(ll)) if not re.match(r'^\s*(#.*)?$',ll[i][:-1]) and i>1]
-print availableLines
 
 # read actual data
 values={}
@@ -171,7 +170,8 @@
 	else: logFile=logFile.replace('@',str(l))
 	envVars=[]
 	for col,head in enumerate(headings):
-		if re.match('^[A-Z_]+[A-Z0-9_]+',head): envVars+=['%s=%s'%(head,values[l][col])]
+		if head=='!EXEC': executable=values[l][col]
+		if head[0]=='!': envVars+=['%s=%s'%(head[1:],values[l][col])]
 	jobs.append(JobInfo(i,idStrings[l] if idStrings else '#'+str(i),'PARAM_TABLE=%s:%d %s nice -n %d %s -N PythonUI -- -n -x %s > %s 2>&1'%(table,l,' '.join(envVars),nice,executable,simul,logFile),logFile))
 
 print "Job summary:"

Modified: trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp
===================================================================
--- trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp	2009-02-26 17:27:54 UTC (rev 1698)
+++ trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp	2009-02-28 10:26:47 UTC (rev 1699)
@@ -26,6 +26,8 @@
 	zBounds.clear();
 	minima.clear();
 	maxima.clear();
+
+	//timingDeltas=shared_ptr<TimingDeltas>(new TimingDeltas);
 }
 
 PersistentSAPCollider::~PersistentSAPCollider()
@@ -38,6 +40,8 @@
 	rootBody=ncb;
 	shared_ptr<BodyContainer> bodies=ncb->bodies;
 	transientInteractions=ncb->transientInteractions;
+
+//	timingDeltas->start();
 	
 	if (2*bodies->size()!=xBounds.size()){
 		xBounds.resize(2*bodies->size());
@@ -47,6 +51,8 @@
 		maxima.resize(3*bodies->size());
 	}
 
+//	timingDeltas->checkpoint("resizeArrays");
+
 	// Updates the minima and maxima arrays according to the new center and radius of the spheres
 	int offset;
 	Vector3r min,max;
@@ -70,6 +76,9 @@
 			maxima[offset+0]=pos[0]; maxima[offset+1]=pos[1]; maxima[offset+2]=pos[2];
 		}
 	}
+
+//	timingDeltas->checkpoint("minMaxUpdate");
+
 	typedef pair<body_id_t,body_id_t> bodyIdPair;
 	list<bodyIdPair> toBeDeleted;
 	FOREACH(const shared_ptr<Interaction>& I,*ncb->transientInteractions){
@@ -87,8 +96,13 @@
 		//if(!I->isReal){LOG_DEBUG("Interaction #"<<I->getId1()<<"=#"<<I->getId2()<<" is not real.");}
 	}
 	FOREACH(const bodyIdPair& p, toBeDeleted){ transientInteractions->erase(p.first,p.second); }
+
+//	timingDeltas->checkpoint("deleteInvalid");
 	
 	updateIds(bodies->size());
+
+//	timingDeltas->checkpoint("updateIds");
+
 	nbObjects=bodies->size();
 
 	// permutation sort of the AABBBounds along the 3 axis performed in a independant manner
@@ -101,6 +115,8 @@
 	//#pragma omp section
 		sortBounds(zBounds, nbObjects);
 	}
+
+//	timingDeltas->checkpoint("sortBounds");
 }
 
 bool PersistentSAPCollider::probeBoundingVolume(const BoundingVolume& bv)
@@ -132,6 +148,8 @@
 		int begin=0, end=nbElements;
 		if (nbElements>nbObjects) begin=nbObjects;
 
+		//timingDeltas->start();
+
 		// initialization if the xBounds, yBounds, zBounds
 		for(int i=begin;i<end;i++){
 			xBounds[2*i]	= shared_ptr<AABBBound>(new AABBBound(i,1));
@@ -142,6 +160,8 @@
 			zBounds[2*i+1]	= shared_ptr<AABBBound>(new AABBBound(i,0));
 		}
 
+		//timingDeltas->checkpoint("init");
+
 		// initialization if the field "value" of the xBounds, yBounds, zBounds arrays
 		updateBounds(nbElements);
 
@@ -149,16 +169,22 @@
 		// The first time these arrays are not sorted so it is faster to use such a sort instead
 		// of the permutation we are going to use next
 		std::sort(xBounds.begin(),xBounds.begin()+2*nbElements,AABBBoundComparator());
+		//timingDeltas->checkpoint("sortX");
 		std::sort(yBounds.begin(),yBounds.begin()+2*nbElements,AABBBoundComparator());
+		//timingDeltas->checkpoint("sortY");
 		std::sort(zBounds.begin(),zBounds.begin()+2*nbElements,AABBBoundComparator());
+		//timingDeltas->checkpoint("sortZ");
 
 		// initialize the overlappingBB collection
 		//for(unsigned int j=0;j<nbElements;j++)
 		//	overlappingBB[j].clear(); //attention memoire
 
 		findOverlappingBB(xBounds, nbElements);
+		//timingDeltas->checkpoint("findX");
 		findOverlappingBB(yBounds, nbElements);
+		//timingDeltas->checkpoint("findY");
 		findOverlappingBB(zBounds, nbElements);
+		//timingDeltas->checkpoint("findZ");
 	}
 	else updateBounds(nbElements);
 }