41 |
|
|
42 |
|
#include "applications/dynamicProps/CorrelationFunction.hpp" |
43 |
|
#include "utils/simError.h" |
44 |
< |
|
44 |
> |
#include "primitives/Molecule.hpp" |
45 |
|
namespace oopse { |
46 |
|
|
47 |
|
CorrelationFunction::CorrelationFunction(SimInfo* info, const std::string& filename, |
73 |
|
storageLayout_ |= DataStorage::dslElectroFrame; |
74 |
|
} |
75 |
|
|
76 |
< |
bsMan_ = new BlockSnapshotMananger(info, dumpFilename_, storageLayout_); |
77 |
< |
info->setSnapshotManager(bsMan_); |
76 |
> |
bsMan_ = new BlockSnapshotManager(info, dumpFilename_, storageLayout_); |
77 |
> |
info_->setSnapshotManager(bsMan_); |
78 |
|
|
79 |
|
//if selection is static, we only need to evaluate it once |
80 |
|
if (!evaluator1_.isDynamic()) { |
85 |
|
seleMan2_.setSelectionSet(evaluator2_.evaluate()); |
86 |
|
validateSelection(seleMan2_); |
87 |
|
} |
88 |
+ |
|
89 |
+ |
/**@todo Fixed Me */ |
90 |
+ |
Globals* simParams = info_->getSimParams(); |
91 |
+ |
if (simParams->haveSampleTime()){ |
92 |
+ |
deltaTime_ = simParams->getSampleTime(); |
93 |
+ |
} else { |
94 |
+ |
sprintf(painCave.errMsg, |
95 |
+ |
"CorrelationFunction::writeCorrelate Error: can not figure out deltaTime\n"); |
96 |
+ |
painCave.isFatal = 1; |
97 |
+ |
simError(); |
98 |
+ |
} |
99 |
|
|
100 |
|
int nframes = bsMan_->getNFrames(); |
101 |
< |
nTimeBins_ = nframes; /**@todo Fixed Me */ |
101 |
> |
nTimeBins_ = nframes; |
102 |
|
histogram_.resize(nTimeBins_); |
103 |
|
count_.resize(nTimeBins_); |
104 |
+ |
time_.resize(nTimeBins_); |
105 |
|
|
106 |
< |
//deltaTime_ = info_->; |
106 |
> |
for (int i = 0; i < nTimeBins_; ++i) { |
107 |
> |
time_[i] = i * deltaTime_; |
108 |
> |
} |
109 |
> |
|
110 |
|
} |
111 |
|
|
112 |
|
|
183 |
|
int j; |
184 |
|
StuntDouble* sd1; |
185 |
|
StuntDouble* sd2; |
186 |
< |
for (sd1 = seleMan1_.beginSelected(i), (sd2 = seleMan2_.beginSelected(j); sd1 != NULL && sd2 != NULL; |
187 |
< |
sd1 = seleMan1_.nextSelected(i) sd2 = seleMan2_.nextSelected(j)) { |
186 |
> |
for (sd1 = seleMan1_.beginSelected(i), sd2 = seleMan2_.beginSelected(j); sd1 != NULL && sd2 != NULL; |
187 |
> |
sd1 = seleMan1_.nextSelected(i), sd2 = seleMan2_.nextSelected(j)) { |
188 |
> |
|
189 |
|
double corrVal = calcCorrVal(sd1, frame1, sd2, frame2); |
190 |
|
histogram_[timeBin] += corrVal; |
191 |
|
} |
239 |
|
void CorrelationFunction::postCorrelate() { |
240 |
|
for (int i =0 ; i < nTimeBins_; ++i) { |
241 |
|
if (count_[i] > 0) { |
242 |
< |
histogram_[i] / = count_[i]; |
242 |
> |
histogram_[i] /= count_[i]; |
243 |
|
} |
244 |
|
} |
245 |
|
} |
251 |
|
if (ofs.is_open()) { |
252 |
|
|
253 |
|
ofs << "#" << getCorrFuncType() << "\n"; |
254 |
< |
ofs << "#selection script1: \"" << selectionScript1_ <<"\"\tselection script2: \"" selectionScript2_ << "\"\n"; |
254 |
> |
ofs << "#selection script1: \"" << selectionScript1_ <<"\"\tselection script2: \"" << selectionScript2_ << "\"\n"; |
255 |
|
ofs << "#extra information: " << extra_ << "\n"; |
256 |
|
ofs << "#time\tcorrVal\n"; |
257 |
|
|