← Back to team overview

yade-users team mailing list archive

[Question #667254]: Defining an engine

 

New question #667254 on Yade:
https://answers.launchpad.net/yade/+question/667254

I have to run a rotation cum constant pressure plate over a open FacetBox filled with spheres: imitating aggregate compaction in the field. Through my literature review, I came across this code for rotation plate engine:

#include "RotationEngine.hpp"
#include<yade/pkg-common/RigidBodyParameters.hpp>
#include<yade/core/MetaBody.hpp>
#include<yade/lib-base/yadeWm3Extra.hpp>
RotationEngine::RotationEngine()
{
rotateAroundZero = false;
zeroPoint = Vector3r(0,0,0);
}
void RotationEngine::registerAttributes()
{
DeusExMachina::registerAttributes();
REGISTER_ATTRIBUTE(angularVelocity);
REGISTER_ATTRIBUTE(rotationAxis);
REGISTER_ATTRIBUTE(rotateAroundZero);
REGISTER_ATTRIBUTE(zeroPoint);
}
void RotationEngine::postProcessAttributes(bool deserializing)
{
if (!deserializing) return;
rotationAxis.Normalize();
}
void RotationEngine::applyCondition(MetaBody *ncb)
{
shared_ptr<BodyContainer> bodies = ncb->bodies;
std::vector<int>::const_iterator ii = subscribedBodies.begin();
std::vector<int>::const_iterator iiEnd = subscribedBodies.end();
Real dt = Omega::instance().getTimeStep();
// time = dt;
Quaternionr q;
q.FromAxisAngle(rotationAxis,angularVelocity*dt);
Vector3r ax;
Real an;
for(;ii!=iiEnd;++ii)
{
RigidBodyParameters * rb =
static_cast<RigidBodyParameters*>((*bodies)[*ii]-
>physicalParameters.get());
154
if(rotateAroundZero)
rb->se3.position = q*(rb->se3.positionzeroPoint)+
zeroPoint; // for RotatingBox
rb->se3.orientation = q*rb->se3.orientation;
rb->se3.orientation.Normalize();
rb->se3.orientation.ToAxisAngle(ax,an);
rb->angularVelocity = rotationAxis*angularVelocity;
rb->velocity = Vector3r(0,0,0);
}
}
YADE_PLUGIN();

<src: Chen, J. (2011). Discrete element method (DEM) analyses for hot-mix asphalt (HMA) mixture compaction.>

My question is, how do I use this C++ code in my python program? Do I have to copy-paste this code somewhere to be called as an engine in the main python framework?

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.