← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3622: Parallelization of one loop of Law2_ScGeom_CapillaryPhys_Capillarity (see http://www.mail-archive...

 

------------------------------------------------------------
revno: 3622
committer: jduriez <jerome.duriez@xxxxxxxxxxx>
timestamp: Tue 2015-03-17 13:59:57 -0600
message:
  Parallelization of one loop of Law2_ScGeom_CapillaryPhys_Capillarity (see http://www.mail-archive.com/yade-dev@xxxxxxxxxxxxxxxxxxx/msg11238.html) and some comments
modified:
  pkg/dem/Law2_ScGeom_CapillaryPhys_Capillarity.cpp
  pkg/dem/Law2_ScGeom_CapillaryPhys_Capillarity.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 'pkg/dem/Law2_ScGeom_CapillaryPhys_Capillarity.cpp'
--- pkg/dem/Law2_ScGeom_CapillaryPhys_Capillarity.cpp	2015-02-20 08:52:41 +0000
+++ pkg/dem/Law2_ScGeom_CapillaryPhys_Capillarity.cpp	2015-03-17 19:59:57 +0000
@@ -75,7 +75,7 @@
 	
 	if (fusionDetection && !bodiesMenisciiList.initialized) bodiesMenisciiList.prepare(scene,hertzOn);
 
-	FOREACH(const shared_ptr<Interaction>& interaction, *scene->interactions){ // could be done in parallel ? Was tried once, but needs maybe more comparison to assert it is OK: http://www.mail-archive.com/yade-dev@xxxxxxxxxxxxxxxxxxx/msg10842.html
+	FOREACH(const shared_ptr<Interaction>& interaction, *scene->interactions){ // could be done in parallel as soon as OpenMPVector class (lib/base/openmp-accu.hpp) is extended See http://www.mail-archive.com/yade-dev@xxxxxxxxxxxxxxxxxxx/msg10842.html and msg11238.html
 		/// interaction is real
 		if (interaction->isReal()) {
 			CapillaryPhys* cundallContactPhysics=NULL;
@@ -175,7 +175,14 @@
 	}
 	if (fusionDetection) checkFusion();
 
-	FOREACH(const shared_ptr<Interaction>& interaction, *scene->interactions){ // same remark for parallel loops
+        #ifdef YADE_OPENMP
+        const long size=scene->interactions->size();
+        #pragma omp parallel for schedule(guided) num_threads(ompThreads>0 ? min(ompThreads,omp_get_max_threads()) : omp_get_max_threads())
+        for(long i=0; i<size; i++){
+            const shared_ptr<Interaction>& interaction=(*scene->interactions)[i];
+        #else
+        FOREACH(const shared_ptr<Interaction>& interaction, *scene->interactions){
+        #endif
 		if (interaction->isReal()) {
 			CapillaryPhys* cundallContactPhysics=NULL;
 			MindlinCapillaryPhys* mindlinContactPhysics=NULL;

=== modified file 'pkg/dem/Law2_ScGeom_CapillaryPhys_Capillarity.hpp'
--- pkg/dem/Law2_ScGeom_CapillaryPhys_Capillarity.hpp	2015-02-20 08:52:41 +0000
+++ pkg/dem/Law2_ScGeom_CapillaryPhys_Capillarity.hpp	2015-03-17 19:59:57 +0000
@@ -55,7 +55,7 @@
 class BodiesMenisciiList
 {
 	private:
-		vector< list< shared_ptr<Interaction> > > interactionsOnBody;
+		vector< list< shared_ptr<Interaction> > > interactionsOnBody; // would require use of OpenMPVector (lib/base/openmp-accu.hpp) for parallel coding, see http://www.mail-archive.com/yade-dev@xxxxxxxxxxxxxxxxxxx/msg10842.html and msg11238.html
 		
 		//shared_ptr<Interaction> empty;
 		
@@ -122,7 +122,7 @@
 {	
 	public: 
 		Real R;
-		std::vector<TableauD> full_data;
+		std::vector<TableauD> full_data; // full_data contains a lot of TableauD, for different D. that are the Laplace solutions for a given r, and a given D
 		MeniscusParameters Interpolate2(Real D, Real P, int& index1, int& index2);		
 		std::ifstream& operator<< (std::ifstream& file);		
 		Tableau();
@@ -134,7 +134,7 @@
 {
 	public:
 		capillarylaw();
-		std::vector<Tableau> data_complete;
+		std::vector<Tableau> data_complete; // each Tableau of data_complete corresponds to one capillary file M(r=..), in ascending order of r
 		MeniscusParameters interpolate(Real R1, Real R2, Real D, Real P, int* index);		
 		void fill (const char* filename);
 };