topo_two_dim.cpp
Go to the documentation of this file.
1 #include <topo_two_dim.hpp>
2 
3 // -----------------------------------------------------------------------------------------------------
4 // MONOLAYER ALGORITHMS
5 // -----------------------------------------------------------------------------------------------------
6 
40  molSys::PointCloud<molSys::Point<double>, double> *yCloud, int maxDepth,
41  double sheetArea, int firstFrame) {
42  //
44  ringsOneType; // Vector of vectors of rings of a single size
45  int nRings; // Number of rings of the current type
46  std::vector<int> nRingList; // Vector of the values of the number of prisms
47  // for a particular frame
48  std::vector<double> coverageAreaXY; // Coverage area percent on the XY plane
49  // for a particular n and frame
50  std::vector<double> coverageAreaXZ; // Coverage area percent on the XZ plane
51  // for a particular n and frame
52  std::vector<double> coverageAreaYZ; // Coverage area percent on the YZ plane
53  // for a particular n and frame
54  std::vector<double> singleAreas; // Coverage area on the XY, XZ and YZ planes
55  // for a single ring
57  atomTypes; // contains int values for each prism type considered
58  // -------------------------------------------------------------------------------
59  // Init
60  nRingList.resize(
61  maxDepth -
62  2); // Has a value for every value of ringSize from 3, upto maxDepth
63  coverageAreaXY.resize(maxDepth - 2);
64  coverageAreaXZ.resize(maxDepth - 2);
65  coverageAreaYZ.resize(maxDepth - 2);
66  // The atomTypes vector is the same size as the pointCloud atoms
67  atomTypes.resize(yCloud->nop, 1); // The dummy or unclassified value is 1
68  // -------------------------------------------------------------------------------
69  // Run this loop for rings of sizes upto maxDepth
70  // The smallest possible ring is of size 3
71  for (int ringSize = 3; ringSize <= maxDepth; ringSize++) {
72  // Clear ringsOneType
73  ring::clearRingList(ringsOneType);
74  // Get rings of the current ring size
75  ringsOneType = ring::getSingleRingSize(rings, ringSize);
76  //
77  // Continue if there are zero rings of ringSize
78  if (ringsOneType.size() == 0) {
79  nRingList[ringSize - 3] = 0; // Update the number of prisms
80  // Update the coverage area%
81  coverageAreaXY[ringSize - 3] = 0.0;
82  coverageAreaXZ[ringSize - 3] = 0.0;
83  coverageAreaYZ[ringSize - 3] = 0.0;
84  continue;
85  } // skip if there are no rings
86  //
87  // -------------
88  // Number of rings with n nodes
89  nRings = ringsOneType.size();
90  // -------------
91  // Now that you have rings of a certain size:
92  nRingList[ringSize - 3] = nRings; // Update the number of n-membered rings
93  // Update the coverage area% for the n-membered ring phase.
94  singleAreas = topoparam::calcCoverageArea(yCloud, ringsOneType, sheetArea);
95  // XY plane
96  coverageAreaXY[ringSize - 3] = singleAreas[0];
97  // XZ plane
98  coverageAreaXZ[ringSize - 3] = singleAreas[1];
99  // YZ plane
100  coverageAreaYZ[ringSize - 3] = singleAreas[2];
101  // -------------
102  } // end of loop through every possible ringSize
103 
104  // Get the atom types for all the ring types
105  ring::assignPolygonType(rings, &atomTypes, nRingList);
106 
107  // Write out the ring information
108  sout::writeRingNum(path, yCloud->currentFrame, nRingList, coverageAreaXY,
109  coverageAreaXZ, coverageAreaYZ, maxDepth, firstFrame);
110  // Write out the lammps data file for the particular frame
111  sout::writeLAMMPSdataAllRings(yCloud, nList, atomTypes, maxDepth, path);
112 
113  return 0;
114 }
115 
126  std::vector<int> *atomTypes,
127  std::vector<int> nRings) {
128  // Every value in listPrism corresponds to an index in rings.
129  // Every ring contains atom indices, corresponding to the indices (not atom
130  // IDs) in rings
131  int iring; // Index of current ring
132  int iatom; // Index of current atom
133  int ringSize; // Ring size of the current ring
134  int prevRingSize; // Ring size previously assigned to a point
135 
136  // Dummy value corresponds to a value of 1.
137  // If an atom is shared by more than one ring type, it is assigned the
138  // value 2.
139 
140  // Loop through every ring in rings
141  for (int iring = 0; iring < rings.size(); iring++) {
142  ringSize = rings[iring].size();
143  // Loop through every element in iring
144  for (int j = 0; j < ringSize; j++) {
145  iatom = rings[iring][j]; // Atom index
146  // Update the atom type
147  if ((*atomTypes)[iatom] == 1) {
148  (*atomTypes)[iatom] = ringSize;
149  } // The atom is unclassified
150  else {
151  // Only update the ring type if the number is higher
152  prevRingSize = (*atomTypes)[iatom]; // Previously assigned ring size
153  if (ringSize > prevRingSize) {
154  (*atomTypes)[iatom] = ringSize;
155  } // end of assigning the new ring size
156  } // only update if the number is higher
157  } // end of loop through every atom in iring
158  } // end of loop through every ring
159 
160  return 0;
161 } // end of function
int clearRingList(std::vector< std::vector< int >> &rings)
Erases memory for a vector of vectors for a list of rings.
Definition: ring.cpp:18
int polygonRingAnalysis(std::string path, std::vector< std::vector< int >> rings, std::vector< std::vector< int >> nList, molSys::PointCloud< molSys::Point< double >, double > *yCloud, int maxDepth, double sheetArea, int firstFrame)
int assignPolygonType(std::vector< std::vector< int >> rings, std::vector< int > *atomTypes, std::vector< int > nRings)
std::vector< std::vector< int > > getSingleRingSize(std::vector< std::vector< int >> rings, int ringSize)
Returns a vector of vectors of rings of a single size.
Definition: ring.cpp:149
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)
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.
std::vector< double > calcCoverageArea(molSys::PointCloud< molSys::Point< double >, double > *yCloud, std::vector< std::vector< int >> rings, double sheetArea)
T resize(T... args)
T size(T... args)
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