Changeset 6f1551 for molecuilder/src
- Timestamp:
- Sep 28, 2009, 6:38:06 PM (16 years ago)
- Children:
- 606dfb
- Parents:
- c03ca6
- Location:
- molecuilder/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/linkedcell.cpp
rc03ca6 r6f1551 96 96 //cout << Verbose(2) << *Walker << " goes into cell " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl; 97 97 set->GoToNext(); 98 } 99 cout << "done." << endl; 100 cout << Verbose(1) << "End of LinkedCell" << endl; 101 }; 102 103 104 /** Puts all atoms in \a *mol into a linked cell list with cell's lengths of \a RADIUS 105 * \param *set LCNodeSet class with all LCNode's 106 * \param RADIUS edge length of cells 107 */ 108 LinkedCell::LinkedCell(LinkedNodes *set, double radius) 109 { 110 class TesselPoint *Walker = NULL; 111 RADIUS = radius; 112 LC = NULL; 113 for(int i=0;i<NDIM;i++) 114 N[i] = 0; 115 index = -1; 116 max.Zero(); 117 min.Zero(); 118 cout << Verbose(1) << "Begin of LinkedCell" << endl; 119 if (set->empty()) { 120 cerr << "ERROR: set contains no linked cell nodes!" << endl; 121 return; 122 } 123 // 1. find max and min per axis of atoms 124 LinkedNodes::iterator Runner = set->begin(); 125 for (int i=0;i<NDIM;i++) { 126 max.x[i] = (*Runner)->node->x[i]; 127 min.x[i] = (*Runner)->node->x[i]; 128 } 129 for (LinkedNodes::iterator Runner = set->begin(); Runner != set->end(); Runner++) { 130 Walker = *Runner; 131 for (int i=0;i<NDIM;i++) { 132 if (max.x[i] < Walker->node->x[i]) 133 max.x[i] = Walker->node->x[i]; 134 if (min.x[i] > Walker->node->x[i]) 135 min.x[i] = Walker->node->x[i]; 136 } 137 } 138 cout << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl; 139 140 // 2. find then number of cells per axis 141 for (int i=0;i<NDIM;i++) { 142 N[i] = (int)floor((max.x[i] - min.x[i])/RADIUS)+1; 143 } 144 cout << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl; 145 146 // 3. allocate the lists 147 cout << Verbose(2) << "Allocating cells ... "; 148 if (LC != NULL) { 149 cout << Verbose(1) << "ERROR: Linked Cell list is already allocated, I do nothing." << endl; 150 return; 151 } 152 LC = new LinkedNodes[N[0]*N[1]*N[2]]; 153 for (index=0;index<N[0]*N[1]*N[2];index++) { 154 LC [index].clear(); 155 } 156 cout << "done." << endl; 157 158 // 4. put each atom into its respective cell 159 cout << Verbose(2) << "Filling cells ... "; 160 for (LinkedNodes::iterator Runner = set->begin(); Runner != set->end(); Runner++) { 161 Walker = *Runner; 162 for (int i=0;i<NDIM;i++) { 163 n[i] = (int)floor((Walker->node->x[i] - min.x[i])/RADIUS); 164 } 165 index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2]; 166 LC[index].push_back(Walker); 167 //cout << Verbose(2) << *Walker << " goes into cell " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl; 98 168 } 99 169 cout << "done." << endl; -
molecuilder/src/linkedcell.hpp
rc03ca6 r6f1551 44 44 LinkedCell(); 45 45 LinkedCell(PointCloud *set, double RADIUS); 46 LinkedCell(LinkedNodes *set, double radius); 46 47 ~LinkedCell(); 47 48 LinkedNodes* GetCurrentCell();
Note:
See TracChangeset
for help on using the changeset viewer.