← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2406: 1. Added materialId analyze to PSD-engine

 

------------------------------------------------------------
revno: 2406
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: trunk
timestamp: Wed 2010-08-18 15:35:16 +0200
message:
  1. Added materialId analyze to PSD-engine
  2. Changed chmod of CohesiveFrictionalPM
modified:
  pkg/dem/Engine/GlobalEngine/CohesiveFrictionalPM.cpp*
  pkg/dem/Engine/GlobalEngine/CohesiveFrictionalPM.hpp*
  pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.cpp
  pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.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/dem/Engine/GlobalEngine/CohesiveFrictionalPM.cpp' (properties changed: +x to -x)
=== modified file 'pkg/dem/Engine/GlobalEngine/CohesiveFrictionalPM.hpp' (properties changed: +x to -x)
=== modified file 'pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.cpp'
--- pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.cpp	2010-08-17 13:34:22 +0000
+++ pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.cpp	2010-08-18 13:35:16 +0000
@@ -187,16 +187,85 @@
 			}
 		}
 	}
-	
 	std::sort (arrayIdentIds.begin(), arrayIdentIds.end(), identicalIds::sortArrayIdentIds);
 	
+	//Material Analyze===============================================================================================
+	vector<materialAnalyze> materialAnalyzeIds;
+	materialAnalyzeIds.clear();
+	FOREACH(const shared_ptr<Body>& b, *scene->bodies){
+		if (!b) continue;
+		const Sphere* sphere = dynamic_cast<Sphere*>(b->shape.get());
+		if (sphere) {
+			int specimenNumberId = YADE_PTR_CAST<RpmState>(b->state)->specimenNumber;
+			int materialId = b->material->id;
+			
+			//Check, whether this specimenId is in array
+			bool foundSuitableRecording = false;
+			for (unsigned int i=0; i<materialAnalyzeIds.size(); i++) {
+				if ((materialAnalyzeIds[i].specId == specimenNumberId) and (materialAnalyzeIds[i].matId == materialId)) {
+					materialAnalyzeIds[i].particleNumber++;
+					materialAnalyzeIds[i].mass+=YADE_PTR_CAST<RpmState>(b->state)->specimenMass;
+					foundSuitableRecording = true;
+					break;
+				}
+			}
+			//If not found the recording, create one
+			if (!foundSuitableRecording) {
+				materialAnalyze tempVar (materialId, specimenNumberId, 1, YADE_PTR_CAST<RpmState>(b->state)->specimenMass);
+				materialAnalyzeIds.push_back(tempVar);
+			}
+		}
+	}
+	std::sort (materialAnalyzeIds.begin(), materialAnalyzeIds.end(), materialAnalyze::sortMaterialAnalyze);
+	
+	for (unsigned int i=0; i<materialAnalyzeIds.size(); i++) {
+		std::cout<<materialAnalyzeIds[i].matId<<" "<<materialAnalyzeIds[i].specId<<" "<<materialAnalyzeIds[i].mass<<" "<<materialAnalyzeIds[i].particleNumber<<"\n";
+	}
+	std::cout<<"\n";
+	
+	//Define, how many material columns we need:
+	vector<int> materialCount;
+	materialCount.clear();
+	for (unsigned int i=0; i<materialAnalyzeIds.size(); i++) {
+		bool foundItem = false;
+		for (unsigned int w=0; w<materialCount.size(); w++) {
+			if (materialCount[w]==materialAnalyzeIds[i].matId) {
+				foundItem = true;
+				break;
+			}
+		}
+		if (foundItem==false) {materialCount.push_back(materialAnalyzeIds[i].matId);}
+	}
+	for (unsigned int w=0; w<materialCount.size(); w++) { std::cout<<materialCount[w]<<" ";}
+	std::cout<<"\n";
+		
+	//=================================================================================================================
 	//Save data to a file
 	out<<"**********\n";
 	out<<"iter totalMass numSpecimen\n";
 	out<<scene->iter<<" "<<totalMass<<" "<<arrayIdentIds.size()<<"\n";
-	out<<"id mass maxDistanceBetweenSph\n";
+	out<<"id mass maxDistanceBetweenSph ";
+	
+	for (unsigned int w=0; w<materialCount.size(); w++) { out<<"mat_"<<materialCount[w]<<" partN_"<<materialCount[w]<<" ";}
+	out<<"\n";
+	
 	for (unsigned int i=0; i<arrayIdentIds.size(); i++) {
-		out<<arrayIdentIds[i].id1<<" "<<arrayIdentIds[i].mass<<" "<<arrayIdentIds[i].maxDistanceBetweenSpheres<<"\n";
+		out<<arrayIdentIds[i].id1<<" "<<arrayIdentIds[i].mass<<" "<<arrayIdentIds[i].maxDistanceBetweenSpheres<<" ";
+		//Find Material Info
+		for (unsigned int w=0; w<materialCount.size(); w++) {
+			bool findItem=false;
+			for (unsigned int l=0; l<materialAnalyzeIds.size(); l++) {
+				if ((materialAnalyzeIds[l].matId==materialCount[w])&&(materialAnalyzeIds[l].specId==arrayIdentIds[i].id1)) {
+					out<<materialAnalyzeIds[l].mass<<" "<<materialAnalyzeIds[l].particleNumber<<" ";
+					findItem=true;
+				}
+			}
+			if (!findItem) {
+				out<<"0 0 ";
+			}
+		}
+		
+		out<<"\n";
 	}
 	out.close();
 }

=== modified file 'pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.hpp'
--- pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.hpp	2010-08-17 13:34:22 +0000
+++ pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.hpp	2010-08-18 13:35:16 +0000
@@ -31,4 +31,17 @@
 	}
 	static bool sortArrayIdentIds (identicalIds i, identicalIds d) {return i.mass>d.mass;}
 };
+
+struct materialAnalyze{
+	int matId, specId, particleNumber;
+	Real mass;
+	materialAnalyze (int matIdR, int specIdR, int particleNumberR, Real massR){
+		matId = matIdR;
+		specId = specIdR;
+		particleNumber = particleNumberR;
+		mass = massR;
+	}
+	static bool sortMaterialAnalyze (materialAnalyze i, materialAnalyze d) {return d.specId>i.specId;}
+};
+
 REGISTER_SERIALIZABLE(ParticleSizeDistrbutionRPMRecorder);