mol_sys.cpp
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 #include <iostream>
12 #include <memory>
13 #include <mol_sys.hpp>
14 
21  molSys::PointCloud<molSys::Point<double>, double> *yCloud) {
22  //
24  std::vector<double> tempBox;
25  //
26  std::vector<double> tempBox1;
27 
28  tempPts.swap(yCloud->pts);
29  tempBox.swap(yCloud->box);
30  tempBox1.swap(yCloud->boxLow);
31  yCloud->idIndexMap.clear();
32 
33  return *yCloud;
34 }
35 
41  molSys::PointCloud<molSys::Point<double>, double> *yCloud) {
43  idMolIDmap; // atom IDs as keys and mol IDs as values
44  int iatomMolID; // molID of the current iatom
45  int iatomID; // atom ID of the current iatom
46 
47  // Loop through the atoms in yCloud
48  for (int iatom = 0; iatom < yCloud->nop; iatom++) {
49  iatomID = yCloud->pts[iatom].atomID; // atom ID
50  iatomMolID = yCloud->pts[iatom].molID; // molecular ID
51  // Update the unordered map
52  idMolIDmap[iatomID] = iatomMolID;
53  } // end of loop through every iatom in pointCloud
54 
55  return idMolIDmap;
56 }
57 
64  molSys::PointCloud<molSys::Point<double>, double> *oCloud) {
66  hMolList; // the first column contains the molecular IDs, and the next
67  // two elements in the row are the hydrogen bond atoms in the
68  // molecule
69  int iMolID; // Current molecular ID
70  int nHatoms; // No. of h atoms found for a particular molID.
71 
72  for (int iatom = 0; iatom < oCloud->nop; iatom++) {
73  // Get the molID
74  iMolID = oCloud->pts[iatom].molID;
75 
76  hMolList.push_back(std::vector<int>()); // Empty vector for the index iatom
77  // Fill the first element with the molecular ID
78  hMolList[iatom].push_back(iMolID);
79 
80  nHatoms = 0; // init (no. of h atoms for the particular molID)
81 
82  // Now search through the hydrogen atom pointCloud for this particular molID
83  for (int jatom = 0; jatom < hCloud->nop; jatom++) {
84  if (hCloud->pts[jatom].molID == iMolID) {
85  hMolList[iatom].push_back(jatom); // fill the hatom index
86  nHatoms++;
87  // If the two hydrogens have been found, break out of the loop
88  if (nHatoms == 2) {
89  break;
90  } // end of break
91  } // end of check to see if jatom is part of iMolID
92  } // end of loop through the hydrogen atom pointCloud
93  } // end of looping through every oxygen atom
94 
95  return hMolList;
96 } // end of function
97 
105  int molIDtoFind) {
106  int index = -1; // init invalid index
107 
108  for (int iatom = 0; iatom < molList.size(); iatom++) {
109  // If the molecular ID is equal, return the index in the array
110  if (molList[iatom][0] == molIDtoFind) {
111  index = iatom;
112  return index;
113  } // end of check
114  } // end of looping through iatom
115 
116  return index;
117 }
std::vector< std::vector< int > > hAtomMolList(molSys::PointCloud< molSys::Point< double >, double > *hCloud, molSys::PointCloud< molSys::Point< double >, double > *oCloud)
Definition: mol_sys.cpp:62
std::unordered_map< int, int > createIDMolIDmap(molSys::PointCloud< molSys::Point< double >, double > *yCloud)
Definition: mol_sys.cpp:40
int searchMolList(std::vector< std::vector< int >> molList, int molIDtoFind)
Definition: mol_sys.cpp:104
molSys::PointCloud< molSys::Point< double >, double > clearPointCloud(molSys::PointCloud< molSys::Point< double >, double > *yCloud)
//! Function for clearing vectors in PointCloud after multiple usage
Definition: mol_sys.cpp:20
The main molecular system handler.
T push_back(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
T swap(T... args)