yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #06716
Re: [Branch ~yade-dev/yade/trunk] Rev 2654: 1. HelixEngine updated, dublicated code deleted.
Hi,
I have updated HelixEngine. Now it is the child class from
RotationEngine. Therefore I deleted the duplicated code.
AxisPt is now zeroPoint
axis is now rotationAxis
Now, seems, kinematic engines are working correctly.
Discussions are welcome.
Anton
On Fri, Jan 14, 2011 at 9:03 AM, <noreply@xxxxxxxxxxxxx> wrote:
> ------------------------------------------------------------
> revno: 2654
> committer: Anton Gladky <gladky.anton@xxxxxxxxx>
> branch nick: yade
> timestamp: Fri 2011-01-14 09:01:33 +0100
> message:
> 1. HelixEngine updated, dublicated code deleted.
> 2. HelixEngine is added to regression tests.
> modified:
> pkg/common/KinematicEngines.cpp
> pkg/common/KinematicEngines.hpp
> py/tests/omega.py
>
>
> --
> 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/KinematicEngines.cpp'
> --- pkg/common/KinematicEngines.cpp 2011-01-13 13:22:41 +0000
> +++ pkg/common/KinematicEngines.cpp 2011-01-14 08:01:33 +0000
> @@ -74,16 +74,16 @@
>
> void HelixEngine::apply(const vector<Body::id_t>& ids){
> const Real& dt=scene->dt;
> - Quaternionr q(AngleAxisr(angularVelocity*dt,axis));
> angleTurned+=angularVelocity*dt;
> shared_ptr<BodyContainer> bodies = scene->bodies;
> FOREACH(Body::id_t id,ids){
> assert(id<(Body::id_t)bodies->size());
> Body* b=Body::byId(id,scene).get();
> if(!b) continue;
> - b->state->vel+=linearVelocity*axis+angularVelocity*axis.cross(b->state->pos-axisPt);
> - b->state->angVel+=angularVelocity*axis;
> + b->state->vel+=linearVelocity*rotationAxis;
> }
> + rotateAroundZero=true;
> + RotationEngine::apply(ids);
> }
>
>
>
> === modified file 'pkg/common/KinematicEngines.hpp'
> --- pkg/common/KinematicEngines.hpp 2010-12-21 12:36:14 +0000
> +++ pkg/common/KinematicEngines.hpp 2011-01-14 08:01:33 +0000
> @@ -62,14 +62,10 @@
> };
> REGISTER_SERIALIZABLE(RotationEngine);
>
> -struct HelixEngine:public KinematicEngine{
> +struct HelixEngine:public RotationEngine{
> virtual void apply(const vector<Body::id_t>& ids);
> - void postLoad(HelixEngine&){ axis.normalize(); }
> - YADE_CLASS_BASE_DOC_ATTRS(HelixEngine,KinematicEngine,"Engine applying both rotation and translation, along the same axis, whence the name HelixEngine",
> - ((Real,angularVelocity,0,,"Angular velocity [rad/s]"))
> + YADE_CLASS_BASE_DOC_ATTRS(HelixEngine,RotationEngine,"Engine applying both rotation and translation, along the same axis, whence the name HelixEngine",
> ((Real,linearVelocity,0,,"Linear velocity [m/s]"))
> - ((Vector3r,axis,Vector3r::UnitX(),Attr::triggerPostLoad,"Axis of translation and rotation; will be normalized by the engine."))
> - ((Vector3r,axisPt,Vector3r::Zero(),,"A point on the axis, to position it in space properly."))
> ((Real,angleTurned,0,,"How much have we turned so far. |yupdate| [rad]"))
> );
> };
>
> === modified file 'py/tests/omega.py'
> --- py/tests/omega.py 2011-01-13 15:24:47 +0000
> +++ py/tests/omega.py 2011-01-14 08:01:33 +0000
> @@ -67,29 +67,44 @@
> O.reset()
> id_fixed_transl = O.bodies.append(utils.sphere((0.0,0.0,0.0),1.0,fixed=True))
> id_nonfixed_transl = O.bodies.append(utils.sphere((0.0,5.0,0.0),1.0,fixed=False))
> - id_fixed_rot = O.bodies.append(utils.sphere((0.0,0.0,10.0),1.0,fixed=False))
> - id_nonfixed_rot = O.bodies.append(utils.sphere((0.0,5.0,10.0),1.0,fixed=False))
> + id_fixed_rot = O.bodies.append(utils.sphere((0.0,10.0,10.0),1.0,fixed=True))
> + id_nonfixed_rot = O.bodies.append(utils.sphere((0.0,15.0,10.0),1.0,fixed=False))
> + id_fixed_helix = O.bodies.append(utils.sphere((0.0,20.0,10.0),1.0,fixed=True))
> + id_nonfixed_helix = O.bodies.append(utils.sphere((0.0,25.0,10.0),1.0,fixed=False))
> O.engines=[
>
> TranslationEngine(velocity = 1.0, translationAxis = [1.0,0,0], ids = [id_fixed_transl]),
> TranslationEngine(velocity = 1.0, translationAxis = [1.0,0,0], ids = [id_nonfixed_transl]),
> RotationEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], rotateAroundZero = True, zeroPoint = [0.0,0.0,0.0], ids = [id_fixed_rot]),
> RotationEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], rotateAroundZero = True, zeroPoint = [0.0,5.0,0.0], ids = [id_nonfixed_rot]),
> + HelixEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], linearVelocity = 1.0, zeroPoint = [0.0,0.0,0.0], ids = [id_fixed_helix]),
> + HelixEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], linearVelocity = 1.0, zeroPoint = [0.0,5.0,0.0], ids = [id_nonfixed_helix]),
> ForceResetter(),
> NewtonIntegrator()
> ]
> O.dt = 1.0
> for i in range(0,25):
> O.step()
> - self.assertTrue(abs(O.bodies[id_fixed_transl].state.pos[0] - O.iter) < tolerance) #Check translation of fixed bodies
> - self.assertTrue(abs(O.bodies[id_nonfixed_transl].state.pos[0] - O.iter) < tolerance) #Check translation of nonfixed bodies
> - self.assertTrue(abs(O.bodies[id_fixed_rot].state.pos[0]-10.0*sin(pi/angVelTemp*O.iter))<tolerance) #Check rotation of fixed bodies X
> - self.assertTrue(abs(O.bodies[id_fixed_rot].state.pos[2]-10.0*cos(pi/angVelTemp*O.iter))<tolerance) #Check rotation of fixed bodies Y
> + self.assertTrue(abs(O.bodies[id_fixed_transl].state.pos[0] - O.iter) < tolerance) #Check translation of fixed bodies
> + self.assertTrue(abs(O.bodies[id_nonfixed_transl].state.pos[0] - O.iter) < tolerance) #Check translation of nonfixed bodies
> +
> + self.assertTrue(abs(O.bodies[id_fixed_rot].state.pos[0]-10.0*sin(pi/angVelTemp*O.iter))<tolerance) #Check rotation of fixed bodies X
> + self.assertTrue(abs(O.bodies[id_fixed_rot].state.pos[2]-10.0*cos(pi/angVelTemp*O.iter))<tolerance) #Check rotation of fixed bodies Y
> self.assertTrue(abs(O.bodies[id_fixed_rot].state.ori.toAxisAngle()[1]-Quaternion(Vector3(0.0,1.0,0.0),pi/angVelTemp*O.iter).toAxisAngle()[1])<tolerance) #Check rotation of fixed bodies, angle
>
> self.assertTrue(abs(O.bodies[id_nonfixed_rot].state.pos[0] - 10*sin(pi/angVelTemp*O.iter))<tolerance) #Check rotation of nonfixed bodies X
> self.assertTrue(abs(O.bodies[id_nonfixed_rot].state.pos[2] - 10*cos(pi/angVelTemp*O.iter))<tolerance) #Check rotation of nonfixed bodies Y
> self.assertTrue(abs(O.bodies[id_nonfixed_rot].state.ori.toAxisAngle()[1]-Quaternion(Vector3(0.0,1.0,0.0),pi/angVelTemp*O.iter).toAxisAngle()[1])<tolerance) #Check rotation of nonfixed bodies, angle
> +
> + self.assertTrue(abs(O.bodies[id_fixed_helix].state.pos[0] - 10*sin(pi/angVelTemp*O.iter))<tolerance) #Check helixEngine of fixed bodies X
> + self.assertTrue(abs(O.bodies[id_fixed_helix].state.pos[2] - 10*cos(pi/angVelTemp*O.iter))<tolerance) #Check helixEngine of fixed bodies Y
> + self.assertTrue(abs(O.bodies[id_fixed_helix].state.pos[1]-20.0 - O.iter)<tolerance) #Check helixEngine of fixed bodies Z
> +
> + self.assertTrue(abs(O.bodies[id_nonfixed_helix].state.pos[0] - 10*sin(pi/angVelTemp*O.iter))<tolerance) #Check helixEngine of nonfixed bodies X
> + self.assertTrue(abs(O.bodies[id_nonfixed_helix].state.pos[2] - 10*cos(pi/angVelTemp*O.iter))<tolerance) #Check helixEngine of nonfixed bodies Y
> + self.assertTrue(abs(O.bodies[id_nonfixed_helix].state.pos[1]-25.0 - O.iter)<tolerance) #Check helixEngine of nonfixed bodies Z
> +
> +
>
>
> class TestIO(unittest.TestCase):
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-dev
> Post to : yade-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-dev
> More help : https://help.launchpad.net/ListHelp
>
>
Follow ups
References