seams_output.hpp
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------------
2 // d-SEAMS - Deferred Structural Elucidation Analysis for Molecular Simulations
3 //
4 // Copyright (c) 2018--present d-SEAMS core team
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the MIT License as published by
8 // the Open Source Initiative.
9 //
10 // A copy of the MIT License is included in the LICENSE file of this repository.
11 // You should have received a copy of the MIT License along with this program.
12 // If not, see <https://opensource.org/licenses/MIT>.
13 //-----------------------------------------------------------------------------------
14 
15 #ifndef __SEAMS_OUTPUT_H_
16 #define __SEAMS_OUTPUT_H_
17 
18 #include <bond.hpp>
19 #include <cage.hpp>
20 #include <errno.h> // errno, ENOENT, EEXIST
21 #include <generic.hpp>
22 #include <iostream>
23 #include <memory>
24 #include <mol_sys.hpp>
25 #include <sys/stat.h> // stat
26 #if defined(_WIN32)
27 #include <direct.h> // _mkdir
28 #endif
29 
30 // Boost
31 #include "boost/filesystem/operations.hpp"
32 #include "boost/filesystem/path.hpp"
33 namespace fs = boost::filesystem;
34 // #include <filesystem>
35 // namespace fs = std::filesystem;
36 
37 namespace sout {
38 
44 inline bool isDirExist(const std::string &path) {
45 #if defined(_WIN32)
46  struct _stat info;
47  if (_stat(path.c_str(), &info) != 0) {
48  return false;
49  }
50  return (info.st_mode & _S_IFDIR) != 0;
51 #else
52  struct stat info;
53  if (stat(path.c_str(), &info) != 0) {
54  return false;
55  }
56  return (info.st_mode & S_IFDIR) != 0;
57 #endif
58 }
59 
64 inline int makePath(const std::string &path) {
65 #if defined(_WIN32)
66  int ret = _mkdir(path.c_str());
67 #else
68  mode_t mode = 0755;
69  int ret = mkdir(path.c_str(), mode);
70 #endif
71  if (ret == 0)
72  return 0;
73 
74  switch (errno) {
75  case ENOENT:
76  // parent didn't exist, try to create it
77  {
78  int pos = path.find_last_of('/');
79  if (pos == std::string::npos)
80 #if defined(_WIN32)
81  pos = path.find_last_of('\\');
82  if (pos == std::string::npos)
83 #endif
84  return 1;
85  if (!makePath(path.substr(0, pos)))
86  return 1;
87  }
88 // now, try to create again
89 #if defined(_WIN32)
90  return 0 == _mkdir(path.c_str());
91 #else
92  return 0 == mkdir(path.c_str(), mode);
93 #endif
94 
95  case EEXIST:
96  // done!
97  if (isDirExist(path)) {
98  return 0;
99  } else {
100  return 1;
101  }
102 
103  default:
104  return 1;
105  }
106 }
107 
110  std::string filename = "rings.dat");
111 
114 int writePrismNum(std::string path, std::vector<int> nPrisms,
115  std::vector<int> nDefPrisms,
116  std::vector<double> heightPercent, int maxDepth,
117  int currentFrame, int firstFrame);
118 
121 int writeRingNum(std::string path, int currentFrame, std::vector<int> nRings,
122  std::vector<double> coverageAreaXY,
123  std::vector<double> coverageAreaXZ,
124  std::vector<double> coverageAreaYZ, int maxDepth,
125  int firstFrame);
126 
129 int writeRingNumBulk(std::string path, int currentFrame, std::vector<int> nRings, int maxDepth,
130  int firstFrame);
131 
133 int printRDF(std::string fileName, std::vector<double> *rdfValues,
134  double binwidth, int nbin);
135 
138 int writeTopoBulkData(std::string path, int currentFrame, int numHC, int numDDC,
139  int mixedRings, int basalRings, int prismaticRings,
140  int firstFrame);
141 
143 int writePrisms(std::vector<int> *basal1, std::vector<int> *basal2,
144  int prismNum,
145  molSys::PointCloud<molSys::Point<double>, double> *yCloud);
146 
148 int writeClusterStats(std::string path, int currentFrame, int largestCluster,
149  int numOfClusters, int smallestCluster,
150  double avgClusterSize, int firstFrame);
151 
155 
159 
164  std::string filename = "system-rings.data");
165 
168  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
169  std::vector<double> rmsdPerAtom, std::vector<int> atomTypes, int maxDepth,
170  std::string path);
171 
175  molSys::PointCloud<molSys::Point<double>, double> *yCloud, std::string path);
176 
179  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
180  std::vector<double> rmsdPerAtom, std::vector<int> atomTypes,
181  std::string path, int firstFrame);
182 
185  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
187  int maxDepth, std::string path, bool doShapeMatching = false);
188 
191  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
193  int maxDepth, std::string path, bool isMonolayer = true);
194 
198  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
200  std::string path, bool bondsBetweenDummy = false);
201 
204  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
205  std::vector<std::vector<int>> rings, bool useBondFile, std::string bondFile,
207  std::string filename = "system-prisms.data");
208 
212  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
214  cage::cageType type, int numCages,
215  std::string filename = "system-cages.data");
216 
222  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
223  int currentFrame);
224 
226 int writeEachCage(std::vector<int> currentCage, int cageNum,
228  molSys::PointCloud<molSys::Point<double>, double> *yCloud);
229 
231 int writeBasalRingsHex(std::vector<int> currentCage, int cageNum,
234 
237  std::vector<int> *basal1, std::vector<int> *basal2, int prismNum,
239  molSys::PointCloud<molSys::Point<double>, double> *yCloud, bool isDeformed);
240 
243  std::string path, std::string outFile);
244 
249 
252  std::string fileName = "cluster.txt", bool isSlice = false,
253  int largestIceCluster = 0);
254 
257  molSys::PointCloud<molSys::Point<double>, double> *yCloud,
258  std::vector<int> atoms, int clusterID, cage::cageType type);
259 } // namespace sout
260 #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:54
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:40
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 writeMoleculeIDsInSlice(std::string path, molSys::PointCloud< molSys::Point< double >, double > *yCloud)
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 writeRingNumBulk(std::string path, int currentFrame, std::vector< int > nRings, int maxDepth, int firstFrame)
int writeLAMMPSdumpSlice(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::string path)
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 writeLAMMPSdataAllRings(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> nList, std::vector< int > atomTypes, int maxDepth, std::string path, bool isMonolayer=true)
Write a data file for rings of every type for a monolayer.
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 printRDF(std::string fileName, std::vector< double > *rdfValues, double binwidth, int nbin)
Function for printing out the RDF, given the filename.
int writeMoleculeIDsExpressionSelectOVITO(std::string path, molSys::PointCloud< molSys::Point< double >, double > *yCloud)
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:170
This contains per-particle information.
Definition: mol_sys.hpp:149
T substr(T... args)