yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #05118
[Branch ~yade-dev/yade/trunk] Rev 2327: 1. Engine for particle size distribution analyzes is added. (not finished)
------------------------------------------------------------
revno: 2327
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: trunk
timestamp: Wed 2010-07-07 17:42:59 +0200
message:
1. Engine for particle size distribution analyzes is added. (not finished)
added:
pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.cpp
pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.hpp
modified:
pkg/dem/Engine/GlobalEngine/CohesiveStateRPMRecorder.hpp
pkg/dem/meta/RockPM.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/CohesiveStateRPMRecorder.hpp'
--- pkg/dem/Engine/GlobalEngine/CohesiveStateRPMRecorder.hpp 2010-03-20 12:40:44 +0000
+++ pkg/dem/Engine/GlobalEngine/CohesiveStateRPMRecorder.hpp 2010-07-07 15:42:59 +0000
@@ -1,4 +1,4 @@
-/*! This class is for storing the cohesive contacts number
+/*! This class is for recording number of cohesive contacts
* of RPM model in a file. Class derived from Recorder
*/
#pragma once
=== added file 'pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.cpp'
--- pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.cpp 1970-01-01 00:00:00 +0000
+++ pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.cpp 2010-07-07 15:42:59 +0000
@@ -0,0 +1,76 @@
+#include"ParticleSizeDistrbutionRPMRecorder.hpp"
+
+YADE_PLUGIN((ParticleSizeDistrbutionRPMRecorder));
+CREATE_LOGGER(ParticleSizeDistrbutionRPMRecorder);
+
+void ParticleSizeDistrbutionRPMRecorder::action() {
+ numberCohesiveContacts=0;
+ int curBin = 1; //Current bin number for PSD
+ vector<identicalIds> arrayIdentIds;
+ arrayIdentIds.clear();
+
+ FOREACH(const shared_ptr<Body>& b, *scene->bodies){ // Annulling specimenNumber
+ if (!b) continue;
+ YADE_PTR_CAST<RpmState>(b->state)->specimenNumber = 0;
+ }
+
+ //Check all interactions
+ FOREACH(const shared_ptr<Interaction>& i, *scene->interactions){
+ if(!i->isReal()) continue; //Check whether they are real
+ const shared_ptr<RpmPhys>& contPhys = YADE_PTR_CAST<RpmPhys>(i->interactionPhysics);
+
+ body_id_t id1 = i->getId1(); //Get bodies ids from interaction
+ body_id_t id2 = i->getId2();
+ int& specimenNumberId1 = YADE_PTR_CAST<RpmState>(Body::byId(id1)->state)->specimenNumber;
+ int& specimenNumberId2 = YADE_PTR_CAST<RpmState>(Body::byId(id2)->state)->specimenNumber;
+
+ bool cohesiveState = contPhys->isCohesive;
+ if (cohesiveState==true){
+ if ((specimenNumberId1 == 0) and (specimenNumberId2 == 0)){ //Both bodies are "untouched"
+ specimenNumberId1 = curBin;
+ specimenNumberId2 = curBin;
+ curBin++;
+ } else if ((specimenNumberId1 != 0) and (specimenNumberId2 == 0)){ //On of bodies is 0, another one has number specimen
+ specimenNumberId2 = specimenNumberId1;
+ } else if ((specimenNumberId1 == 0) and (specimenNumberId2 != 0)){ //On of bodies is 0, another one has number specimen
+ specimenNumberId1 = specimenNumberId2;
+ } else if ((specimenNumberId1 != 0) and (specimenNumberId2 != 0) and (specimenNumberId1 != specimenNumberId2) ){ //Bodies have different specimen number, but they are cohesive! Update it
+ int minIdR = std::min(specimenNumberId1, specimenNumberId2);
+ int maxIdR = std::max(specimenNumberId1, specimenNumberId2);
+ specimenNumberId1 = minIdR;
+ specimenNumberId2 = minIdR;
+ identicalIds tempVar(minIdR, maxIdR);
+ arrayIdentIds.push_back(tempVar);
+ }
+ }
+
+
+ for (unsigned int i=0; i<arrayIdentIds.size(); i++) {
+ for (unsigned int d=0; d<arrayIdentIds.size(); d++) {
+ if (i!=d){
+ identicalIds& tempAr1 = arrayIdentIds[i];
+ identicalIds& tempAr2 = arrayIdentIds[d];
+ if (tempAr1.id2 == tempAr2.id1) {
+ tempAr2.id1 = tempAr1.id1;
+ }
+ }
+ }
+ }
+
+ for (unsigned int i=0; i<arrayIdentIds.size(); i++) {
+ FOREACH(const shared_ptr<Body>& b, *scene->bodies){
+ if (!b) continue;
+ if ((YADE_PTR_CAST<RpmState>(b->state)->specimenNumber)==arrayIdentIds[i].id2) {
+ YADE_PTR_CAST<RpmState>(b->state)->specimenNumber=arrayIdentIds[i].id1;
+ }
+ }
+ }
+
+ if (contPhys->isCohesive==true) { //Check whether they are cohesive
+ numberCohesiveContacts++; //If yes - calculate them
+ }
+ }
+ //Save data to a file
+ out<<Omega::instance().getCurrentIteration()<<" "<<curBin<<"\n";
+ out.close();
+}
=== added file 'pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.hpp'
--- pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.hpp 1970-01-01 00:00:00 +0000
+++ pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.hpp 2010-07-07 15:42:59 +0000
@@ -0,0 +1,37 @@
+/*! This class is for recording Particle Size Distribution
+ * of RPM model in a file. Class derived from Recorder
+*/
+#pragma once
+#include <yade/pkg-common/Recorder.hpp>
+#include <yade/pkg-common/InteractionPhysicsFunctor.hpp>
+#include <yade/pkg-dem/RockPM.hpp>
+
+class ParticleSizeDistrbutionRPMRecorder: public Recorder {
+ std::ofstream outFile;
+ public:
+ virtual void action();
+ YADE_CLASS_BASE_DOC_ATTRS_CTOR(ParticleSizeDistrbutionRPMRecorder,Recorder,
+ "Store number of PSD in RPM model to file.",
+ ((int,numberCohesiveContacts,0,"Number of cohesive contacts found at last run. [-]")),
+ initRun=true;);
+ DECLARE_LOGGER;
+};
+
+
+struct identicalIds{
+ int id1, id2;
+ identicalIds (int id1r, int id2r){
+ assert(id1r<id2r);
+ id1 = id1r;
+ id2 = id2r;
+ }
+
+ static bool checkIdentical(identicalIds param1, identicalIds param2) {
+ if ((param1.id1 == param2.id1) and (param1.id2 == param2.id2)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+};
+REGISTER_SERIALIZABLE(ParticleSizeDistrbutionRPMRecorder);
=== modified file 'pkg/dem/meta/RockPM.hpp'
--- pkg/dem/meta/RockPM.hpp 2010-04-25 13:18:11 +0000
+++ pkg/dem/meta/RockPM.hpp 2010-07-07 15:42:59 +0000
@@ -16,6 +16,13 @@
#include<yade/pkg-common/ElastMat.hpp>
+class RpmState: public State {
+ YADE_CLASS_BASE_DOC_ATTRS(RpmState,State,"State information about Rpm body.",
+ ((int,specimenNumber,0,"The variable is used for particle size distribution analyze. Indicates, to which part of specimen belongs para of particles."))
+ );
+};
+REGISTER_SERIALIZABLE(RpmState);
+
class Law2_Dem3DofGeom_RockPMPhys_Rpm: public LawFunctor{
public:
virtual void go(shared_ptr<InteractionGeometry>& _geom, shared_ptr<InteractionPhysics>& _phys, Interaction* I, Scene* rootBody);