← Back to team overview

yade-dev team mailing list archive

[svn] r1474 - eudoxos

 

------------------------------------------------------------------------
r1474 | eudoxos | 2008-08-19 13:19:34 +0200 (wto, 19 sie 2008) | 2 lines
Changed paths:
   M /trunk/SConstruct
   M /trunk/extra/Brefcom.cpp
   M /trunk/extra/Brefcom.hpp

1. Kill building threads if the master thread is interruped in multi-builds (profile=a,b)

------------------------------------------------------------------------
Index: extra/Brefcom.hpp
===================================================================
--- extra/Brefcom.hpp	(revision 1473)
+++ extra/Brefcom.hpp	(revision 1474)
@@ -32,6 +32,7 @@
 		virtual void action(MetaBody* rb){compute(rb,useMaxForce);}
 		BrefcomGlobalCharacteristics(){};
 	void registerAttributes(){ PeriodicEngine::registerAttributes(); REGISTER_ATTRIBUTE(unbalancedForce); REGISTER_ATTRIBUTE(useMaxForce);}
+	DECLARE_LOGGER;
 	REGISTER_CLASS_NAME(BrefcomGlobalCharacteristics);
 	REGISTER_BASE_CLASS_NAME(PeriodicEngine);
 };
@@ -145,7 +146,7 @@
 		//! number of contacts with this body
 		int numContacts;
 		BrefcomPhysParams(): epsVolumetric(0.), numBrokenCohesive(0), numContacts(0) {createIndex();};
-		virtual void registerAttributes(){BodyMacroParameters::registerAttributes(); REGISTER_ATTRIBUTE(epsVolumetric); REGISTER_ATTRIBUTE(numBrokenCohesive);}
+		virtual void registerAttributes(){BodyMacroParameters::registerAttributes(); REGISTER_ATTRIBUTE(epsVolumetric); REGISTER_ATTRIBUTE(numBrokenCohesive); REGISTER_ATTRIBUTE(numContacts); }
 		REGISTER_CLASS_NAME(BrefcomPhysParams);
 		REGISTER_BASE_CLASS_NAME(BodyMacroParameters);
 };
Index: extra/Brefcom.cpp
===================================================================
--- extra/Brefcom.cpp	(revision 1473)
+++ extra/Brefcom.cpp	(revision 1474)
@@ -8,6 +8,8 @@
 
 YADE_PLUGIN("BrefcomMakeContact","BrefcomContact","BrefcomLaw","GLDrawBrefcomContact","BrefcomDamageColorizer", "BrefcomPhysParams", "BrefcomGlobalCharacteristics" /* ,"BrefcomStiffnessComputer"*/ );
 
+CREATE_LOGGER(BrefcomGlobalCharacteristics);
+
 void BrefcomGlobalCharacteristics::compute(MetaBody* rb, bool useMaxForce){
 	Shop::Bex::initCache();
 
@@ -15,7 +17,7 @@
 	// 2. get maximum force on a body and sum of all forces (for averaging)
 	Real sumF=0,maxF=0,currF;
 	FOREACH(const shared_ptr<Body>& b, *rb->bodies){
-		BrefcomPhysParams* bpp(YADE_CAST<BrefcomPhysParams*>(b->physicalParameters.get()));
+	BrefcomPhysParams* bpp(YADE_CAST<BrefcomPhysParams*>(b->physicalParameters.get()));
 		bpp->epsVolumetric=0;
 		bpp->numContacts=0;
 		currF=Shop::Bex::force(b->id,rb).Length(); maxF=max(currF,maxF); sumF+=currF;
@@ -41,8 +43,10 @@
 		shared_ptr<BrefcomContact> BC=YADE_PTR_CAST<BrefcomContact>(I->interactionPhysics); assert(BC);
 		BrefcomPhysParams* bpp1(YADE_CAST<BrefcomPhysParams*>(Body::byId(I->getId1())->physicalParameters.get()));
 		BrefcomPhysParams* bpp2(YADE_CAST<BrefcomPhysParams*>(Body::byId(I->getId2())->physicalParameters.get()));
-		Real epsVolAvg=.5*((3/bpp1->numContacts)*bpp1->epsVolumetric+(3/bpp2->numContacts)*bpp2->epsVolumetric);
+		Real epsVolAvg=.5*((3./bpp1->numContacts)*bpp1->epsVolumetric+(3./bpp2->numContacts)*bpp2->epsVolumetric);
 		BC->epsTrans=(epsVolAvg-BC->epsN)/2.;
+		//TRVAR5(I->getId1(),I->getId2(),BC->epsTrans,(3./bpp1->numContacts)*bpp1->epsVolumetric,(3./bpp2->numContacts)*bpp2->epsVolumetric);
+		//TRVAR4(bpp1->numContacts,bpp1->epsVolumetric,bpp2->numContacts,bpp2->epsVolumetric);
 	}
 	#if 0
 		FOREACH(const shared_ptr<Body>& b, *rb->bodies){
Index: SConstruct
===================================================================
--- SConstruct	(revision 1473)
+++ SConstruct	(revision 1474)
@@ -87,6 +87,11 @@
 		t=threading.Thread(target=runProfile,name='profile_'+p,args=(p,))
 		t.start()
 		profileThreads.append(t)
+	import atexit
+	def killAllProfileThreads():
+		for t in profileThreads:
+			t.join(0.1)
+	atexit.register(killAllProfileThreads)
 	for t in profileThreads:
 		t.join()
 	Exit()