yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #07216
[Branch ~yade-dev/yade/trunk] Rev 2775: "mask" parameter is added to GravitiEngines to make it more flexible.
------------------------------------------------------------
revno: 2775
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Tue 2011-03-01 11:31:54 +0100
message:
"mask" parameter is added to GravitiEngines to make it more flexible.
modified:
pkg/common/GravityEngines.cpp
pkg/common/GravityEngines.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/common/GravityEngines.cpp'
--- pkg/common/GravityEngines.cpp 2011-02-27 13:54:43 +0000
+++ pkg/common/GravityEngines.cpp 2011-03-01 10:31:54 +0000
@@ -20,6 +20,7 @@
YADE_PARALLEL_FOREACH_BODY_BEGIN(const shared_ptr<Body>& b, scene->bodies){
// skip clumps, only apply forces on their constituents
if(!b || b->isClump()) continue;
+ if(mask!=0 && (b->groupMask & mask)==0) continue;
scene->forces.addForce(b->getId(),gravity*b->state->mass);
// work done by gravity is "negative", since the energy appears in the system from outside
if(trackEnergy) scene->energy->add(-gravity.dot(b->state->vel)*b->state->mass*dt,"gravWork",fieldWorkIx,/*non-incremental*/false);
@@ -30,6 +31,7 @@
const Vector3r& centralPos=Body::byId(centralBody)->state->pos;
FOREACH(const shared_ptr<Body>& b, *scene->bodies){
if(!b || b->isClump() || b->getId()==centralBody) continue; // skip clumps and central body
+ if(mask!=0 && (b->groupMask & mask)==0) continue;
Real F=accel*b->state->mass;
Vector3r toCenter=centralPos-b->state->pos; toCenter.normalize();
scene->forces.addForce(b->getId(),F*toCenter);
@@ -40,6 +42,7 @@
void AxialGravityEngine::action(){
FOREACH(const shared_ptr<Body>&b, *scene->bodies){
if(!b || b->isClump()) continue;
+ if(mask!=0 && (b->groupMask & mask)==0) continue;
/* http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html */
const Vector3r& x0=b->state->pos;
const Vector3r& x1=axisPoint;
=== modified file 'pkg/common/GravityEngines.hpp'
--- pkg/common/GravityEngines.hpp 2010-11-20 22:38:25 +0000
+++ pkg/common/GravityEngines.hpp 2011-03-01 10:31:54 +0000
@@ -12,6 +12,7 @@
YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(GravityEngine,FieldApplier,"Engine applying constant acceleration to all bodies.",
((Vector3r,gravity,Vector3r::Zero(),,"Acceleration [kgmsâ»Â²]"))
((int,gravPotIx,-1,(Attr::noSave|Attr::hidden),"Index for gravPot energy"))
+ ((int,mask,0,,"If mask defined, only bodies with corresponding groupMask will be affected by this engine. If 0, all bodies will be affected."))
,/*ctor*/,/*py*/
);
};
@@ -29,6 +30,7 @@
((Body::id_t,centralBody,Body::ID_NONE,,"The :yref:`body<Body>` towards which all other bodies are attracted."))
((Real,accel,0,,"Acceleration magnitude [kgmsâ»Â²]"))
((bool,reciprocal,false,,"If true, acceleration will be applied on the central body as well."))
+ ((int,mask,0,,"If mask defined, only bodies with corresponding groupMask will be affected by this engine. If 0, all bodies will be affected."))
,,
);
};
@@ -44,6 +46,7 @@
((Vector3r,axisPoint,Vector3r::Zero(),,"Point through which the axis is passing."))
((Vector3r,axisDirection,Vector3r::UnitX(),,"direction of the gravity axis (will be normalized automatically)"))
((Real,acceleration,0,,"Acceleration magnitude [kgmsâ»Â²]"))
+ ((int,mask,0,,"If mask defined, only bodies with corresponding groupMask will be affected by this engine. If 0, all bodies will be affected."))
);
};
REGISTER_SERIALIZABLE(AxialGravityEngine);