← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2888: Add utils.getSpheresMass

 

------------------------------------------------------------
revno: 2888
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Mon 2011-07-18 16:32:51 +0200
message:
  Add utils.getSpheresMass
modified:
  pkg/dem/Shop.cpp
  pkg/dem/Shop.hpp
  py/_utils.cpp


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

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'pkg/dem/Shop.cpp'
--- pkg/dem/Shop.cpp	2011-05-11 12:17:46 +0000
+++ pkg/dem/Shop.cpp	2011-07-18 14:32:51 +0000
@@ -289,6 +289,18 @@
 	return vol;
 }
 
+Real Shop::getSpheresMass(const shared_ptr<Scene>& _scene){
+	const shared_ptr<Scene> scene=(_scene?_scene:Omega::instance().getScene());
+	Real mass=0;
+	FOREACH(shared_ptr<Body> b, *scene->bodies){
+		if (!b || !b->isDynamic()) continue;
+		Sphere* s=dynamic_cast<Sphere*>(b->shape.get());
+		if(!s) continue;
+		mass += b->state->mass;
+	}
+	return mass;
+}
+
 Real Shop::getPorosity(const shared_ptr<Scene>& _scene, Real _volume){
 	const shared_ptr<Scene> scene=(_scene?_scene:Omega::instance().getScene());
 	Real V;

=== modified file 'pkg/dem/Shop.hpp'
--- pkg/dem/Shop.hpp	2011-03-16 21:02:40 +0000
+++ pkg/dem/Shop.hpp	2011-07-18 14:32:51 +0000
@@ -53,6 +53,10 @@
 
 		//! Compute the total volume of spheres
 		static Real getSpheresVolume(const shared_ptr<Scene>& rb=shared_ptr<Scene>());
+		
+		//! Compute the total mass of spheres
+		static Real getSpheresMass(const shared_ptr<Scene>& rb=shared_ptr<Scene>());
+		
 		//! Compute porosity; volume must be given for aperiodic simulations
 		static Real getPorosity(const shared_ptr<Scene>& rb=shared_ptr<Scene>(),Real volume=-1);
 

=== modified file 'py/_utils.cpp'
--- py/_utils.cpp	2011-03-16 21:02:40 +0000
+++ py/_utils.cpp	2011-07-18 14:32:51 +0000
@@ -405,6 +405,7 @@
 Real Shop__unbalancedForce(bool useMaxForce /*false by default*/){return Shop::unbalancedForce(useMaxForce);}
 py::tuple Shop__totalForceInVolume(){Real stiff; Vector3r ret=Shop::totalForceInVolume(stiff); return py::make_tuple(ret,stiff); }
 Real Shop__getSpheresVolume(){ return Shop::getSpheresVolume();}
+Real Shop__getSpheresMass(){ return Shop::getSpheresMass();}
 py::object Shop__kineticEnergy(bool findMaxId=false){
 	if(!findMaxId) return py::object(Shop::kineticEnergy());
 	Body::id_t maxId;
@@ -456,6 +457,7 @@
 	py::def("PWaveTimeStep",PWaveTimeStep,"Get timestep accoring to the velocity of P-Wave propagation; computed from sphere radii, rigidities and masses.");
 	py::def("RayleighWaveTimeStep",RayleighWaveTimeStep,"Determination of time step according to Rayleigh wave speed of force propagation.");
 	py::def("getSpheresVolume",Shop__getSpheresVolume,"Compute the total volume of spheres in the simulation (might crash for now if dynamic bodies are not spheres)");
+	py::def("getSpheresMass",Shop__getSpheresMass,"Compute the total mass of spheres in the simulation (might crash for now if dynamic bodies are not spheres)");
 	py::def("porosity",Shop__getPorosity,(py::arg("volume")=-1),"Compute packing poro sity $\\frac{V-V_s}{V}$ where $V$ is overall volume and $V_s$ is volume of spheres.\n\n:param float volume: overall volume which must be specified for aperiodic simulations. For periodic simulations, current volume of the :yref:`Cell` is used.\n");
 	py::def("voxelPorosity",Shop__getVoxelPorosity,(py::arg("resolution")=200,py::arg("start")=Vector3r(0,0,0),py::arg("end")=Vector3r(0,0,0)),"Compute packing porosity $\\frac{V-V_v}{V}$ where $V$ is a specified volume (from start to end) and $V_v$ is volume of voxels that fall inside any sphere. The calculation method is to divide whole volume into a dense grid of voxels (at given resolution), and count the voxels that fall inside any of the spheres. This method allows to calculate porosity in any given sub-volume of a whole sample. It is properly excluding part of a sphere that does not fall inside a specified volume.\n\n:param int resolution: voxel grid resolution, values bigger than resolution=1600 require a 64 bit operating system, because more than 4GB of RAM is used, a resolution=800 will use 500MB of RAM.\n:param Vector3 start: start corner of the volume.\n:param Vector3 end: end corner of the volume.\n");
 	py::def("aabbExtrema",aabbExtrema,(py::arg("cutoff")=0.0,py::arg("centers")=false),"Return coordinates of box enclosing all bodies\n\n:param bool centers: do not take sphere radii in account, only their centroids\n:param float∈〈0…1〉 cutoff: relative dimension by which the box will be cut away at its boundaries.\n\n\n:return: (lower corner, upper corner) as (Vector3,Vector3)\n\n");