← Back to team overview

yade-dev team mailing list archive

[svn] r1458 - eudoxos

 

------------------------------------------------------------------------
r1458 | eudoxos | 2008-08-11 09:35:29 +0200 (pon, 11 sie 2008) | 3 lines
Changed paths:
   M /trunk/extra/Brefcom.cpp
   M /trunk/extra/Brefcom.hpp
   M /trunk/extra/usct/UniaxialStrainControlledTest.cpp
   M /trunk/gui/qt3/QtGUI-python.cpp
   M /trunk/gui/qt3/YadeQtMainWindow.hpp

1. Fix USCTGen so that it works within default-test.py
2. Minor fixes as usual.

------------------------------------------------------------------------
Index: extra/Brefcom.hpp
===================================================================
--- extra/Brefcom.hpp	(revision 1457)
+++ extra/Brefcom.hpp	(revision 1458)
@@ -72,9 +72,13 @@
 			//! characteristic time (if non-positive, the law without rate-dependence is used)
 			tau,
 			//! exponent in the rate-dependent damage evolution
-			expDmgRate;
+			expDmgRate,
+			//! coefficient that takes transversal strain into accound when calculating kappaDReduced
+			transStrainCoeff;
 		/*! Up to now maximum normal strain (semi-norm), non-decreasing in time. */
 		Real kappaD;
+		/*! Transversal strain (perpendicular to the contact axis) */
+		Real epsTrans;
 		/*! prevNormal is oriented A→B (as in SpheresContactGeometry); */
 		Vector3r prevNormal;
 		/*! previous tangential (shear) strain */
@@ -105,11 +109,13 @@
 			REGISTER_ATTRIBUTE(xiShear);
 			REGISTER_ATTRIBUTE(tau);
 			REGISTER_ATTRIBUTE(expDmgRate);
+			REGISTER_ATTRIBUTE(transStrainCoeff);
 
 			REGISTER_ATTRIBUTE(kappaD);
 			REGISTER_ATTRIBUTE(neverDamage);
 			REGISTER_ATTRIBUTE(prevNormal);
 			REGISTER_ATTRIBUTE(epsT);
+			REGISTER_ATTRIBUTE(epsTrans);
 
 			REGISTER_ATTRIBUTE(isCohesive);
 
@@ -135,7 +141,9 @@
 		Real epsVolumetric;
 		//! number of (cohesive) contacts that damaged completely
 		int numBrokenCohesive;
-		BrefcomPhysParams(): epsVolumetric(0.), numBrokenCohesive(0){createIndex();};
+		//! 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);}
 		REGISTER_CLASS_NAME(BrefcomPhysParams);
 		REGISTER_BASE_CLASS_NAME(BodyMacroParameters);
@@ -227,7 +235,7 @@
 		expBending is positive if the damage evolution function is concave after fracture onset;
 		reasonable value seems like 4.
 		*/
-		Real sigmaT, expBending, xiShear, epsCrackOnset, relDuctility, G_over_E, tau, expDmgRate, omegaThreshold;
+		Real sigmaT, expBending, xiShear, epsCrackOnset, relDuctility, G_over_E, tau, expDmgRate, omegaThreshold, transStrainCoeff;
 		//! Should new contacts be cohesive? They will before this iter#, they will not be afterwards. If 0, they will never be. If negative, they will always be created as cohesive.
 		long cohesiveThresholdIter;
 		//! Create contacts that don't receive any damage (BrefcomContact::neverDamage=true); defaults to false
@@ -235,7 +243,7 @@
 
 		BrefcomMakeContact(){
 			// init to signaling_NaN to force crash if not initialized (better than unknowingly using garbage values)
-			sigmaT=xiShear=epsCrackOnset=relDuctility=G_over_E=std::numeric_limits<Real>::signaling_NaN();
+			sigmaT=xiShear=epsCrackOnset=relDuctility=G_over_E=transStrainCoeff=std::numeric_limits<Real>::signaling_NaN();
 			neverDamage=false;
 			cohesiveThresholdIter=-1;
 			tau=-1; expDmgRate=0;
@@ -257,6 +265,7 @@
 			REGISTER_ATTRIBUTE(tau);
 			REGISTER_ATTRIBUTE(expDmgRate);
 			REGISTER_ATTRIBUTE(omegaThreshold);
+			REGISTER_ATTRIBUTE(transStrainCoeff);
 			//REGISTER_ATTRIBUTE(calibratedEpsFracture);
 			/* REGISTER_ATTRIBUTE(Gf); */
 		}
Index: extra/Brefcom.cpp
===================================================================
--- extra/Brefcom.cpp	(revision 1457)
+++ extra/Brefcom.cpp	(revision 1458)
@@ -15,7 +15,9 @@
 	// 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){
-		YADE_PTR_CAST<BrefcomPhysParams>(b->physicalParameters)->epsVolumetric=0;
+		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;
 	}
 	Real meanF=sumF/rb->bodies->size(); 
@@ -27,10 +29,29 @@
 		if(!I->isReal) continue;
 		shared_ptr<BrefcomContact> BC=YADE_PTR_CAST<BrefcomContact>(I->interactionPhysics); assert(BC);
 		maxContactF=max(maxContactF,max(BC->Fn,BC->Fs.Length()));
-		YADE_PTR_CAST<BrefcomPhysParams>(Body::byId(I->getId1(),rb)->physicalParameters)->epsVolumetric+=BC->epsN;
-		YADE_PTR_CAST<BrefcomPhysParams>(Body::byId(I->getId2(),rb)->physicalParameters)->epsVolumetric+=BC->epsN;
+		BrefcomPhysParams* bpp1(YADE_CAST<BrefcomPhysParams*>(Body::byId(I->getId1())->physicalParameters.get()));
+		BrefcomPhysParams* bpp2(YADE_CAST<BrefcomPhysParams*>(Body::byId(I->getId2())->physicalParameters.get()));
+		bpp1->epsVolumetric+=BC->epsN; bpp1->numContacts+=1;
+		bpp2->epsVolumetric+=BC->epsN; bpp2->numContacts+=1;
 	}
 	unbalancedForce=(useMaxForce?maxF:meanF)/maxContactF;
+
+	FOREACH(const shared_ptr<Interaction>& I, *rb->transientInteractions){
+		if(!I->isReal) continue;
+		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);
+		BC->epsTrans=(epsVolAvg-BC->epsN)/2.;
+	}
+	#if 0
+		FOREACH(const shared_ptr<Body>& b, *rb->bodies){
+			BrefcomPhysParams* bpp(YADE_PTR_CAST<BrefcomPhysParams>(b->physicalParameters.get()));
+			bpp->epsVolumeric*=3/bpp->numContacts;
+		}
+	#endif
+
+
 }
 
 
@@ -74,6 +95,7 @@
 		contPhys->epsFracture=relDuctility*epsCrackOnset;
 		contPhys->xiShear=xiShear;
 		contPhys->omegaThreshold=omegaThreshold;
+		contPhys->transStrainCoeff=transStrainCoeff;
 
 		contPhys->prevNormal=contGeom->normal;
 		if(neverDamage) contPhys->neverDamage=true;
@@ -141,7 +163,7 @@
 		#endif
 
 		// shorthands
-		Real& epsN(BC->epsN); Vector3r& epsT(BC->epsT); Real& kappaD(BC->kappaD); const Real& equilibriumDist(BC->equilibriumDist); const Real& xiShear(BC->xiShear); const Real& E(BC->E); const Real& undamagedCohesion(BC->undamagedCohesion); const Real& tanFrictionAngle(BC->tanFrictionAngle); const Real& G(BC->G); const Real& crossSection(BC->crossSection); const Real& tau(BC->tau); const Real& expDmgRate(BC->expDmgRate); const Real& omegaThreshold(BC->omegaThreshold);
+		Real& epsN(BC->epsN); Vector3r& epsT(BC->epsT); Real& kappaD(BC->kappaD); const Real& equilibriumDist(BC->equilibriumDist); const Real& xiShear(BC->xiShear); const Real& E(BC->E); const Real& undamagedCohesion(BC->undamagedCohesion); const Real& tanFrictionAngle(BC->tanFrictionAngle); const Real& G(BC->G); const Real& crossSection(BC->crossSection); const Real& tau(BC->tau); const Real& expDmgRate(BC->expDmgRate); const Real& omegaThreshold(BC->omegaThreshold); const Real& transStrainCoeff(BC->transStrainCoeff); const Real& epsTrans(BC->epsTrans); const Real& epsCrackOnset(BC->epsCrackOnset);
 		// for python access
 		Real& omega(BC->omega); Real& sigmaN(BC->sigmaN);  Vector3r& sigmaT(BC->sigmaT); Real& Fn(BC->Fn); Vector3r& Fs(BC->Fs);
 
@@ -166,7 +188,7 @@
 
 		// /* TODO: recover non-cohesive contact deletion: */
 		if(!BC->isCohesive && epsN>0.){ /* delete this interaction later */ I->isReal=false; continue; }
-		#define BREFCOM_DETAIL
+		//#define BREFCOM_DETAIL
 		#ifdef BREFCOM_DETAIL
 			LOG_TRACE("======= iteration #"<<Omega::instance().getCurrentIteration()<<", interaction "<<id1<<" + "<<id2<<"=======");
 		#endif
Index: extra/usct/UniaxialStrainControlledTest.cpp
===================================================================
--- extra/usct/UniaxialStrainControlledTest.cpp	(revision 1457)
+++ extra/usct/UniaxialStrainControlledTest.cpp	(revision 1458)
@@ -239,13 +239,24 @@
 	}
 	else spheres=Shop::loadSpheresFromFile(spheresFile,minXYZ,maxXYZ);
 
+
 	TRVAR2(minXYZ,maxXYZ);
 	// get spheres that are "close enough" to the strained ends
 	for(vecVecReal::iterator I=spheres.begin(); I!=spheres.end(); I++){
 		Vector3r C=I->first;
 		Real r=I->second;
 		shared_ptr<Body> S=Shop::sphere(C,r);
+
+		// replace BodyMacroParameters by BrefcomPhysParams
+		shared_ptr<BodyMacroParameters> bmp=YADE_PTR_CAST<BodyMacroParameters>(S->physicalParameters);
+		shared_ptr<BrefcomPhysParams> bpp(new BrefcomPhysParams);
+		#define _CP(attr) bpp->attr=bmp->attr;
+		_CP(acceleration); _CP(angularVelocity); _CP(blockedDOFs); _CP(frictionAngle); _CP(inertia); _CP(mass); _CP(poisson); _CP(refSe3); _CP(se3); _CP(young); _CP(velocity);
+		#undef _CP
+		S->physicalParameters=bpp;
+
 		body_id_t sId=rootBody->bodies->insert(S);
+
 		Real distFactor=1.2;
 		if (C[axis]-distFactor*r<minXYZ[axis]) {
 			strainer->negIds.push_back(sId);
@@ -328,7 +339,7 @@
 	shared_ptr<InteractionPhysicsMetaEngine> iphysDispatcher(new InteractionPhysicsMetaEngine);
 		shared_ptr<BrefcomMakeContact> bmc(new BrefcomMakeContact);
 		bmc->cohesiveThresholdIter=cohesiveThresholdIter;
-		bmc->cohesiveThresholdIter=-1; bmc->G_over_E=1; bmc->expBending=1; bmc->xiShear=.8; bmc->sigmaT=3e9; bmc->neverDamage=true; bmc->epsCrackOnset=1e-4; bmc->relDuctility=5;
+		bmc->cohesiveThresholdIter=-1; bmc->G_over_E=1; bmc->expBending=1; bmc->xiShear=.8; bmc->sigmaT=3e9; bmc->neverDamage=true; bmc->epsCrackOnset=1e-4; bmc->relDuctility=5; bmc->transStrainCoeff=.5;
 		iphysDispatcher->add(bmc);
 	rootBody->engines.push_back(iphysDispatcher);
 
Index: gui/qt3/QtGUI-python.cpp
===================================================================
--- gui/qt3/QtGUI-python.cpp	(revision 1457)
+++ gui/qt3/QtGUI-python.cpp	(revision 1458)
@@ -32,7 +32,6 @@
 POST_SYNTH_EVENT(GENERATOR,generator);
 // BOOST_PYTHON_FUNCTION_OVERLOADS(evtPLAYER_overloads,evtPLAYER,0,1); BOOST_PYTHON_FUNCTION_OVERLOADS(evtCONTROLLER_overloads,evtCONTROLLER,0,1); BOOST_PYTHON_FUNCTION_OVERLOADS(evtGENERATOR_overloads,evtGENERATOR,0,1);
 #undef POST_SYNT_EVENT
-void evtVIEW(){QApplication::postEvent(ensuredMainWindow(),new QCustomEvent(YadeQtMainWindow::EVENT_VIEW)); size_t origViewNo=ensuredMainWindow()->glViews.size(); while(ensuredMainWindow()->glViews.size()!=origViewNo+1) usleep(50000); }
 
 // event associated data will be deleted in the event handler
 void restoreGLViewerState_str(string str){string* s=new string(str); QApplication::postEvent(ensuredMainWindow(),new QCustomEvent((QEvent::Type)YadeQtMainWindow::EVENT_RESTORE_GLVIEWER_STR,(void*)s));}
@@ -137,11 +136,14 @@
 		void center(bool median=false){if(median)glv->centerMedianQuartile(); else glv->centerScene();}
 		python::tuple get_screenSize(){return python::make_tuple(glv->width(),glv->height());} void set_screenSize(python::tuple t){ vector<int>* ii=new(vector<int>); ii->push_back(ensuredMainWindow()->viewNo(glv)); ii->push_back(python::extract<int>(t[0])()); ii->push_back(python::extract<int>(t[1])()); QApplication::postEvent(ensuredMainWindow(),new QCustomEvent((QEvent::Type)YadeQtMainWindow::EVENT_RESIZE_VIEW,(void*)ii));}
 		string pyStr(){return string("<GLViewer for view #")+lexical_cast<string>(ensuredMainWindow()->viewNo(glv))+">";}
+		void saveDisplayParameters(size_t n){glv->saveDisplayParameters(n);}
+		void useDisplayParameters(size_t n){glv->useDisplayParameters(n);}
 };
-
 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(pyGLViewer_center_overloads,center,0,1);
 
 
+pyGLViewer evtVIEW(){QApplication::postEvent(ensuredMainWindow(),new QCustomEvent(YadeQtMainWindow::EVENT_VIEW)); size_t origViewNo=ensuredMainWindow()->glViews.size(); while(ensuredMainWindow()->glViews.size()!=origViewNo+1) usleep(50000); return pyGLViewer(*ensuredMainWindow()->glViews.rbegin());}
+
 python::list getAllViews(){
 	python::list ret;
 	for(size_t i=0; i<YadeQtMainWindow::self->glViews.size(); i++) ret.append(YadeQtMainWindow::self->glViews[i]);
@@ -180,6 +182,8 @@
 		.def("fitSphere",&pyGLViewer::fitSphere)
 		.def("showEntireScene",&pyGLViewer::showEntireScene)
 		.def("center",&pyGLViewer::center,pyGLViewer_center_overloads())
+		.def("saveState",&pyGLViewer::saveDisplayParameters)
+		.def("loadState",&pyGLViewer::useDisplayParameters)
 		.def("__repr__",&pyGLViewer::pyStr).def("__str__",&pyGLViewer::pyStr)
 		;
 }
Index: gui/qt3/YadeQtMainWindow.hpp
===================================================================
--- gui/qt3/YadeQtMainWindow.hpp	(revision 1457)
+++ gui/qt3/YadeQtMainWindow.hpp	(revision 1458)
@@ -57,7 +57,7 @@
 		enum{EVENT_CONTROLLER=QEvent::User+1,EVENT_PLAYER,EVENT_VIEW,EVENT_GENERATOR,EVENT_RESTORE_GLVIEWER_NUM,EVENT_RESTORE_GLVIEWER_STR,EVENT_RESTORE_VIEWER_FILE,EVENT_RESIZE_VIEW};
 		virtual void customEvent(QCustomEvent* e);
 		/* each of player, controller, generator have slots for them being opened and closed: create{Player,Controller,Generator} and the instances are kept in player, controller, generator. */
-		#define __MK_RM_CHILD(Child,child,YadeClass)  virtual void close##Child(){if(child)child=shared_ptr<YadeClass>();} virtual void create##Child(){if(!child){child=shared_ptr<YadeClass>(new YadeClass()); connect(child.get(),SIGNAL(closeSignal()),this,SLOT(close##Child())); child->show();} else {child->show(); child->raise();}}
+		#define __MK_RM_CHILD(Child,child,YadeClass)  virtual void close##Child(){if(child)child=shared_ptr<YadeClass>();} virtual void create##Child(){closeAllChilds(); if(!child){child=shared_ptr<YadeClass>(new YadeClass()); connect(child.get(),SIGNAL(closeSignal()),this,SLOT(close##Child())); child->show();} else {child->show(); child->raise();}}
 		__MK_RM_CHILD(Generator,generator,QtFileGenerator);
 		__MK_RM_CHILD(Player,player,QtSimulationPlayer);
 		__MK_RM_CHILD(Controller,controller,SimulationController);