26 inpFile = std::make_unique<std::ifstream>(filename);
33 std::cout <<
"Fatal Error: The bond file does not exist or you gave the "
45 if (inpFile->is_open()) {
56 for (
int i = 0; i < tokens.
size(); i++) {
75 xyzFile = std::make_unique<std::ifstream>(filename);
84 double xLo, xHi, yLo, yHi, zLo,
89 <<
"Fatal Error: The file does not exist or you gave the wrong path.\n";
105 if (xyzFile->is_open()) {
127 if (tokens.
size() == 0) {
133 iPoint.
molID = iatom;
154 if (iPoint.
x < xLo) {
157 else if (iPoint.
x > xHi) {
160 else if (iPoint.
y < yLo) {
163 else if (iPoint.
y > yHi) {
166 else if (iPoint.
z < zLo) {
169 else if (iPoint.
z > zHi) {
186 yCloud.
box.push_back(xHi - xLo);
187 yCloud.
box.push_back(yHi - yLo);
188 yCloud.
box.push_back(zHi - zLo);
191 std::cout <<
"Atoms didn't get filled in properly.\n";
217 dumpFile = std::make_unique<std::ifstream>(filename);
222 int currentFrame = 0;
226 bool readNOP =
false;
227 bool readBox =
false;
228 bool readAtoms =
false;
229 int xIndex, yIndex, zIndex,
234 xIndex = yIndex = zIndex = typeIndex = -1;
235 bool isTriclinic =
false;
239 <<
"Fatal Error: The file does not exist or you gave the wrong path.\n";
255 if (dumpFile->is_open()) {
264 if (tokens[0].compare(
"ITEM:") == 0) {
265 if (tokens[1].compare(
"TIMESTEP") == 0) {
273 if (currentFrame == targetFrame) {
297 if (tokens[0].compare(
"ITEM:") == 0) {
298 if (tokens[1].compare(
"TIMESTEP") == 0) {
308 yCloud->pts.reserve(nop);
314 if (tokens[0].compare(
"ITEM:") == 0) {
320 for (
int k = 0; k < tilt.
size(); k++) {
321 yCloud->box.push_back(tilt[k]);
327 yCloud->box.push_back(numbers[1] - numbers[0]);
328 yCloud->boxLow.push_back(
331 if (numbers.
size() == 3) {
339 iPoint.
type = numbers[typeIndex];
340 iPoint.
molID = numbers[molIndex];
341 iPoint.
atomID = numbers[atomIndex];
342 iPoint.
x = numbers[xIndex];
343 iPoint.
y = numbers[yIndex];
344 iPoint.
z = numbers[zIndex];
349 coordLow, coordHigh);
351 yCloud->pts.push_back(iPoint);
352 yCloud->idIndexMap[iPoint.
atomID] = yCloud->pts.size() - 1;
357 if (tokens[0].compare(
"ITEM:") == 0) {
358 if (tokens[1].compare(
"NUMBER") == 0) {
362 if (tokens[0].compare(
"ITEM:") == 0) {
363 if (tokens[1].compare(
"BOX") == 0) {
367 if (tokens[0].compare(
"ITEM:") == 0) {
368 if (tokens[1].compare(
"ATOMS") == 0) {
371 for (
int i = 2; i < tokens.
size(); i++) {
372 if (tokens[i].compare(
"type") == 0) {
375 if (tokens[i].compare(
"x") == 0) {
378 if (tokens[i].compare(
"y") == 0) {
381 if (tokens[i].compare(
"z") == 0) {
384 if (tokens[i].compare(
"mol") == 0) {
387 if (tokens[i].compare(
"id") == 0) {
392 molIndex = atomIndex;
404 std::cout <<
"You entered a frame that doesn't exist.\n";
407 if (yCloud->pts.size() != yCloud->nop) {
408 std::cout <<
"Atoms didn't get filled in properly.\n";
411 yCloud->currentFrame = targetFrame;
436 dumpFile = std::make_unique<std::ifstream>(filename);
441 int currentFrame = 0;
445 bool readNOP =
false;
446 bool readBox =
false;
447 bool readAtoms =
false;
448 int xIndex, yIndex, zIndex,
453 xIndex = yIndex = zIndex = typeIndex = -1;
454 bool isTriclinic =
false;
459 <<
"Fatal Error: The file does not exist or you gave the wrong path.\n";
475 if (dumpFile->is_open()) {
484 if (tokens[0].compare(
"ITEM:") == 0) {
485 if (tokens[1].compare(
"TIMESTEP") == 0) {
493 if (currentFrame == targetFrame) {
517 if (tokens[0].compare(
"ITEM:") == 0) {
518 if (tokens[1].compare(
"TIMESTEP") == 0) {
532 if (tokens[0].compare(
"ITEM:") == 0) {
538 for (
int k = 0; k < tilt.
size(); k++) {
539 yCloud->box.push_back(tilt[k]);
545 yCloud->box.push_back(numbers[1] - numbers[0]);
546 yCloud->boxLow.push_back(
549 if (numbers.
size() == 3) {
557 iPoint.
type = numbers[typeIndex];
558 iPoint.
molID = numbers[molIndex];
559 iPoint.
atomID = numbers[atomIndex];
560 iPoint.
x = numbers[xIndex];
561 iPoint.
y = numbers[yIndex];
562 iPoint.
z = numbers[zIndex];
567 coordLow, coordHigh);
570 if (iPoint.
type == typeO) {
573 yCloud->pts.push_back(iPoint);
574 yCloud->idIndexMap[iPoint.
atomID] = yCloud->pts.size() - 1;
580 if (tokens[0].compare(
"ITEM:") == 0) {
581 if (tokens[1].compare(
"NUMBER") == 0) {
585 if (tokens[0].compare(
"ITEM:") == 0) {
586 if (tokens[1].compare(
"BOX") == 0) {
590 if (tokens[0].compare(
"ITEM:") == 0) {
591 if (tokens[1].compare(
"ATOMS") == 0) {
594 for (
int i = 2; i < tokens.
size(); i++) {
595 if (tokens[i].compare(
"type") == 0) {
598 if (tokens[i].compare(
"x") == 0) {
601 if (tokens[i].compare(
"y") == 0) {
604 if (tokens[i].compare(
"z") == 0) {
607 if (tokens[i].compare(
"mol") == 0) {
610 if (tokens[i].compare(
"id") == 0) {
615 molIndex = atomIndex;
627 std::cout <<
"You entered a frame that doesn't exist.\n";
630 yCloud->nop = yCloud->pts.size();
631 if (yCloud->pts.size() != nOxy) {
632 std::cout <<
"Atoms didn't get filled in properly.\n";
635 yCloud->currentFrame = targetFrame;
662 dumpFile = std::make_unique<std::ifstream>(filename);
667 int currentFrame = 0;
671 bool readNOP =
false;
672 bool readBox =
false;
673 bool readAtoms =
false;
674 int xIndex, yIndex, zIndex,
679 xIndex = yIndex = zIndex = typeIndex = -1;
680 bool isTriclinic =
false;
685 <<
"Fatal Error: The file does not exist or you gave the wrong path.\n";
701 if (dumpFile->is_open()) {
710 if (tokens[0].compare(
"ITEM:") == 0) {
711 if (tokens[1].compare(
"TIMESTEP") == 0) {
719 if (currentFrame == targetFrame) {
743 if (tokens[0].compare(
"ITEM:") == 0) {
744 if (tokens[1].compare(
"TIMESTEP") == 0) {
758 if (tokens[0].compare(
"ITEM:") == 0) {
764 for (
int k = 0; k < tilt.
size(); k++) {
765 yCloud->box.push_back(tilt[k]);
771 yCloud->box.push_back(numbers[1] - numbers[0]);
772 yCloud->boxLow.push_back(
775 if (numbers.
size() == 3) {
783 iPoint.
type = numbers[typeIndex];
784 iPoint.
molID = numbers[molIndex];
785 iPoint.
atomID = numbers[atomIndex];
786 iPoint.
x = numbers[xIndex];
787 iPoint.
y = numbers[yIndex];
788 iPoint.
z = numbers[zIndex];
793 coordLow, coordHigh);
800 if (iPoint.
type == typeI) {
803 yCloud->pts.push_back(iPoint);
804 yCloud->idIndexMap[iPoint.
atomID] =
805 yCloud->pts.size() - 1;
811 if (tokens[0].compare(
"ITEM:") == 0) {
812 if (tokens[1].compare(
"NUMBER") == 0) {
816 if (tokens[0].compare(
"ITEM:") == 0) {
817 if (tokens[1].compare(
"BOX") == 0) {
821 if (tokens[0].compare(
"ITEM:") == 0) {
822 if (tokens[1].compare(
"ATOMS") == 0) {
825 for (
int i = 2; i < tokens.
size(); i++) {
826 if (tokens[i].compare(
"type") == 0) {
829 if (tokens[i].compare(
"x") == 0) {
832 if (tokens[i].compare(
"y") == 0) {
835 if (tokens[i].compare(
"z") == 0) {
838 if (tokens[i].compare(
"mol") == 0) {
841 if (tokens[i].compare(
"id") == 0) {
846 molIndex = atomIndex;
858 std::cout <<
"You entered a frame that doesn't exist.\n";
862 yCloud->nop = yCloud->pts.size();
865 yCloud->currentFrame = targetFrame;
File for containing generic or common functions.
bool file_exists(const std::string &name)
Function for checking if a file exists or not.
std::vector< std::string > tokenizer(std::string line)
Function for tokenizing line strings into words (strings) delimited by whitespace....
std::vector< double > tokenizerDouble(std::string line)
Function for tokenizing line strings into a vector of doubles.
T x
type ID, molID, atomID
int nop
Current frame number.
bool inSlice
Type of ice/water etc based on cij.
std::unordered_map< int, int > idIndexMap
xlo, ylo, zlo
std::vector< T > box
Number of atoms.
molSys::PointCloud< molSys::Point< double >, double > clearPointCloud(molSys::PointCloud< molSys::Point< double >, double > *yCloud)
//! Function for clearing vectors in PointCloud after multiple usage
molSys::PointCloud< molSys::Point< double >, double > readLammpsTrj(std::string filename, int targetFrame, molSys::PointCloud< molSys::Point< double >, double > *yCloud, bool isSlice=false, std::array< double, 3 > coordLow=std::array< double, 3 >{0, 0, 0}, std::array< double, 3 > coordHigh=std::array< double, 3 >{0, 0, 0})
molSys::PointCloud< molSys::Point< double >, double > readLammpsTrjreduced(std::string filename, int targetFrame, molSys::PointCloud< molSys::Point< double >, double > *yCloud, int typeI, bool isSlice=false, std::array< double, 3 > coordLow=std::array< double, 3 >{0, 0, 0}, std::array< double, 3 > coordHigh=std::array< double, 3 >{0, 0, 0})
molSys::PointCloud< molSys::Point< double >, double > readLammpsTrjO(std::string filename, int targetFrame, molSys::PointCloud< molSys::Point< double >, double > *yCloud, int typeO, bool isSlice=false, std::array< double, 3 > coordLow=std::array< double, 3 >{0, 0, 0}, std::array< double, 3 > coordHigh=std::array< double, 3 >{0, 0, 0})
molSys::PointCloud< molSys::Point< double >, double > readXYZ(std::string filename)
Function for reading in atom coordinates from an XYZ file.
bool atomInSlice(double x, double y, double z, std::array< double, 3 > coordLow, std::array< double, 3 > coordHigh)
std::vector< std::vector< int > > readBonds(std::string filename)
Reads bonds into a vector of vectors from a file with a specific format.
This contains a collection of points; contains information for a particular frame.
This contains per-particle information.