[Yade-dev] [svn] r1638 - trunk/gui/py

2009-01-24 Thread eudoxos at BerliOS
Author: eudoxos
Date: 2009-01-24 11:40:10 +0100 (Sat, 24 Jan 2009)
New Revision: 1638

Modified:
   trunk/gui/py/utils.py
   trunk/gui/py/yade-multi
Log:
1. Number lines in parameter table for multijobs from 1 (as text editors do)
2. Print short summary at the end of job log (when started, when finished, exit 
status, duration, commandline)


Modified: trunk/gui/py/utils.py
===
--- trunk/gui/py/utils.py   2009-01-24 05:55:23 UTC (rev 1637)
+++ trunk/gui/py/utils.py   2009-01-24 10:40:10 UTC (rev 1638)
@@ -295,7 +295,7 @@
if not tableFileLine: tableFileLine=os.environ['PARAM_TABLE']
tableFile,tableLine=tableFileLine.split(':')
o.tags['line']='l'+tableLine
-   ll=[l.split('#')[0] for l in open(tableFile).readlines()]; 
names=ll[0].split(); values=ll[int(tableLine)].split()
+   ll=[l.split('#')[0] for l in ['']+open(tableFile).readlines()]; 
names=ll[1].split(); values=ll[int(tableLine)].split()
assert(len(names)==len(values))
for i in range(len(names)):
if names[i]=='description': 
o.tags['description']=values[i]

Modified: trunk/gui/py/yade-multi
===
--- trunk/gui/py/yade-multi 2009-01-24 05:55:23 UTC (rev 1637)
+++ trunk/gui/py/yade-multi 2009-01-24 10:40:10 UTC (rev 1638)
@@ -3,25 +3,44 @@
 #
 # portions © 2008 Václav Šmilauer eudo...@arcig.cz
 
+import os, sys, thread, time
 
+class JobInfo():
+   def __init__(self,num,id,command,log):
+   
self.started,self.finished,self.duration,self.exitStatus=None,None,None,None
+   self.command=command; self.num=num; self.log=log; self.id=id
+   def saveInfo(self):
+   log=file(self.log,'a')
+   log.write(
+=== JOB SUMMARY 
+id  : %s
+status  : %d (%s)
+duration: %s
+command : %s
+started : %s
+finished: %s
+%(self.id,self.exitStatus,'OK' if self.exitStatus==0 else 
'FAILED',self.duration,self.command,time.asctime(time.localtime(self.started)),time.asctime(time.localtime(self.finished;
+   log.close()
+
 #
 # _MANY_ thanks to Mark Pettit for concurrent jobs handling!
 # http://code.activestate.com/recipes/534160/
 #
 
-import os, sys, thread, time
 
 def __concurrent_batch(cmd,thread_num,completion_status_dict,exit_code_dict):
Helper routine for 'concurrent_batches.
-
-   t0=time.time()
+   job=jobs[thread_num]
+   job.started=time.time();
print '#%d started on %s'%(thread_num,time.asctime())
exit_code_dict[thread_num] = os.system(cmd)
completion_status_dict[thread_num] = 1  # for sum() routine
-   dt=int(time.time()-t0)
-   strDt='%02d:%02d:%02d'%(dt//3600,(dt%3600)//60,(dt%60))
-   strStatus='done   ' if exit_code_dict[thread_num]==0 else 'FAILED '
-   print #%d %s (exit status %d), duration 
%s%(thread_num,strStatus,exit_code_dict[thread_num],strDt)
+   job.finished=time.time(); dt=job.finished-job.started;
+   job.exitStatus=exit_code_dict[thread_num]
+   job.duration='%02d:%02d:%02d'%(dt//3600,(dt%3600)//60,(dt%60))
+   strStatus='done   ' if job.exitStatus==0 else 'FAILED '
+   print #%d %s (exit status %d), duration %s, log 
%s%(thread_num,strStatus,exit_code_dict[thread_num],job.duration,job.log)
+   job.saveInfo()
 
 def concurrent_batches(batchlist,maxjobs=0,maxtime=0):
Run a list of batch commands simultaneously.
@@ -104,8 +123,8 @@
 
 print Will run `%s' on `%s' with nice value %d, output redirected to `%s', %d 
jobs at a time.%(executable,simul,nice,logFormat,maxJobs)
 
-ll=open(table,'r').readlines()
-availableLines=[i for i in range(len(ll)) if not 
re.match(r'^\s*(#.*)?$',ll[i][:-1]) and i0]
+ll=['']+open(table,'r').readlines()
+availableLines=[i for i in range(len(ll)) if not 
re.match(r'^\s*(#.*)?$',ll[i][:-1]) and i1]
 
 print Will use table `%s', with available lines%(table),', '.join([str(i) 
for i in availableLines])+'.'
 
@@ -120,13 +139,13 @@
useLines0=numRange2List(lineList)
for l in useLines0:
if l not in availableLines: print WARNING: skipping 
unavailable line %d that was requested from the command line.%l
-   elif l==0: print WARNING: skipping line 0 that should contain 
variable labels
+   elif l==1: print WARNING: skipping line 1 that should contain 
variable labels
else: useLines+=[l]
 else: useLines=availableLines
 print Will use lines ,', '.join([str(i) for i in useLines])+'.'
 # find column where description is
 try:
-   idColumn=ll[0].split().index('description')
+   idColumn=ll[1].split().index('description')
idStrings={}
for i in useLines: idStrings[i]=ll[i].split()[idColumn] # textual 
descripion of respective lines 
print idStrings
@@ -135,14 +154,15 @@

[Yade-dev] [svn] r1639 - trunk/gui/qt3

2009-01-24 Thread eudoxos at BerliOS
Author: eudoxos
Date: 2009-01-24 18:33:01 +0100 (Sat, 24 Jan 2009)
New Revision: 1639

Modified:
   trunk/gui/qt3/QtGUI.cpp
Log:
1. Fix logic typo in QtGUI (warning when there shouldn't be and vice versa)


Modified: trunk/gui/qt3/QtGUI.cpp
===
--- trunk/gui/qt3/QtGUI.cpp 2009-01-24 10:40:10 UTC (rev 1638)
+++ trunk/gui/qt3/QtGUI.cpp 2009-01-24 17:33:01 UTC (rev 1639)
@@ -58,7 +58,7 @@
#ifdef EMBED_PYTHON
LOG_DEBUG(Adding script parameter `argv[index]' 
from the command line.);
PythonUI::scriptArgs.push_back(string(argv[index]));
-   if(!PythonUI::runScript.empty()) LOG_WARN(Got 
parameter `argv[index]', but no .py script to be run!);
+   if(PythonUI::runScript.empty()) LOG_WARN(Got parameter 
`argv[index]', but no .py script to be run!);
#else
LOG_ERROR(Unprocessed non-option argument: 
`argv[index]');
#endif


___
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


[Yade-dev] polyhedron collisions

2009-01-24 Thread Janek Kozicki
If anybody is interested, it turns out that I'm implementing snow
grains as deformable polyhedrons that can collide with each other.

This code can be extracted later for general polyhedron (made of
triangles) collisions.

Currently I have committed a code which can determine if any given 3D
point is inside a polyhedron made of triangular faces.

The snow grains are not clean polyhedrons and not convex. Sometimes
they have stupid faces nearly facing each other. I made the code to be
slower but correct, it was easier than cleaning all stupid faces (and
it still would remain concave). So it will work very good with
convex polyhedrons, and it will work acceptably with concave
polyhedrons.

When detecting collision I am going to iterate over all points from
one polyhedron checking if it is inside another polyhedron and
vice-versa. I'll have a list of polyhedron points that are inside of
each other. I'm going to assume that there is a plane of contact
which is somewhere in the middle of all those points. From that get a
penetration depth and normal of the contact, then it can go straight
to our CohseiveFrictionalContactLaw


And is much slower than spheres, so you can forget about simulations
with 5000 polyhedrons, anyway.

-- 
Janek Kozicki |

___
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