← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2059: GravityEngine parallelized

 

------------------------------------------------------------
revno: 2059
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-03-02 16:17:30 +0100
message:
  GravityEngine parallelized
modified:
  pkg/common/Engine/PartialEngine/GravityEngines.cpp
  pkg/common/Engine/PartialEngine/GravityEngines.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/GravityEngines.cpp'
--- pkg/common/Engine/PartialEngine/GravityEngines.cpp	2009-12-25 14:46:48 +0000
+++ pkg/common/Engine/PartialEngine/GravityEngines.cpp	2010-03-02 15:17:30 +0000
@@ -18,7 +18,15 @@
 	 *
 	 * The choice is to skip (b->isClumpMember()) or (b->isClump()). We rather skip members,
 	 * since that will apply smaller number of forces. */
+	#ifdef YADE_OPENMP
+		const BodyContainer& bodies=*(scene->bodies.get());
+		const long size=(long)bodies.size();
+		#pragma omp parallel for schedule(static)
+		for(long i=0; i<size; i++){
+			const shared_ptr<Body>& b(bodies[i]);
+	#else
 	FOREACH(const shared_ptr<Body>& b, *scene->bodies){
+	#endif
 		if(!b || b->isClumpMember()) continue;
 		scene->forces.addForce(b->getId(),gravity*b->state->mass);
 	}

=== modified file 'pkg/common/Engine/PartialEngine/GravityEngines.hpp'
--- pkg/common/Engine/PartialEngine/GravityEngines.hpp	2010-02-15 19:27:34 +0000
+++ pkg/common/Engine/PartialEngine/GravityEngines.hpp	2010-03-02 15:17:30 +0000
@@ -4,6 +4,9 @@
 #include<yade/core/GlobalEngine.hpp>
 #include<yade/core/Interaction.hpp>
 #include<yade/core/Body.hpp>
+#ifdef YADE_OPENMP
+	#include<omp.h>
+#endif
 
 /*! Homogeneous gravity field; applies gravity×mass force on all bodies. */
 class GravityEngine: public GlobalEngine{