← Back to team overview

yade-dev team mailing list archive

[svn] r1511 - in trunk: core gui/py

 

Author: eudoxos
Date: 2008-09-07 14:47:01 +0200 (Sun, 07 Sep 2008)
New Revision: 1511

Modified:
   trunk/core/Body.hpp
   trunk/core/Interaction.hpp
   trunk/core/NullGUI.cpp
   trunk/core/yade.cpp
   trunk/gui/py/_utils.cpp
   trunk/gui/py/eudoxos.py
Log:
1. poisson and young estimator now works on a fractional part of the speciment
2. do not switch ui automatically if selected explcitly
3. body::maskOK to check mask


Modified: trunk/core/Body.hpp
===================================================================
--- trunk/core/Body.hpp	2008-09-05 14:37:29 UTC (rev 1510)
+++ trunk/core/Body.hpp	2008-09-07 12:47:01 UTC (rev 1511)
@@ -61,9 +61,8 @@
 
 		body_id_t getId() const {return id;};
 
-		// FIXME - but we SHOULDN'T use them in InteractionSolver, because it allows
-		//         to have flat simulation. We should make tree simulation and see...
 		int getGroupMask() {return groupMask; };
+		bool maskOk(int mask){return (mask==0 || (groupMask&mask));}
 
 		// only BodyContainer can set the id of a body
 		friend class BodyContainer;

Modified: trunk/core/Interaction.hpp
===================================================================
--- trunk/core/Interaction.hpp	2008-09-05 14:37:29 UTC (rev 1510)
+++ trunk/core/Interaction.hpp	2008-09-07 12:47:01 UTC (rev 1511)
@@ -33,6 +33,13 @@
 		body_id_t getId1() {return id1;};
 		body_id_t getId2() {return id2;};
 
+		#if 0
+			//! Whether both bodies involved in interaction satisfies given mask; provide rootBody for faster lookup
+			bool maskBothOK(int mask, MetaBody* rootBody=NULL){return (mask==0) || (Body::byId(id1,rootBody)->maskOK(mask) && Body::byId(id2,rootBody)->maskOK(mask));}
+			//! Whether at least one body in interaction satisfies given mask; provide rootBody for faster lookup
+			bool maskAnyOK(int mask, MetaBody* rootBody=NULL){return (mask==0) || Body::byId(id1,rootBody)->maskOK(mask) || Body::byId(id2,rootBody)->maskOK(mask);}
+		#endif
+
 	protected :
 		void registerAttributes();
 	REGISTER_CLASS_NAME(Interaction);

Modified: trunk/core/NullGUI.cpp
===================================================================
--- trunk/core/NullGUI.cpp	2008-09-05 14:37:29 UTC (rev 1510)
+++ trunk/core/NullGUI.cpp	2008-09-07 12:47:01 UTC (rev 1511)
@@ -114,7 +114,7 @@
 	} 
 	else // FileGenerator
 	{
-		for(unsigned int i=0; i<inputFiles.size() ; ++i)
+		for(size_t i=0; i<inputFiles.size() ; ++i)
 		{
 			std::cerr << "filegenerator: \"" << inputFiles[i] << "\"";
 			file=inputFiles[i];

Modified: trunk/core/yade.cpp
===================================================================
--- trunk/core/yade.cpp	2008-09-05 14:37:29 UTC (rev 1510)
+++ trunk/core/yade.cpp	2008-09-07 12:47:01 UTC (rev 1511)
@@ -145,12 +145,12 @@
 
 	string configPath=string(getenv("HOME")) + "/.yade" SUFFIX; // this is the default, may be overridden by -c / -C
 	
-	int ch; string gui=""; string simulationFileName=""; bool setup=false; int verbose=0; bool coreOptions=true;
+	int ch; string gui=""; string simulationFileName=""; bool setup=false; int verbose=0; bool coreOptions=true; bool explicitUI=false;
 	while(coreOptions && (ch=getopt(argc,argv,"hnN:wC:cvS:"))!=-1)
 		switch(ch){
 			case 'h': printHelp(); return 1;
-			case 'n': gui="NullGUI"; break;
-			case 'N': gui=optarg; break;
+			case 'n': gui="NullGUI"; explicitUI=true; break;
+			case 'N': gui=optarg; explicitUI=true; break;
 			case 'w': setup=true; break;
 			case 'C': configPath=optarg; break;
 			case 'c': configPath="."; break;
@@ -242,7 +242,7 @@
 	}
 
 	if(gui.size()==0) gui=Omega::instance().preferences->defaultGUILibName;
-	if(gui=="PythonUI" && !getenv("TERM")){ LOG_WARN("No $TERM, using QtGUI instead of PythonUI"); gui="QtGUI"; }
+	if(!explicitUI && gui=="PythonUI" && !getenv("TERM")){ LOG_WARN("No $TERM, using QtGUI instead of PythonUI"); gui="QtGUI"; }
 	if(gui=="QtGUI" && !getenv("DISPLAY")){ LOG_WARN("No $DISPLAY, using PythonUI instead of QtUI"); gui="PythonUI"; }
 		
 	shared_ptr<FrontEnd> frontEnd = dynamic_pointer_cast<FrontEnd>(ClassFactory::instance().createShared(gui));

Modified: trunk/gui/py/_utils.cpp
===================================================================
--- trunk/gui/py/_utils.cpp	2008-09-05 14:37:29 UTC (rev 1510)
+++ trunk/gui/py/_utils.cpp	2008-09-07 12:47:01 UTC (rev 1511)
@@ -7,7 +7,9 @@
 #include<cmath>
 using namespace boost::python;
 
-python::tuple vec2tuple(const Vector3r& v){return boost::python::make_tuple(v[0],v[1],v[2]);};
+python::tuple vec2tuple(const Vector3r& v){return boost::python::make_tuple(v[0],v[1],v[2]);}
+Vector3r tuple2vec(const python::tuple& t){return Vector3r(extract<double>(t[0])(),extract<double>(t[1])(),extract<double>(t[2])());}
+bool isInBB(Vector3r p, Vector3r bbMin, Vector3r bbMax){return p[0]>bbMin[0] && p[0]<bbMax[0] && p[1]>bbMin[1] && p[1]<bbMax[1] && p[2]>bbMin[2] && p[2]<bbMax[2];}
 
 /* \todo implement groupMask */
 python::tuple aabbExtrema(){
@@ -35,14 +37,18 @@
 }
 BOOST_PYTHON_FUNCTION_OVERLOADS(negPosExtremeIds_overloads,negPosExtremeIds,1,2);
 
-python::tuple coordsAndDisplacements(int axis){
+python::tuple coordsAndDisplacements(int axis,python::tuple AABB=python::tuple()){
+	Vector3r bbMin,bbMax; bool useBB=python::len(AABB)>0;
+	if(useBB){bbMin=tuple2vec(extract<python::tuple>(AABB[0])());bbMax=tuple2vec(extract<python::tuple>(AABB[1])());}
 	python::list retCoord,retDispl;
 	FOREACH(const shared_ptr<Body>&b, *Omega::instance().getRootBody()->bodies){
+		if(useBB && !isInBB(b->physicalParameters->se3.position,bbMin,bbMax)) continue;
 		retCoord.append(b->physicalParameters->se3.position[axis]);
 		retDispl.append(b->physicalParameters->se3.position[axis]-b->physicalParameters->refSe3.position[axis]);
 	}
 	return python::make_tuple(retCoord,retDispl);
 }
+BOOST_PYTHON_FUNCTION_OVERLOADS(coordsAndDisplacements_overloads,coordsAndDisplacements,1,2);
 
 void setRefSe3(){
 	FOREACH(const shared_ptr<Body>& b, *Omega::instance().getRootBody()->bodies){
@@ -90,7 +96,7 @@
 	def("PWaveTimeStep",PWaveTimeStep);
 	def("aabbExtrema",aabbExtrema);
 	def("negPosExtremeIds",negPosExtremeIds,negPosExtremeIds_overloads(args("axis","distFactor")));
-	def("coordsAndDisplacements",coordsAndDisplacements);
+	def("coordsAndDisplacements",coordsAndDisplacements,coordsAndDisplacements_overloads(args("AABB")));
 	def("setRefSe3",setRefSe3);
 	def("interactionAnglesHistogram",interactionAnglesHistogram,interactionAnglesHistogram_overloads(args("axis","mask","bins")));
 }

Modified: trunk/gui/py/eudoxos.py
===================================================================
--- trunk/gui/py/eudoxos.py	2008-09-05 14:37:29 UTC (rev 1510)
+++ trunk/gui/py/eudoxos.py	2008-09-07 12:47:01 UTC (rev 1511)
@@ -16,7 +16,7 @@
 		bar(d[0],d[1],width=math.pi/(1.2*bins),fc=fc,alpha=.7,label=['yz','xz','xy'][axis])
 	pylab.show()
 
-def estimatePoissonYoung(principalAxis,stress=0,plot=False):
+def estimatePoissonYoung(principalAxis,stress=0,plot=False,keepRatio=1.):
 	"""Estimate Poisson's ration given the "principal" axis of straining.
 	For every base direction, homogenized strain is computed
 	(slope in linear regression on discrete function particle coordinate →
@@ -26,12 +26,20 @@
 
 	Young's modulus is computed as σ/ε₀; if stress σ is not given (default 0),
 	the result is 0.
+
+	keepRatio, if < 1., will take only smaller part (centered) or the specimen into account
 	"""
 	dd=[] # storage for linear regression parameters
 	import pylab,numpy,stats
 	from yade import utils
+	if keepRatio<1.:
+		aabb=utils.aabbExtrema(); half=[.5*(aabb[1][i]-aabb[0][i]) for i in [0,1,2]]
+		cut=(tuple([aabb[0][i]+(1.-keepRatio)*half[i] for i in [0,1,2]]),tuple([aabb[1][i]-(1.-keepRatio)*half[i] for i in [0,1,2]]))
 	for axis in [0,1,2]:
-		w,dw=utils.coordsAndDisplacements(axis)
+		if keepRatio<1.:
+			w,dw=utils.coordsAndDisplacements(axis,AABB=cut)
+		else:
+			w,dw=utils.coordsAndDisplacements(axis)
 		l,ll=stats.linregress(w,dw)[0:2] # use only tangent and section
 		dd.append((l,ll,min(w),max(w)))
 		if plot: pylab.plot(w,dw,'.',label='xyz'[axis])
@@ -67,7 +75,7 @@
 
 	ph=o.interactions.nth(0).phys # some params are the same everywhere
 	material.append("%g %g"%(ph['E'],ph['G']))
-	material.append("%g %g %g %g"%(ph['epsCrackOnset'],ph['epsFracture'],ph['expBending'],ph['xiShear']))
+	material.append("%g %g %g %g"%(ph['epsCrackOnset'],ph['epsFracture'],1e50,ph['xiShear']))
 	material.append("%g %g"%(ph['undamagedCohesion'],ph['tanFrictionAngle']))
 
 	# need strainer for getting bodies in positive/negative boundary