← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3970: Added assert to get*Unsynced function

 

------------------------------------------------------------
revno: 3970
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Tue 2014-05-20 08:35:16 +0200
message:
  Added assert to get*Unsynced function
  
  Do not return _zero if there is a try to
  access out of size element.
modified:
  core/ForceContainer.hpp


--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'core/ForceContainer.hpp'
--- core/ForceContainer.hpp	2014-05-20 06:35:16 +0000
+++ core/ForceContainer.hpp	2014-05-20 06:35:16 +0000
@@ -97,8 +97,8 @@
 		/*! Function to allow friend classes to get force even if not synced. Used for clumps by NewtonIntegrator.
 		* Dangerous! The caller must know what it is doing! (i.e. don't read after write
 		* for a particular body id. */
-		const Vector3r& getForceUnsynced (Body::id_t id){return ((size_t)id<size)?_force[id]:_zero;}
-		const Vector3r& getTorqueUnsynced(Body::id_t id){return ((size_t)id<size)?_torque[id]:_zero;}
+		const Vector3r& getForceUnsynced (Body::id_t id){assert ((size_t)id<size); return _force[id];}
+		const Vector3r& getTorqueUnsynced(Body::id_t id){assert ((size_t)id<size); return _torque[id];}
 		void  addForceUnsynced(Body::id_t id, const Vector3r& f){ assert ((size_t)id<size); _force[id]+=f; }
 		void  addTorqueUnsynced(Body::id_t id, const Vector3r& m){ assert ((size_t)id<size); _torque[id]+=m; }