Defining an engine

Asked by Harsh Patel

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?

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Robert Caulk
Solved:
Last query:
Last reply:
Revision history for this message
Best Robert Caulk (rcaulk) said :
#1

Hello Harsh,

Welcome to Yade, it is probably well worth your time to go through the tutorial [1] so you can learn how we setup DEM models in Yade. Also, the class reference [2] is your best friend for finding the correct engines and engine attributes e.g. RotationEngine [3]. After you've become acquainted with how Yade models are setup, you can start looking at RotationEngine examples [4].

Cheers,

Robert

[1]https://yade-dem.org/doc/tutorial.html
[2]https://yade-dem.org/doc/yade.wrapper.html
[3]https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.RotationEngine
[4]https://github.com/yade/trunk/search?utf8=%E2%9C%93&q=rotationengine&type=

Revision history for this message
Harsh Patel (j0hnn1e) said :
#2

Thanks Robert Caulk, that solved my question.