48#include "io/ZConsReader.hpp"
51#include "utils/simError.h"
55 ZConsReader::ZConsReader(
SimInfo* info) : info_(info) {
56 std::string zconsFileName_ =
57 getPrefix(info_->getFinalConfigFileName()) +
".fz";
58 istream_.open(zconsFileName_.c_str());
61 std::cerr <<
"open " << zconsFileName_ <<
"error" << std::endl;
65 Globals* simParam = info_->getSimParams();
66 int nZconstraints = simParam->getNZconsStamps();
67 std::vector<ZConsStamp*> stamp = simParam->getZconsStamps();
68 for (
int i = 0; i < nZconstraints; i++) {
69 allZmols_.push_back(stamp[i]->getMolIndex());
73 void ZConsReader::readNextFrame() {
74 char line[MAXBUFFERSIZE];
78 fixedZmolData_.clear();
80 while (istream_.getline(line, MAXBUFFERSIZE) && line[0] ==
'/' &&
83 sscanfCount = sscanf(line,
"%lf", &curTime_);
84 if (sscanfCount != 1) {
85 std::cerr <<
"ZConsReader Error : reading file error" << std::endl;
89 istream_.getline(line, MAXBUFFERSIZE);
90 sscanfCount = sscanf(line,
"%d", &nFixedZmol);
91 if (sscanfCount != 1) {
92 std::cerr <<
"ZConsReader Error : reading file error" << std::endl;
97 for (
int i = 0; i < nFixedZmol; i++) {
98 istream_.getline(line, MAXBUFFERSIZE);
99 sscanfCount = sscanf(line,
"%d\t%lf\t%lf\t%lf", &data.zmolIndex,
100 &data.zforce, &data.zpos, &data.zconsPos);
101 if (sscanfCount != 4) {
102 std::cerr <<
"ZConsReader Error : reading file error" << std::endl;
106 fixedZmolData_.push_back(data);
110 bool ZConsReader::hasNextFrame() {
111 return istream_.peek() != EOF ? true :
false;
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
std::string getPrefix(const std::string &str)