yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #08284
[Branch ~yade-dev/yade/trunk] Rev 3012: Check newly created spheres on intersection with spheres, which were created in one iteration in ...
------------------------------------------------------------
revno: 3012
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Wed 2012-02-01 11:51:19 +0100
message:
Check newly created spheres on intersection with spheres, which were created in one iteration in SpheresFactory. Hopefully fixes "jumping sphere" problem, discussed here [1]
[1] http://www.mail-archive.com/yade-dev@xxxxxxxxxxxxxxxxxxx/msg07622.html
modified:
pkg/dem/SpheresFactory.cpp
pkg/dem/SpheresFactory.hpp
--
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/SpheresFactory.cpp'
--- pkg/dem/SpheresFactory.cpp 2012-01-10 09:39:47 +0000
+++ pkg/dem/SpheresFactory.cpp 2012-02-01 10:51:19 +0000
@@ -87,6 +87,8 @@
maxMass = -1;
}
+ vector< SpherCoord > justCreatedBodies;
+
while(totalMass<goalMass && (maxParticles<0 || numParticles<maxParticles) && (maxMass<0 || totalMass<maxMass)){
Real r=0.0;
@@ -122,8 +124,19 @@
pickRandomPosition(c,r);
LOG_TRACE("Center "<<c);
Bound b; b.min=c-Vector3r(r,r,r); b.max=c+Vector3r(r,r,r);
- vector<Body::id_t> collidingParticles=collider->probeBoundingVolume(b);
- if(collidingParticles.size()==0) break;
+ vector<Body::id_t> collidingParticles=collider->probeBoundingVolume(b); //Check, whether newly created sphere collides with existing bodies
+
+ bool collideWithNewBodies = false;
+ if (justCreatedBodies.size()>0) { //Check, whether newly created sphere collides with bodies from this scope
+ for (unsigned int ii = 0; ii < justCreatedBodies.size(); ii++) {
+ if ((justCreatedBodies.at(ii).c-c).norm() < (justCreatedBodies.at(ii).r+r)) { //Bodies intersect
+ collideWithNewBodies = true;
+ break;
+ }
+ }
+ }
+
+ if(collidingParticles.size()==0 and not(collideWithNewBodies)) break;
#ifdef YADE_DEBUG
FOREACH(const Body::id_t& id, collidingParticles) LOG_TRACE(scene->iter<<":"<<attempt<<": collision with #" <<id);
#endif
@@ -172,6 +185,8 @@
totalVolume+= vol;
numParticles++;
+ justCreatedBodies.push_back(SpherCoord(c, r));
+
if (PSDuse) { //Add newly created "material" into the bin
Real summMaterial = 0.0;
if (PSDcalculateMass) { PSDCurMean[maxdiffID]=PSDCurMean[maxdiffID]+state->mass; summMaterial = totalMass;}
=== modified file 'pkg/dem/SpheresFactory.hpp'
--- pkg/dem/SpheresFactory.hpp 2012-01-10 09:39:47 +0000
+++ pkg/dem/SpheresFactory.hpp 2012-02-01 10:51:19 +0000
@@ -15,6 +15,10 @@
bool PSDuse; //PSD or not
public:
virtual void action();
+ struct SpherCoord{
+ Vector3r c; Real r;
+ SpherCoord(const Vector3r& _c, Real _r){ c=_c; r=_r;}
+ };
DECLARE_LOGGER;
YADE_CLASS_BASE_DOC_ATTRS_CTOR(SpheresFactory,GlobalEngine,"Engine for spitting spheres based on mass flow rate, particle size distribution etc. Initial velocity of particles is given by *vMin*, *vMax*, the *massFlowRate* determines how many particles to generate at each step. When *goalMass* is attained or positive *maxParticles* is reached, the engine does not produce particles anymore. Geometry of the region should be defined in a derived engine by overridden SpheresFactory::pickRandomPosition(). \n\nA sample script for this engine is in :ysrc:`scripts/spheresFactory.py`.",
((Real,massFlowRate,NaN,,"Mass flow rate [kg/s]"))