← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2892: Add mask-parameter to utils.getSpheresVolume and utils.getSpheresMass

 

------------------------------------------------------------
revno: 2892
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Wed 2011-07-20 09:49:38 +0200
message:
  Add mask-parameter to utils.getSpheresVolume and utils.getSpheresMass
modified:
  pkg/dem/Shop.cpp
  pkg/dem/Shop.hpp
  pkg/dem/SpheresFactory.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-07-18 14:32:51 +0000
+++ pkg/dem/Shop.cpp	2011-07-20 07:49:38 +0000
@@ -277,25 +277,25 @@
 	f.close();
 }
 
-Real Shop::getSpheresVolume(const shared_ptr<Scene>& _scene){
+Real Shop::getSpheresVolume(const shared_ptr<Scene>& _scene, int mask){
 	const shared_ptr<Scene> scene=(_scene?_scene:Omega::instance().getScene());
 	Real vol=0;
 	FOREACH(shared_ptr<Body> b, *scene->bodies){
 		if (!b || !b->isDynamic()) continue;
 		Sphere* s=dynamic_cast<Sphere*>(b->shape.get());
-		if(!s) continue;
+		if((!s) or ((mask>0) and (mask!=b->groupMask))) continue;
 		vol += (4/3.)*Mathr::PI*pow(s->radius,3);
 	}
 	return vol;
 }
 
-Real Shop::getSpheresMass(const shared_ptr<Scene>& _scene){
+Real Shop::getSpheresMass(const shared_ptr<Scene>& _scene, int mask){
 	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;
+		if((!s) or ((mask>0) and (mask!=b->groupMask))) continue;
 		mass += b->state->mass;
 	}
 	return mass;

=== modified file 'pkg/dem/Shop.hpp'
--- pkg/dem/Shop.hpp	2011-07-18 14:32:51 +0000
+++ pkg/dem/Shop.hpp	2011-07-20 07:49:38 +0000
@@ -52,10 +52,10 @@
 		static void saveSpheresToFile(string fileName);
 
 		//! Compute the total volume of spheres
-		static Real getSpheresVolume(const shared_ptr<Scene>& rb=shared_ptr<Scene>());
+		static Real getSpheresVolume(const shared_ptr<Scene>& rb=shared_ptr<Scene>(), int mask=-1);
 		
 		//! Compute the total mass of spheres
-		static Real getSpheresMass(const shared_ptr<Scene>& rb=shared_ptr<Scene>());
+		static Real getSpheresMass(const shared_ptr<Scene>& rb=shared_ptr<Scene>(), int mask=-1);
 		
 		//! 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 'pkg/dem/SpheresFactory.hpp'
--- pkg/dem/SpheresFactory.hpp	2011-07-19 07:06:08 +0000
+++ pkg/dem/SpheresFactory.hpp	2011-07-20 07:49:38 +0000
@@ -9,6 +9,9 @@
 	protected:
 		// Pick random position of a sphere. Should be override in derived engine.
 		virtual void pickRandomPosition(Vector3r&/*picked position*/, Real/*sphere's radius*/);
+		vector<Real> PSDCurMean;  //Current value of material in each bin
+		vector<Real> PSDCurProc;  //Current value of material in each bin, in procents
+		vector<Real> PSDNeedProc; //Need value of procent in each bin
 	public:
 		virtual void action();
 	DECLARE_LOGGER;
@@ -30,6 +33,9 @@
 		((int,maxAttempt,5000 ,,"Maximum number of attempts to position a new sphere randomly."))
 		((bool,silent,false ,,"If true no complain about excessing maxAttempt but disable the factory (by set massFlowRate=0)."))
 		((std::string,blockedDOFs,"" ,,"Blocked degress of freedom"))
+		((vector<Real>,PSDsizes,,,"PSD-dispersion, sizes of cells [m]"))
+		((vector<Real>,PSDcum,,,"PSD-dispersion, cumulative procent meanings [-]"))
+		((std::string,PSDcalculate,"mass",,"How the PSD will be calculated: mass, number or volume of particles"))
 	);
 };
 REGISTER_SERIALIZABLE(SpheresFactory);

=== modified file 'py/_utils.cpp'
--- py/_utils.cpp	2011-07-18 14:32:51 +0000
+++ py/_utils.cpp	2011-07-20 07:49:38 +0000
@@ -404,8 +404,8 @@
 
 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();}
+Real Shop__getSpheresVolume(int mask=-1){ return Shop::getSpheresVolume(Omega::instance().getScene(), mask=mask);}
+Real Shop__getSpheresMass(int mask=-1){ return Shop::getSpheresMass(Omega::instance().getScene(), mask=mask);}
 py::object Shop__kineticEnergy(bool findMaxId=false){
 	if(!findMaxId) return py::object(Shop::kineticEnergy());
 	Body::id_t maxId;
@@ -456,8 +456,8 @@
 
 	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("getSpheresVolume",Shop__getSpheresVolume,(py::arg("mask")=-1),"Compute the total volume of spheres in the simulation (might crash for now if dynamic bodies are not spheres), mask parameter is considered");
+	py::def("getSpheresMass",Shop__getSpheresMass,(py::arg("mask")=-1),"Compute the total mass of spheres in the simulation (might crash for now if dynamic bodies are not spheres), mask parameter is considered");
 	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");