yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #05353
[Branch ~yade-dev/yade/trunk] Rev 2364: 1. Recorder has new feature "addIterNum" which adds Iteration number to the end of file name. Off...
------------------------------------------------------------
revno: 2364
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: trunk
timestamp: Wed 2010-07-14 16:26:58 +0200
message:
1. Recorder has new feature "addIterNum" which adds Iteration number to the end of file name. Off by default.
2. Clean ParticleSizeDistrbutionRPMRecorder
modified:
pkg/common/Engine/GlobalEngine/Recorder.cpp
pkg/common/Engine/GlobalEngine/Recorder.hpp
pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.cpp
--
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/GlobalEngine/Recorder.cpp'
--- pkg/common/Engine/GlobalEngine/Recorder.cpp 2010-02-03 13:11:02 +0000
+++ pkg/common/Engine/GlobalEngine/Recorder.cpp 2010-07-14 14:26:58 +0000
@@ -5,9 +5,13 @@
Recorder::~Recorder(){}
void Recorder::openAndCheck(){
assert(!out.is_open());
- if(file.empty()) throw ios_base::failure(__FILE__ ": Empty filename.");
- out.open(file.c_str(), truncate ? fstream::trunc : fstream::app);
- if(!out.good()) throw ios_base::failure(__FILE__ ": I/O error opening file `"+file+"'.");
+
+ std::string fileTemp = file;
+ if (addIterNum) fileTemp+="-" + lexical_cast<string>(scene->currentIteration);
+
+ if(fileTemp.empty()) throw ios_base::failure(__FILE__ ": Empty filename.");
+ out.open(fileTemp.c_str(), truncate ? fstream::trunc : fstream::app);
+ if(!out.good()) throw ios_base::failure(__FILE__ ": I/O error opening file `"+fileTemp+"'.");
}
#if 0
void Recorder::postProcessAttributes(bool deserializing){
=== modified file 'pkg/common/Engine/GlobalEngine/Recorder.hpp'
--- pkg/common/Engine/GlobalEngine/Recorder.hpp 2010-03-20 12:40:44 +0000
+++ pkg/common/Engine/GlobalEngine/Recorder.hpp 2010-07-14 14:26:58 +0000
@@ -20,6 +20,7 @@
YADE_CLASS_BASE_DOC_ATTRS(Recorder,PeriodicEngine,"Engine periodically storing some data to (one) external file. In addition PeriodicEngine, it handles opening the file as needed. See :yref:`PeriodicEngine` for controlling periodicity.",
((std::string,file,,"Name of file to save to; must not be empty."))
((bool,truncate,false,"Whether to delete current file contents, if any, when opening (false by default)"))
+ ((bool,addIterNum,false,"Adds an iteration number to the file name, when the file was created. Useful for creating new files at each call (false by default)"))
);
};
REGISTER_SERIALIZABLE(Recorder);
=== modified file 'pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.cpp'
--- pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.cpp 2010-07-12 14:58:42 +0000
+++ pkg/dem/Engine/GlobalEngine/ParticleSizeDistrbutionRPMRecorder.cpp 2010-07-14 14:26:58 +0000
@@ -158,17 +158,12 @@
}
}
- //Check Masses in bodies loop and in dedicated vector. ONLY for debugging.
- Real totalMass2 = 0;
- for (unsigned int i=0; i<arrayIdentIds.size(); i++) {
- totalMass2+=arrayIdentIds[i].mass;
- }
std::sort (arrayIdentIds.begin(), arrayIdentIds.end(), identicalIds::sortArrayIdentIds);
//Save data to a file
out<<"**********\n";
- out<<"iter totalMass1 totalMass2 numSpecimen\n";
- out<<Omega::instance().getCurrentIteration()<<" "<<totalMass<<" "<<totalMass2<<" "<<arrayIdentIds.size()<<"\n";
+ out<<"iter totalMass numSpecimen\n";
+ out<<Omega::instance().getCurrentIteration()<<" "<<totalMass<<" "<<arrayIdentIds.size()<<"\n";
out<<"id mass\n";
for (unsigned int i=0; i<arrayIdentIds.size(); i++) {
out<<arrayIdentIds[i].id1<<" "<<arrayIdentIds[i].mass<<"\n";