← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2058: RotationEngine parallelized

 

------------------------------------------------------------
revno: 2058
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-03-02 15:15:29 +0100
message:
  RotationEngine parallelized
modified:
  pkg/common/Engine/PartialEngine/RotationEngine.cpp
  pkg/common/Engine/PartialEngine/RotationEngine.hpp


--
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/Engine/PartialEngine/RotationEngine.cpp'
--- pkg/common/Engine/PartialEngine/RotationEngine.cpp	2010-02-09 20:22:04 +0000
+++ pkg/common/Engine/PartialEngine/RotationEngine.cpp	2010-03-02 14:15:29 +0000
@@ -45,10 +45,17 @@
 
 
 void RotationEngine::applyCondition(Scene*){
-   rotationAxis.Normalize();
+	rotationAxis.Normalize();
 	Quaternionr q;
 	q.FromAxisAngle(rotationAxis,angularVelocity*scene->dt);
+	#ifdef YADE_OPENMP
+	const long size=subscribedBodies.size();
+	#pragma omp parallel for schedule(static)
+	for(long i=0; i<size; i++){
+		const body_id_t& id=subscribedBodies[i];
+	#else
 	FOREACH(body_id_t id,subscribedBodies){
+	#endif
 		State* rb=Body::byId(id,scene)->state.get();
 		rb->angVel=rotationAxis*angularVelocity;
 		if(rotateAroundZero){
@@ -56,8 +63,8 @@
 			rb->pos=q*l+zeroPoint; 
 			rb->vel=rb->angVel.Cross(l);
 		}
-		rb->ori=q*rb->ori;
-		rb->ori.Normalize();
+	rb->ori=q*rb->ori;
+	rb->ori.Normalize();
 	}
 }
 

=== modified file 'pkg/common/Engine/PartialEngine/RotationEngine.hpp'
--- pkg/common/Engine/PartialEngine/RotationEngine.hpp	2010-02-09 20:22:04 +0000
+++ pkg/common/Engine/PartialEngine/RotationEngine.hpp	2010-03-02 14:15:29 +0000
@@ -4,6 +4,9 @@
 
 #include<yade/core/PartialEngine.hpp>
 #include<yade/lib-base/Math.hpp>
+#ifdef YADE_OPENMP
+	#include<omp.h>
+#endif
 
 /*! Engine applying rotation (by setting angular velocity) to subscribed bodies.
  * If rotateAroundZero is set, then each body is also displaced around zeroPoint.


Follow ups