# | Line 40 | Line 40 | |
---|---|---|
40 | */ | |
41 | #include <algorithm> | |
42 | #include "brains/BlockSnapshotManager.hpp" | |
43 | < | #include "utlis/physmem.h" |
43 | > | #include "utils/physmem.h" |
44 | #include "brains/SimInfo.hpp" | |
45 | #include "io/DumpReader.hpp" | |
46 | ||
47 | namespace oopse { | |
48 | < | BlockSnapshotManager::BlockSnapshotManager(SimInfo* info, const std::string& filename, |
48 | > | BlockSnapshotMananger::BlockSnapshotMananger(SimInfo* info, const std::string& filename, |
49 | int storageLayout, int blockCapacity) | |
50 | < | : SnapshotManager(storageLayout), info_(info), |
51 | < | blockCapacity_(blockCapacity), activeBlocks(blockCapacity_, -1) { |
50 | > | : SnapshotManager(storageLayout), info_(info), blockCapacity_(blockCapacity), activeBlocks_(blockCapacity_, -1) { |
51 | ||
52 | nAtoms_ = info->getNGlobalAtoms(); | |
53 | nRigidBodies_ = info->getNGlobalRigidBodies(); | |
# | Line 57 | Line 56 | BlockSnapshotManager::BlockSnapshotManager(SimInfo* in | |
56 | ||
57 | int bytesPerStuntDouble = DataStorage::getBytesPerStuntDouble(storageLayout); | |
58 | ||
59 | < | int bytesPerFrame = nStuntDoubles * bytesPerStuntDouble; |
59 | > | int bytesPerFrame = (nRigidBodies_ + nAtoms_) * bytesPerStuntDouble; |
60 | ||
61 | int frameCapacity = int (avalPhysMem / bytesPerFrame); | |
62 | ||
63 | nSnapshotPerBlock_ = frameCapacity /blockCapacity_ ; | |
64 | ||
65 | reader_ = new DumpReader(info, filename); | |
66 | < | nframes_ = reader->getNFrames(); |
66 | > | nframes_ = reader_->getNFrames(); |
67 | ||
68 | < | int nblocks = nframes / nSnapshotPerBlock_; |
69 | < | if (nframes % nSnapshotPerBlock != 0) { |
68 | > | int nblocks = nframes_ / nSnapshotPerBlock_; |
69 | > | if (nframes_ % nSnapshotPerBlock_ != 0) { |
70 | ++nblocks; | |
71 | } | |
72 | ||
# | Line 75 | Line 74 | BlockSnapshotManager::BlockSnapshotManager(SimInfo* in | |
74 | blocks_.push_back(SnapshotBlock(i, (i+1)*nSnapshotPerBlock_); | |
75 | } | |
76 | //the last block may not have nSnapshotPerBlock frames, we need to consider this special situation | |
77 | < | blocks.back.second = nframes; |
77 | > | blocks_.back.second = nframes_; |
78 | ||
79 | < | snapshots_.insert(snapshot_.begin(), nframes, NULL); |
79 | > | snapshots_.insert(snapshots_.begin(), nframes_, NULL); |
80 | ||
81 | } | |
82 | ||
# | Line 149 | Line 148 | Snapshot* BlockSnapshotManager::loadFrame(int frame){ | |
148 | return snapshot; | |
149 | } | |
150 | ||
151 | + | int BlockSnapshotManager::getNFrames() { |
152 | + | return reader_->getNFrames(); |
153 | } | |
154 | + | |
155 | + | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |