Author: sega
Date: 2009-02-21 21:14:55 +0100 (Sat, 21 Feb 2009)
New Revision: 1677
Modified:
trunk/pkg/common/Engine/DeusExMachina/GravityEngines.cpp
trunk/pkg/common/Engine/MetaEngine/ConstitutiveLaw.hpp
Log:
Migrate GravityEngines and ConstitutiveLaw to BEX_CONTAINER
Modified: trunk/pkg/common/Engine/DeusExMachina/GravityEngines.cpp
===================================================================
--- trunk/pkg/common/Engine/DeusExMachina/GravityEngines.cpp 2009-02-21
14:12:20 UTC (rev 1676)
+++ trunk/pkg/common/Engine/DeusExMachina/GravityEngines.cpp 2009-02-21
20:14:55 UTC (rev 1677)
@@ -24,7 +24,11 @@
if(b->isClumpMember()) continue;
shared_ptr<ParticleParameters>
p=YADE_PTR_CAST<ParticleParameters>(b->physicalParameters);
if(p!=0) //not everything derives from ParticleParameters; this
line was assert(p); - Janek
+#ifdef BEX_CONTAINER
+ ncb->bex.force(b->getId())+=gravity*p->mass;
+#else
static_cast<Force*>(ncb->physicalActions->find(b->getId(),cachedForceClassIndex).get())->force+=gravity*p->mass;
+#endif
}
}
@@ -34,8 +38,13 @@
if(b->isClumpMember() || b->getId()==centralBody) continue; //
skip clump members and central body
Real
F=accel*YADE_PTR_CAST<ParticleParameters>(b->physicalParameters)->mass;
Vector3r
toCenter=centralPos-b->physicalParameters->se3.position; toCenter.Normalize();
+#ifdef BEX_CONTAINER
+ rootBody->bex.force(b->getId())+=F*toCenter;
+ if(reciprocal) rootBody->bex.force(centralBody)-=F*toCenter;
+#else
static_cast<Force*>(rootBody->physicalActions->find(b->getId(),cachedForceClassIndex).get())->force+=F*toCenter;
if(reciprocal)
static_cast<Force*>(rootBody->physicalActions->find(centralBody,cachedForceClassIndex).get())->force-=F*toCenter;
+#endif
}
}
@@ -49,7 +58,11 @@
const Vector3r x2=axisPoint+axisDirection;
Vector3r closestAxisPoint=(x2-x1) * /* t */
(-(x1-x0).Dot(x2-x1))/((x2-x1).SquaredLength());
Vector3r toAxis=closestAxisPoint-x0; toAxis.Normalize();
+#ifdef BEX_CONTAINER
+ rootBody->bex.force(b->getId())+=acceleration*myMass*toAxis;
+#else
static_pointer_cast<Force>(rootBody->physicalActions->find(b->getId(),cachedForceClassIndex))->force+=acceleration*myMass*toAxis;
//if(b->getId()==20){
TRVAR3(toAxis,acceleration*myMass*toAxis,static_pointer_cast<Force>(rootBody->physicalActions->find(b->getId(),cachedForceClassIndex))->force);
}
+#endif
}
}
Modified: trunk/pkg/common/Engine/MetaEngine/ConstitutiveLaw.hpp
===================================================================
--- trunk/pkg/common/Engine/MetaEngine/ConstitutiveLaw.hpp 2009-02-21
14:12:20 UTC (rev 1676)
+++ trunk/pkg/common/Engine/MetaEngine/ConstitutiveLaw.hpp 2009-02-21
20:14:55 UTC (rev 1677)
@@ -22,8 +22,14 @@
* It creates no overhead runtime overhead, since intialization of
Forces/Momentums
* is done only if the derived ConstitutiveLaw says
NEEDS_BEX("Force","Momentum"), for example.
*/
+#ifdef BEX_CONTAINER
+ inline Vector3r& bodyForce(const body_id_t id, MetaBody* rb) const {
return rb->bex.force(id); }
+ inline Vector3r& bodyTorque(const body_id_t id, MetaBody* rb) const {
return rb->bex.torque(id);}
+#else
Vector3r& bodyForce(const body_id_t id, MetaBody* rb) const { return
static_pointer_cast<Force>(rb->physicalActions->find(id,forceIdx))->force; }
Vector3r& bodyTorque(const body_id_t id, MetaBody* rb) const { return
static_pointer_cast<Momentum>(rb->physicalActions->find(id,torqueIdx))->momentum;}
+#endif
+
/*! Convenience function to apply force and torque from one force at
contact point. Not sure if this is the right place for it. */
void applyForceAtContactPoint(const Vector3r& force, const Vector3r&
contactPoint, const body_id_t id1, const Vector3r& pos1, const body_id_t id2,
const Vector3r& pos2, MetaBody* rb){
#ifdef BEX_CONTAINER
_______________________________________________
Mailing list: https://launchpad.net/~yade-dev
Post to : [email protected]
Unsubscribe : https://launchpad.net/~yade-dev
More help : https://help.launchpad.net/ListHelp