seams_output.hpp
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------------
2 // d-SEAMS is free software: you can redistribute it and/or modify
3 // it under the terms of the GNU General Public License as published by
4 // the Free Software Foundation, either version 3 of the License, or
5 // (at your option) any later version.
6 //
7 // A copy of the GNU General Public License is available at
8 // http://www.gnu.org/licenses/
9 //-----------------------------------------------------------------------------------
10 
11 #ifndef __SEAMS_OUTPUT_H_
12 #define __SEAMS_OUTPUT_H_
13 
14 #include <bond.hpp>
15 #include <cage.hpp>
16 #include <errno.h> // errno, ENOENT, EEXIST
17 #include <generic.hpp>
18 #include <iostream>
19 #include <memory>
20 #include <mol_sys.hpp>
21 #include <sys/stat.h> // stat
22 #if defined(_WIN32)
23 #include <direct.h> // _mkdir
24 #endif
25 
26 // Boost
27 #include "boost/filesystem/operations.hpp"
28 #include "boost/filesystem/path.hpp"
29 namespace fs = boost::filesystem;
30 // #include <filesystem>
31 // namespace fs = std::filesystem;
32 
33 namespace sout {
34 
40 inline bool isDirExist(const std::string &path) {
41 #if defined(_WIN32)
42  struct _stat info;
43  if (_stat(path.c_str(), &info) != 0) {
44  return false;
45  }
46  return (info.st_mode & _S_IFDIR) != 0;
47 #else
48  struct stat info;
49  if (stat(path.c_str(), &info) != 0) {
50  return false;
51  }
52  return (info.st_mode & S_IFDIR) != 0;
53 #endif
54 }
55 
60 inline int makePath(const std::string &path) {
61 #if defined(_WIN32)
62  int ret = _mkdir(path.c_str());
63 #else
64  mode_t mode = 0755;
65  int ret = mkdir(path.c_str(), mode);
66 #endif
67  if (ret == 0)
68  return 0;
69 
70  switch (errno) {
71  case ENOENT:
72  // parent didn't exist, try to create it
73  {
74  int pos = path.find_last_of('/');
75  if (pos == std::string::npos)
76 #if defined(_WIN32)
77  pos = path.find_last_of('\\');
78  if (pos == std::string::npos)
79 #endif
80  return 1;
81  if (!makePath(path.substr(0, pos)))
82  return 1;
83  }
84 // now, try to create again
85 #if defined(_WIN32)
86  return 0 == _mkdir(path.c_str());
87 #else
88  return 0 == mkdir(path.c_str(), mode);
89 #endif
90 
91  case EEXIST:
92  // done!
93  if (isDirExist(path)) {
94  return 0;
95  } else {
96  return 1;
97  }
98 
99  default:
100  return 1;
101  }
102 }
103 
106  std::string filename = "rings.dat");
107 
110 int writePrismNum(std::string path, std::vector<int> nPrisms,
111  std::vector<int> nDefPrisms,
112  std::vector<double> heightPercent, int maxDepth,
113  int currentFrame, int firstFrame);
114 
117 int writeRingNum(std::string path, int currentFrame, std::vector<int> nRings,
118  std::vector<double> coverageAreaXY,
119  std::vector<double> coverageAreaXZ,
120  std::vector<double> coverageAreaYZ, int maxDepth,
121  int firstFrame);
122 
124 int printRDF(std::string fileName, std::vector<double> *rdfValues,
125  double binwidth, int nbin);
126 
129 int writeTopoBulkData(std::string path, int currentFrame, int numHC, int numDDC,
130  int mixedRings, int basalRings, int prismaticRings,
131  int firstFrame);
132 
134 int writePrisms(std::vector<int> *basal1, std::vector<int> *basal2,
135  int prismNum,
136  molSys::PointCloud<molSys::Point<double>, double> *yCloud);
137 
139 int writeClusterStats(std::string path, int currentFrame, int largestCluster,
140  int numOfClusters, int smallestCluster,
141  double avgClusterSize, int firstFrame);
142 
147  std::string filename = "system-rings.data");
148 
151  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
152  std::vector<double> rmsdPerAtom, std::vector<int> atomTypes, int maxDepth,
153  std::string path);
154 
157  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
158  std::vector<double> rmsdPerAtom, std::vector<int> atomTypes,
159  std::string path, int firstFrame);
160 
163  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
165  int maxDepth, std::string path, bool doShapeMatching = false);
166 
169  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
171  int maxDepth, std::string path);
172 
176  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
178  std::string path, bool bondsBetweenDummy = false);
179 
182  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
183  std::vector<std::vector<int>> rings, bool useBondFile, std::string bondFile,
185  std::string filename = "system-prisms.data");
186 
190  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
192  cage::cageType type, int numCages,
193  std::string filename = "system-cages.data");
194 
200  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
201  int currentFrame);
202 
204 int writeEachCage(std::vector<int> currentCage, int cageNum,
206  molSys::PointCloud<molSys::Point<double>, double> *yCloud);
207 
209 int writeBasalRingsHex(std::vector<int> currentCage, int cageNum,
212 
215  std::vector<int> *basal1, std::vector<int> *basal2, int prismNum,
217  molSys::PointCloud<molSys::Point<double>, double> *yCloud, bool isDeformed);
218 
221  std::string path, std::string outFile);
222 
227 
230  std::string fileName = "cluster.txt", bool isSlice = false,
231  int largestIceCluster = 0);
232 
235  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
236  std::vector<int> atoms, int clusterID, cage::cageType type);
237 } // namespace sout
238 #endif // __SEAMS_OUTPUT_H_
File for bond-related analyses (hydrogen bonds, bonded atoms for data file write-outs etc....
T c_str(T... args)
File for cage types for topological network criteria.
T find_last_of(T... args)
File for containing generic or common functions.
cageType
Definition: cage.hpp:50
int largestIceCluster(std::string path, molSys::PointCloud< molSys::Point< double >, double > *yCloud, molSys::PointCloud< molSys::Point< double >, double > *iceCloud, std::vector< std::vector< int >> nList, std::vector< bool > *isIce, std::vector< int > *clusterID, std::vector< int > *nClusters, std::unordered_map< int, int > *indexNumber, int firstFrame)
Finds the largest ice cluster.
Definition: cluster.cpp:36
The main molecular system handler.
int writeBasalRingsPrism(std::vector< int > *basal1, std::vector< int > *basal2, int prismNum, std::vector< std::vector< int >> nList, molSys::PointCloud< molSys::Point< double >, double > *yCloud, bool isDeformed)
Write out the basal rings for a particular prism.
int writeLAMMPSdata(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> rings, std::vector< std::vector< int >> bonds, std::string filename="system-rings.data")
Write a data file for rings.
int writeAllCages(std::string path, std::vector< cage::Cage > *cageList, std::vector< std::vector< int >> rings, std::vector< std::vector< int >> nList, molSys::PointCloud< molSys::Point< double >, double > *yCloud, int currentFrame)
int writePrismNum(std::string path, std::vector< int > nPrisms, std::vector< int > nDefPrisms, std::vector< double > heightPercent, int maxDepth, int currentFrame, int firstFrame)
int writeRingNum(std::string path, int currentFrame, std::vector< int > nRings, std::vector< double > coverageAreaXY, std::vector< double > coverageAreaXZ, std::vector< double > coverageAreaYZ, int maxDepth, int firstFrame)
bool isDirExist(const std::string &path)
int makePath(const std::string &path)
int writeLAMMPSdataCages(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> rings, std::vector< cage::Cage > *cageList, cage::cageType type, int numCages, std::string filename="system-cages.data")
int writeTopoBulkData(std::string path, int currentFrame, int numHC, int numDDC, int mixedRings, int basalRings, int prismaticRings, int firstFrame)
int writeDump(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::string path, std::string outFile)
Generic function for writing out to a dump file.
int writeLAMMPSdumpINT(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< double > rmsdPerAtom, std::vector< int > atomTypes, int maxDepth, std::string path)
Write out a LAMMPS dump file containing the RMSD per atom.
int writeBasalRingsHex(std::vector< int > currentCage, int cageNum, std::vector< std::vector< int >> nList, std::vector< std::vector< int >> rings)
Write out the basal rings of a particular Hexagonal cage.
int writePrisms(std::vector< int > *basal1, std::vector< int > *basal2, int prismNum, molSys::PointCloud< molSys::Point< double >, double > *yCloud)
Function for writing out each prism.
int writeLAMMPSdataAllRings(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> nList, std::vector< int > atomTypes, int maxDepth, std::string path)
Write a data file for rings of every type for a monolayer.
int printRDF(std::string fileName, std::vector< double > *rdfValues, double binwidth, int nbin)
Function for printing out the RDF, given the filename.
int writeLAMMPSdataPrisms(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> rings, bool useBondFile, std::string bondFile, std::vector< int > listPrism, std::vector< std::vector< int >> nList, std::string filename="system-prisms.data")
Write a data file for prisms of a single type.
int writeLAMMPSdataTopoBulk(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> nList, std::vector< cage::iceType > atomTypes, std::string path, bool bondsBetweenDummy=false)
int writeRings(std::vector< std::vector< int >> rings, std::string filename="rings.dat")
Function for printing out ring info, when there is no volume slice.
int writeLAMMPSdumpCages(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< double > rmsdPerAtom, std::vector< int > atomTypes, std::string path, int firstFrame)
Write out a LAMMPS dump file containing the RMSD per atom for bulk ice.
int writeXYZcluster(std::string path, molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< int > atoms, int clusterID, cage::cageType type)
Function for writing out the XYZ files for each cluster.
int writeLAMMPSdataAllPrisms(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> nList, std::vector< int > atomTypes, int maxDepth, std::string path, bool doShapeMatching=false)
Write a data file for prisms of every type.
int writeEachCage(std::vector< int > currentCage, int cageNum, cage::cageType type, std::vector< std::vector< int >> rings, molSys::PointCloud< molSys::Point< double >, double > *yCloud)
Write out a particular cage to a file.
int writeCluster(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::string fileName="cluster.txt", bool isSlice=false, int largestIceCluster=0)
Function for printing the largest ice cluster.
int writeClusterStats(std::string path, int currentFrame, int largestCluster, int numOfClusters, int smallestCluster, double avgClusterSize, int firstFrame)
Function for writing out cluster statistics.
int writeHisto(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> nList, std::vector< double > avgQ6)
This contains a collection of points; contains information for a particular frame.
Definition: mol_sys.hpp:166
This contains per-particle information.
Definition: mol_sys.hpp:145
T substr(T... args)