← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3551: Add of sphSph parameter in plotDirections() to take into account only sph-sph interactions in pol...

 

------------------------------------------------------------
revno: 3551
committer: jduriez <jerome.duriez@xxxxxxxxxxx>
timestamp: Mon 2014-12-01 11:29:59 -0700
message:
  Add of sphSph parameter in plotDirections() to take into account only sph-sph interactions in polar histograms. Seems it does not modify really the plots, but it is easier to figure out with the parameter
modified:
  py/_utils.cpp
  py/_utils.hpp
  py/utils.py


--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'py/_utils.cpp'
--- py/_utils.cpp	2014-10-15 06:44:01 +0000
+++ py/_utils.cpp	2014-12-01 18:29:59 +0000
@@ -40,7 +40,7 @@
 Real PWaveTimeStep(){return Shop::PWaveTimeStep();};
 Real RayleighWaveTimeStep(){return Shop::RayleighWaveTimeStep();};
 
-py::tuple interactionAnglesHistogram(int axis, int mask, size_t bins, py::tuple aabb, Real minProjLen){
+py::tuple interactionAnglesHistogram(int axis, int mask, size_t bins, py::tuple aabb, bool sphSph, Real minProjLen){
 	if(axis<0||axis>2) throw invalid_argument("Axis must be from {0,1,2}=x,y,z.");
 	Vector3r bbMin(Vector3r::Zero()), bbMax(Vector3r::Zero()); bool useBB=py::len(aabb)>0; if(useBB){bbMin=py::extract<Vector3r>(aabb[0])();bbMax=py::extract<Vector3r>(aabb[1])();}
 	Real binStep=Mathr::PI/bins; int axis2=(axis+1)%3, axis3=(axis+2)%3;
@@ -51,6 +51,7 @@
 		const shared_ptr<Body>& b1=Body::byId(i->getId1(),rb), b2=Body::byId(i->getId2(),rb);
 		if(!b1->maskOk(mask) || !b2->maskOk(mask)) continue;
 		if(useBB && !isInBB(b1->state->pos,bbMin,bbMax) && !isInBB(b2->state->pos,bbMin,bbMax)) continue;
+		if (sphSph && ( !dynamic_cast<Sphere*>(b1->shape.get()) || !dynamic_cast<Sphere*>(b2->shape.get()) ) ) continue;
 		GenericSpheresContact* geom=dynamic_cast<GenericSpheresContact*>(i->geom.get());
 		if(!geom) continue;
 		Vector3r n(geom->normal); n[axis]=0.; Real nLen=n.norm();
@@ -427,7 +428,7 @@
 	py::def("approxSectionArea",approxSectionArea,"Compute area of convex hull when when taking (swept) spheres crossing the plane at coord, perpendicular to axis.");
 	py::def("coordsAndDisplacements",coordsAndDisplacements,(py::arg("axis"),py::arg("Aabb")=py::tuple()),"Return tuple of 2 same-length lists for coordinates and displacements (coordinate minus reference coordinate) along given axis (1st arg); if the Aabb=((x_min,y_min,z_min),(x_max,y_max,z_max)) box is given, only bodies within this box will be considered.");
 	py::def("setRefSe3",setRefSe3,"Set reference :yref:`positions<State::refPos>` and :yref:`orientations<State::refOri>` of all :yref:`bodies<Body>` equal to their current :yref:`positions<State::pos>` and :yref:`orientations<State::ori>`.");
-	py::def("interactionAnglesHistogram",interactionAnglesHistogram,interactionAnglesHistogram_overloads(py::args("axis","mask","bins","aabb")));
+	py::def("interactionAnglesHistogram",interactionAnglesHistogram,interactionAnglesHistogram_overloads(py::args("axis","mask","bins","aabb","sphSph")));
 	py::def("bodyNumInteractionsHistogram",bodyNumInteractionsHistogram,bodyNumInteractionsHistogram_overloads(py::args("aabb")));
 // 	py::def("elasticEnergy",elasticEnergyInAABB);
 	py::def("inscribedCircleCenter",inscribedCircleCenter,(py::arg("v1"),py::arg("v2"),py::arg("v3")),"Return center of inscribed circle for triangle given by its vertices *v1*, *v2*, *v3*.");

=== modified file 'py/_utils.hpp'
--- py/_utils.hpp	2014-10-15 06:44:01 +0000
+++ py/_utils.hpp	2014-12-01 18:29:59 +0000
@@ -28,8 +28,8 @@
 Real PWaveTimeStep();
 Real RayleighWaveTimeStep();
 
-py::tuple interactionAnglesHistogram(int axis, int mask=0, size_t bins=20, py::tuple aabb=py::tuple(), Real minProjLen=1e-6);
-BOOST_PYTHON_FUNCTION_OVERLOADS(interactionAnglesHistogram_overloads,interactionAnglesHistogram,1,4);
+py::tuple interactionAnglesHistogram(int axis, int mask=0, size_t bins=20, py::tuple aabb=py::tuple(), bool sphSph=0, Real minProjLen=1e-6);
+BOOST_PYTHON_FUNCTION_OVERLOADS(interactionAnglesHistogram_overloads,interactionAnglesHistogram,1,5);
 
 py::tuple bodyNumInteractionsHistogram(py::tuple aabb=py::tuple());
 BOOST_PYTHON_FUNCTION_OVERLOADS(bodyNumInteractionsHistogram_overloads,bodyNumInteractionsHistogram,0,1);

=== modified file 'py/utils.py'
--- py/utils.py	2014-10-22 10:13:18 +0000
+++ py/utils.py	2014-12-01 18:29:59 +0000
@@ -534,16 +534,16 @@
 	pylab.ion()
 	pylab.show()
 
-def plotDirections(aabb=(),mask=0,bins=20,numHist=True,noShow=False):
+def plotDirections(aabb=(),mask=0,bins=20,numHist=True,noShow=False,sphSph=False):
 	"""Plot 3 histograms for distribution of interaction directions, in yz,xz and xy planes and
-	(optional but default) histogram of number of interactions per body.
+	(optional but default) histogram of number of interactions per body. If sphSph only sphere-sphere interactions are considered.
 
 	:returns: If *noShow* is ``False``, displays the figure and returns nothing. If *noShow*, the figure object is returned without being displayed (works the same way as :yref:`yade.plot.plot`).
 	"""
 	import pylab,math
 	from yade import utils
 	for axis in [0,1,2]:
-		d=utils.interactionAnglesHistogram(axis,mask=mask,bins=bins,aabb=aabb)
+		d=utils.interactionAnglesHistogram(axis,mask=mask,bins=bins,aabb=aabb,sphSph=sphSph)
 		fc=[0,0,0]; fc[axis]=1.
 		subp=pylab.subplot(220+axis+1,polar=True);
 		# 1.1 makes small gaps between values (but the column is a bit decentered)