ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/brains/DataStorage.cpp
(Generate patch)

Comparing branches/development/src/brains/DataStorage.cpp (file contents):
Revision 1465 by chuckv, Fri Jul 9 23:08:25 2010 UTC vs.
Revision 1808 by gezelter, Mon Oct 22 20:42:10 2012 UTC

# Line 36 | Line 36
36   * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37   * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38   * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
39 < * [4]  Vardeman & Gezelter, in progress (2009).                        
39 > * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 > * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43   /**
44   * @file DataStorage.cpp
45   * @author tlin
46   * @date 10/26/2004
46 * @time 11:56am
47   * @version 1.0
48   */
49  
50   #include "brains/DataStorage.hpp"
51 <
51 > using namespace std;
52   namespace OpenMD {
53  
54    DataStorage::DataStorage() : size_(0), storageLayout_(0){
# Line 64 | Line 64 | namespace OpenMD {
64  
65      if (storageLayout_ & dslPosition && position.size() != size_) {
66        //error
67 <      std::cerr << "size does not match"<< std::endl;
67 >      cerr << "size does not match"<< endl;
68      }
69  
70      if (storageLayout_ & dslVelocity && velocity.size() != size_) {
71        //error
72 <      std::cerr << "size does not match"<< std::endl;        
72 >      cerr << "size does not match"<< endl;        
73      }
74  
75 +    if (storageLayout_ & dslForce && force.size() != size_) {
76 +      //error
77 +      cerr << "size does not match"<< endl;        
78 +    }
79 +
80      if (storageLayout_ & dslAmat && aMat.size() != size_) {
81        //error
82 <      std::cerr << "size does not match"<< std::endl;        
82 >      cerr << "size does not match"<< endl;        
83      }
84  
85      if (storageLayout_ & dslAngularMomentum && angularMomentum.size() != size_) {
86        //error
87 <      std::cerr << "size does not match"<< std::endl;        
87 >      cerr << "size does not match"<< endl;        
88      }
89  
90 <    if (storageLayout_ & dslElectroFrame && electroFrame.size() != size_) {
90 >    if (storageLayout_ & dslTorque && torque.size() != size_) {
91        //error
92 <      std::cerr << "size does not match"<< std::endl;        
92 >      cerr << "size does not match"<< endl;        
93      }
94  
95 <    if (storageLayout_ & dslZAngle && zAngle.size() != size_) {
95 >    if (storageLayout_ & dslParticlePot && particlePot.size() != size_) {
96        //error
97 <      std::cerr << "size does not match"<< std::endl;        
97 >      cerr << "size does not match"<< endl;        
98      }
99  
100 <    if (storageLayout_ & dslForce && force.size() != size_) {
100 >    if (storageLayout_ & dslDensity && density.size() != size_) {
101        //error
102 <      std::cerr << "size does not match"<< std::endl;        
102 >      cerr << "size does not match"<< endl;        
103      }
104  
105 <    if (storageLayout_ & dslTorque && torque.size() != size_) {
105 >    if (storageLayout_ & dslFunctional && functional.size() != size_) {
106        //error
107 <      std::cerr << "size does not match"<< std::endl;        
107 >      cerr << "size does not match"<< endl;        
108      }
109 <    if (storageLayout_ & dslParticlePot && particlePot.size() != size_) {
109 >
110 >    if (storageLayout_ & dslFunctionalDerivative && functionalDerivative.size() != size_) {
111        //error
112 <      std::cerr << "size does not match"<< std::endl;        
112 >      cerr << "size does not match"<< endl;        
113      }
114 +
115 +    if (storageLayout_ & dslDipole && dipole.size() != size_) {
116 +      //error
117 +      cerr << "size does not match"<< endl;        
118 +    }
119 +
120 +    if (storageLayout_ & dslQuadrupole && quadrupole.size() != size_) {
121 +      //error
122 +      cerr << "size does not match"<< endl;        
123 +    }
124 +
125 +    if (storageLayout_ & dslElectricField && electricField.size() != size_) {
126 +      //error
127 +      cerr << "size does not match"<< endl;        
128 +    }
129 +
130 +    if (storageLayout_ & dslSkippedCharge && skippedCharge.size() != size_) {
131 +      //error
132 +      cerr << "size does not match"<< endl;        
133 +    }
134 +
135 +    if (storageLayout_ & dslFlucQPosition && flucQPos.size() != size_) {
136 +      //error
137 +      cerr << "size does not match"<< endl;        
138 +    }
139 +
140 +    if (storageLayout_ & dslFlucQVelocity && flucQVel.size() != size_) {
141 +      //error
142 +      cerr << "size does not match"<< endl;        
143 +    }
144 +
145 +    if (storageLayout_ & dslFlucQForce && flucQFrc.size() != size_) {
146 +      //error
147 +      cerr << "size does not match"<< endl;        
148 +    }
149      
150      return size_;
151  
# Line 120 | Line 161 | namespace OpenMD {
161        internalResize(velocity, newSize);
162      }
163  
164 +    if (storageLayout_ & dslForce) {
165 +      internalResize(force, newSize);
166 +    }
167 +
168      if (storageLayout_ & dslAmat) {
169        internalResize(aMat, newSize);
170      }
# Line 127 | Line 172 | namespace OpenMD {
172      if (storageLayout_ & dslAngularMomentum) {
173        internalResize(angularMomentum, newSize);
174      }
175 +    
176 +    if (storageLayout_ & dslTorque) {
177 +      internalResize(torque, newSize);
178 +    }
179  
180 <    if (storageLayout_ & dslElectroFrame) {
181 <      internalResize(electroFrame, newSize);
180 >    if (storageLayout_ & dslParticlePot) {
181 >      internalResize(particlePot, newSize);
182      }
183 <    
184 <    if (storageLayout_ & dslZAngle) {
185 <      internalResize(zAngle, newSize);
183 >
184 >    if (storageLayout_ & dslDensity) {
185 >      internalResize(density, newSize);
186      }
187  
188 <    if (storageLayout_ & dslForce) {
189 <      internalResize(force, newSize);
188 >    if (storageLayout_ & dslFunctional) {
189 >      internalResize(functional, newSize);
190      }
191  
192 <    if (storageLayout_ & dslTorque) {
193 <      internalResize(torque, newSize);
192 >    if (storageLayout_ & dslFunctionalDerivative) {
193 >      internalResize(functionalDerivative, newSize);
194      }
195  
196 <    if (storageLayout_ & dslParticlePot) {
197 <      internalResize(particlePot, newSize);
196 >    if (storageLayout_ & dslDipole) {
197 >      internalResize(dipole, newSize);
198      }
199  
200 +    if (storageLayout_ & dslQuadrupole) {
201 +      internalResize(quadrupole, newSize);
202 +    }
203 +
204 +    if (storageLayout_ & dslElectricField) {
205 +      internalResize(electricField, newSize);
206 +    }
207 +
208 +    if (storageLayout_ & dslSkippedCharge) {
209 +      internalResize(skippedCharge, newSize);
210 +    }
211 +
212 +    if (storageLayout_ & dslFlucQPosition) {
213 +      internalResize(flucQPos, newSize);
214 +    }
215 +
216 +    if (storageLayout_ & dslFlucQVelocity) {
217 +      internalResize(flucQVel, newSize);
218 +    }
219 +
220 +    if (storageLayout_ & dslFlucQForce) {
221 +      internalResize(flucQFrc, newSize);
222 +    }
223 +
224      size_ = newSize;
225    }
226  
# Line 160 | Line 233 | namespace OpenMD {
233        velocity.reserve(size);
234      }
235  
236 +    if (storageLayout_ & dslForce) {
237 +      force.reserve(size);
238 +    }
239 +
240      if (storageLayout_ & dslAmat) {
241        aMat.reserve(size);
242      }
# Line 168 | Line 245 | namespace OpenMD {
245        angularMomentum.reserve(size);
246      }
247  
171    if (storageLayout_ & dslElectroFrame) {
172      electroFrame.reserve(size);
173    }
174    
175    if (storageLayout_ & dslZAngle) {
176      zAngle.reserve(size);
177    }
178
179    if (storageLayout_ & dslForce) {
180      force.reserve(size);
181    }
182
248      if (storageLayout_ & dslTorque) {
249        torque.reserve(size);
250      }
251      
252      if (storageLayout_ & dslParticlePot) {
253        particlePot.reserve(size);
254 +    }
255 +
256 +    if (storageLayout_ & dslDensity) {
257 +      density.reserve(size);
258 +    }
259 +
260 +    if (storageLayout_ & dslFunctional) {
261 +      functional.reserve(size);
262 +    }
263 +
264 +    if (storageLayout_ & dslFunctionalDerivative) {
265 +      functionalDerivative.reserve(size);
266 +    }
267 +
268 +    if (storageLayout_ & dslDipole) {
269 +      dipole.reserve(size);
270 +    }
271 +
272 +    if (storageLayout_ & dslQuadrupole) {
273 +      quadrupole.reserve(size);
274 +    }
275 +
276 +    if (storageLayout_ & dslElectricField) {
277 +      electricField.reserve(size);
278 +    }
279 +
280 +    if (storageLayout_ & dslSkippedCharge) {
281 +      skippedCharge.reserve(size);
282      }
283  
284 +    if (storageLayout_ & dslFlucQPosition) {
285 +      flucQPos.reserve(size);
286 +    }
287 +
288 +    if (storageLayout_ & dslFlucQVelocity) {
289 +      flucQVel.reserve(size);
290 +    }
291 +
292 +    if (storageLayout_ & dslFlucQForce) {
293 +      flucQFrc.reserve(size);
294 +    }
295    }
296  
297    void DataStorage::copy(int source, int num, int target) {
# Line 203 | Line 307 | namespace OpenMD {
307        internalCopy(velocity, source, num, target);
308      }
309  
310 +    if (storageLayout_ & dslForce) {
311 +      internalCopy(force, source, num, target);
312 +    }
313 +
314      if (storageLayout_ & dslAmat) {
315        internalCopy(aMat, source, num, target);
316      }
# Line 211 | Line 319 | namespace OpenMD {
319        internalCopy(angularMomentum, source, num, target);
320      }
321  
214    if (storageLayout_ & dslElectroFrame) {
215      internalCopy(electroFrame, source, num, target);
216    }
217    
218    if (storageLayout_ & dslZAngle) {
219      internalCopy(zAngle, source, num, target);
220    }
221
222    if (storageLayout_ & dslForce) {
223      internalCopy(force, source, num, target);
224    }
225
322      if (storageLayout_ & dslTorque) {
323        internalCopy(torque, source, num, target);
324      }
# Line 230 | Line 326 | namespace OpenMD {
326      if (storageLayout_ & dslParticlePot) {
327        internalCopy(particlePot, source, num, target);
328      }
233    
329  
330 +    if (storageLayout_ & dslDensity) {
331 +      internalCopy(density, source, num, target);
332 +    }
333 +
334 +    if (storageLayout_ & dslFunctional) {
335 +      internalCopy(functional, source, num, target);
336 +    }
337 +
338 +    if (storageLayout_ & dslFunctionalDerivative) {
339 +      internalCopy(functionalDerivative, source, num, target);
340 +    }
341 +
342 +    if (storageLayout_ & dslDipole) {
343 +      internalCopy(dipole, source, num, target);
344 +    }
345 +
346 +    if (storageLayout_ & dslQuadrupole) {
347 +      internalCopy(quadrupole, source, num, target);
348 +    }
349 +
350 +    if (storageLayout_ & dslElectricField) {
351 +      internalCopy(electricField, source, num, target);
352 +    }
353 +
354 +    if (storageLayout_ & dslSkippedCharge) {
355 +      internalCopy(skippedCharge, source, num, target);
356 +    }
357 +
358 +    if (storageLayout_ & dslFlucQPosition) {
359 +      internalCopy(flucQPos, source, num, target);
360 +    }
361 +
362 +    if (storageLayout_ & dslFlucQVelocity) {
363 +      internalCopy(flucQVel, source, num, target);
364 +    }
365 +    if (storageLayout_ & dslFlucQForce) {
366 +      internalCopy(flucQFrc, source, num, target);
367 +    }
368    }
369  
370    int DataStorage::getStorageLayout() {
# Line 254 | Line 387 | namespace OpenMD {
387        return internalGetArrayPointer(velocity);
388        break;
389              
390 +    case dslForce:
391 +      return internalGetArrayPointer(force);
392 +      break;            
393 +
394      case dslAmat:
395        return internalGetArrayPointer(aMat);
396        break;            
# Line 262 | Line 399 | namespace OpenMD {
399        return internalGetArrayPointer(angularMomentum);
400        break;
401              
265    case dslElectroFrame:
266      return internalGetArrayPointer(electroFrame);
267      break;
268            
269    case dslZAngle:
270      return internalGetArrayPointer(zAngle);
271      break;
272
273    case dslForce:
274      return internalGetArrayPointer(force);
275      break;            
276
402      case dslTorque:
403        return internalGetArrayPointer(torque);
404        break;
# Line 281 | Line 406 | namespace OpenMD {
406      case dslParticlePot:
407        return internalGetArrayPointer(particlePot);
408        break;
409 <            
409 >
410 >    case dslDensity:
411 >      return internalGetArrayPointer(density);
412 >      break;
413 >
414 >    case dslFunctional:
415 >      return internalGetArrayPointer(functional);
416 >      break;
417 >
418 >    case dslFunctionalDerivative:
419 >      return internalGetArrayPointer(functionalDerivative);
420 >      break;
421 >
422 >    case dslDipole:
423 >      return internalGetArrayPointer(dipole);
424 >      break;
425 >
426 >    case dslQuadrupole:
427 >      return internalGetArrayPointer(quadrupole);
428 >      break;
429 >
430 >    case dslElectricField:
431 >      return internalGetArrayPointer(electricField);
432 >      break;
433 >
434 >    case dslSkippedCharge:
435 >      return internalGetArrayPointer(skippedCharge);
436 >      break;
437 >
438 >    case dslFlucQPosition:
439 >      return internalGetArrayPointer(flucQPos);
440 >      break;
441 >
442 >    case dslFlucQVelocity:
443 >      return internalGetArrayPointer(flucQVel);
444 >      break;
445 >          
446 >    case dslFlucQForce:
447 >      return internalGetArrayPointer(flucQFrc);
448 >      break;
449 >          
450      default:
451        //error message
452        return NULL;
# Line 297 | Line 462 | namespace OpenMD {
462      }
463    }
464  
465 <  RealType* DataStorage::internalGetArrayPointer(std::vector<RotMat3x3d>& v) {
465 >  RealType* DataStorage::internalGetArrayPointer(std::vector<Mat3x3d>& v) {
466      if (v.size() == 0) {
467        return NULL;
468      } else {
# Line 357 | Line 522 | namespace OpenMD {
522      if (layout & dslVelocity) {
523        bytes += sizeof(Vector3d);
524      }
525 +    if (layout & dslForce) {
526 +      bytes += sizeof(Vector3d);
527 +    }
528      if (layout & dslAmat) {
529        bytes += sizeof(RotMat3x3d);    
530      }
531      if (layout & dslAngularMomentum) {
532        bytes += sizeof(Vector3d);
533      }
534 <    if (layout & dslElectroFrame) {
535 <      bytes += sizeof(Mat3x3d);
534 >    if (layout & dslTorque) {
535 >      bytes += sizeof(Vector3d);
536      }
537 <    if (layout & dslZAngle) {
537 >    if (layout & dslParticlePot) {
538        bytes += sizeof(RealType);
539      }
540 <    if (layout & dslForce) {
540 >    if (layout & dslDensity) {
541 >      bytes += sizeof(RealType);
542 >    }
543 >    if (layout & dslFunctional) {
544 >      bytes += sizeof(RealType);
545 >    }
546 >    if (layout & dslFunctionalDerivative) {
547 >      bytes += sizeof(RealType);
548 >    }
549 >    if (layout & dslDipole) {
550        bytes += sizeof(Vector3d);
551      }
552 <    if (layout & dslTorque) {
552 >    if (layout & dslQuadrupole) {
553 >      bytes += sizeof(Mat3x3d);
554 >    }
555 >    if (layout & dslElectricField) {
556        bytes += sizeof(Vector3d);
557      }
558 <    if (layout & dslParticlePot) {
558 >    if (layout & dslSkippedCharge) {
559        bytes += sizeof(RealType);
560      }
561 +    if (layout & dslFlucQPosition) {
562 +      bytes += sizeof(RealType);
563 +    }
564 +    if (layout & dslFlucQVelocity) {
565 +      bytes += sizeof(RealType);
566 +    }
567 +    if (layout & dslFlucQForce) {
568 +      bytes += sizeof(RealType);
569 +    }
570 +
571      return bytes;
572    }
573  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines