yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #02433
[Branch ~yade-dev/yade/trunk] Rev 1834: 1. CohesiveStateRPMRecorder now derives from the Recorder
------------------------------------------------------------
revno: 1834
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2009-12-01 15:00:40 +0100
message:
1. CohesiveStateRPMRecorder now derives from the Recorder
modified:
pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.cpp
pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.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/StandAloneEngine/CohesiveStateRPMRecorder.cpp'
--- pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.cpp 2009-11-27 14:42:21 +0000
+++ pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.cpp 2009-12-01 14:00:40 +0000
@@ -3,8 +3,8 @@
YADE_PLUGIN((CohesiveStateRPMRecorder));
CREATE_LOGGER(CohesiveStateRPMRecorder);
-CohesiveStateRPMRecorder::CohesiveStateRPMRecorder() {
- initRun=true;
+CohesiveStateRPMRecorder::CohesiveStateRPMRecorder():Recorder(){
+ initRun=true; //We want to save the data in the beginning
numberCohesiveContacts=0;
}
@@ -16,15 +16,15 @@
void CohesiveStateRPMRecorder::action(MetaBody* rootBody) {
numberCohesiveContacts=0;
+ //Check all interactions
FOREACH(const shared_ptr<Interaction>& i, *rootBody->interactions){
- if(!i->isReal()) continue;
+ if(!i->isReal()) continue; //Check whether they are real
const shared_ptr<RpmPhys>& contPhys = YADE_PTR_CAST<RpmPhys>(i->interactionPhysics);
- if (contPhys->isCohesive==true) {
- numberCohesiveContacts++;
+ if (contPhys->isCohesive==true) { //Check whether they are cohesive
+ numberCohesiveContacts++; //If yes - calculate them
}
}
- //Temporary solution, while flieRecorder class is not ready
- outFile.open(outFileName.c_str(), ios::out | ios::app);
- outFile<<Omega::instance().getCurrentIteration()<<" "<<numberCohesiveContacts<<"\n";
- outFile.close();
+ //Save data to a file
+ out<<Omega::instance().getCurrentIteration()<<" "<<numberCohesiveContacts<<"\n";
+ out.close();
}
=== modified file 'pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.hpp'
--- pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.hpp 2009-11-27 14:42:21 +0000
+++ pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.hpp 2009-12-01 14:00:40 +0000
@@ -1,15 +1,14 @@
/*! This class is for storing the cohesive contacts number
- * of RPM model in file
+ * of RPM model in a file. Class derived from Recorder
*/
#pragma once
-#include<yade/pkg-common/PeriodicEngines.hpp>
-#include<yade/pkg-common/InteractionPhysicsEngineUnit.hpp>
-#include<yade/pkg-dem/RockPM.hpp>
-
-
-class CohesiveStateRPMRecorder: public PeriodicEngine {
+#include <yade/pkg-common/Recorder.hpp>
+#include <yade/pkg-common/InteractionPhysicsEngineUnit.hpp>
+#include <yade/pkg-dem/RockPM.hpp>
+
+
+class CohesiveStateRPMRecorder: public Recorder {
public:
- string outFileName;
int numberCohesiveContacts;
CohesiveStateRPMRecorder();
~CohesiveStateRPMRecorder();
@@ -19,8 +18,8 @@
private:
std::ofstream outFile;
- REGISTER_ATTRIBUTES(PeriodicEngine,(outFileName));
- REGISTER_CLASS_AND_BASE(CohesiveStateRPMRecorder,PeriodicEngine);
+ REGISTER_ATTRIBUTES(Recorder,(numberCohesiveContacts));
+ REGISTER_CLASS_AND_BASE(CohesiveStateRPMRecorder,Recorder);
DECLARE_LOGGER;
};
REGISTER_SERIALIZABLE(CohesiveStateRPMRecorder);