| 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(); | 
| 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 | 
  | 
     | 
| 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 | 
  | 
 |