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

Comparing trunk/src/brains/DataStorage.cpp (file contents):
Revision 1245 by chuckv, Tue May 27 16:39:06 2008 UTC vs.
Revision 1993 by gezelter, Tue Apr 29 17:32:31 2014 UTC

# Line 6 | Line 6
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8   *
9 < * 1. Acknowledgement of the program authors must be made in any
10 < *    publication of scientific results based in part on use of the
11 < *    program.  An acceptable form of acknowledgement is citation of
12 < *    the article in which the program was described (Matthew
13 < *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 < *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 < *    Parallel Simulation Engine for Molecular Dynamics,"
16 < *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 < *
18 < * 2. Redistributions of source code must retain the above copyright
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
35 + *                                                                      
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, 234107 (2008).          
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 + using namespace std;
52 + namespace OpenMD {
53  
52 namespace oopse {
53
54    DataStorage::DataStorage() : size_(0), storageLayout_(0){
55  
56    }
# Line 64 | Line 64 | namespace oopse {
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 +    if (storageLayout_ & dslSitePotential && sitePotential.size() != size_) {
151 +      //error
152 +      cerr << "size does not match"<< endl;        
153 +    }
154      
155      return size_;
156  
# Line 120 | Line 166 | namespace oopse {
166        internalResize(velocity, newSize);
167      }
168  
169 +    if (storageLayout_ & dslForce) {
170 +      internalResize(force, newSize);
171 +    }
172 +
173      if (storageLayout_ & dslAmat) {
174        internalResize(aMat, newSize);
175      }
# Line 127 | Line 177 | namespace oopse {
177      if (storageLayout_ & dslAngularMomentum) {
178        internalResize(angularMomentum, newSize);
179      }
180 +    
181 +    if (storageLayout_ & dslTorque) {
182 +      internalResize(torque, newSize);
183 +    }
184  
185 <    if (storageLayout_ & dslElectroFrame) {
186 <      internalResize(electroFrame, newSize);
185 >    if (storageLayout_ & dslParticlePot) {
186 >      internalResize(particlePot, newSize);
187      }
188 <    
189 <    if (storageLayout_ & dslZAngle) {
190 <      internalResize(zAngle, newSize);
188 >
189 >    if (storageLayout_ & dslDensity) {
190 >      internalResize(density, newSize);
191      }
192  
193 <    if (storageLayout_ & dslForce) {
194 <      internalResize(force, newSize);
193 >    if (storageLayout_ & dslFunctional) {
194 >      internalResize(functional, newSize);
195      }
196  
197 <    if (storageLayout_ & dslTorque) {
198 <      internalResize(torque, newSize);
197 >    if (storageLayout_ & dslFunctionalDerivative) {
198 >      internalResize(functionalDerivative, newSize);
199      }
200  
201 <    if (storageLayout_ & dslParticlePot) {
202 <      internalResize(particlePot, newSize);
201 >    if (storageLayout_ & dslDipole) {
202 >      internalResize(dipole, newSize);
203      }
204  
205 +    if (storageLayout_ & dslQuadrupole) {
206 +      internalResize(quadrupole, newSize);
207 +    }
208 +
209 +    if (storageLayout_ & dslElectricField) {
210 +      internalResize(electricField, newSize);
211 +    }
212 +
213 +    if (storageLayout_ & dslSkippedCharge) {
214 +      internalResize(skippedCharge, newSize);
215 +    }
216 +
217 +    if (storageLayout_ & dslFlucQPosition) {
218 +      internalResize(flucQPos, newSize);
219 +    }
220 +
221 +    if (storageLayout_ & dslFlucQVelocity) {
222 +      internalResize(flucQVel, newSize);
223 +    }
224 +
225 +    if (storageLayout_ & dslFlucQForce) {
226 +      internalResize(flucQFrc, newSize);
227 +    }
228 +
229 +    if (storageLayout_ & dslSitePotential) {
230 +      internalResize(sitePotential, newSize);
231 +    }
232 +
233      size_ = newSize;
234    }
235  
# Line 160 | Line 242 | namespace oopse {
242        velocity.reserve(size);
243      }
244  
245 +    if (storageLayout_ & dslForce) {
246 +      force.reserve(size);
247 +    }
248 +
249      if (storageLayout_ & dslAmat) {
250        aMat.reserve(size);
251      }
# Line 168 | Line 254 | namespace oopse {
254        angularMomentum.reserve(size);
255      }
256  
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
257      if (storageLayout_ & dslTorque) {
258        torque.reserve(size);
259      }
# Line 188 | Line 262 | namespace oopse {
262        particlePot.reserve(size);
263      }
264  
265 +    if (storageLayout_ & dslDensity) {
266 +      density.reserve(size);
267 +    }
268 +
269 +    if (storageLayout_ & dslFunctional) {
270 +      functional.reserve(size);
271 +    }
272 +
273 +    if (storageLayout_ & dslFunctionalDerivative) {
274 +      functionalDerivative.reserve(size);
275 +    }
276 +
277 +    if (storageLayout_ & dslDipole) {
278 +      dipole.reserve(size);
279 +    }
280 +
281 +    if (storageLayout_ & dslQuadrupole) {
282 +      quadrupole.reserve(size);
283 +    }
284 +
285 +    if (storageLayout_ & dslElectricField) {
286 +      electricField.reserve(size);
287 +    }
288 +
289 +    if (storageLayout_ & dslSkippedCharge) {
290 +      skippedCharge.reserve(size);
291 +    }
292 +
293 +    if (storageLayout_ & dslFlucQPosition) {
294 +      flucQPos.reserve(size);
295 +    }
296 +
297 +    if (storageLayout_ & dslFlucQVelocity) {
298 +      flucQVel.reserve(size);
299 +    }
300 +
301 +    if (storageLayout_ & dslFlucQForce) {
302 +      flucQFrc.reserve(size);
303 +    }
304 +
305 +    if (storageLayout_ & dslSitePotential) {
306 +      sitePotential.reserve(size);
307 +    }
308    }
309  
310    void DataStorage::copy(int source, int num, int target) {
# Line 203 | Line 320 | namespace oopse {
320        internalCopy(velocity, source, num, target);
321      }
322  
323 +    if (storageLayout_ & dslForce) {
324 +      internalCopy(force, source, num, target);
325 +    }
326 +
327      if (storageLayout_ & dslAmat) {
328        internalCopy(aMat, source, num, target);
329      }
# Line 211 | Line 332 | namespace oopse {
332        internalCopy(angularMomentum, source, num, target);
333      }
334  
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
335      if (storageLayout_ & dslTorque) {
336        internalCopy(torque, source, num, target);
337      }
# Line 230 | Line 339 | namespace oopse {
339      if (storageLayout_ & dslParticlePot) {
340        internalCopy(particlePot, source, num, target);
341      }
233    
342  
343 +    if (storageLayout_ & dslDensity) {
344 +      internalCopy(density, source, num, target);
345 +    }
346 +
347 +    if (storageLayout_ & dslFunctional) {
348 +      internalCopy(functional, source, num, target);
349 +    }
350 +
351 +    if (storageLayout_ & dslFunctionalDerivative) {
352 +      internalCopy(functionalDerivative, source, num, target);
353 +    }
354 +
355 +    if (storageLayout_ & dslDipole) {
356 +      internalCopy(dipole, source, num, target);
357 +    }
358 +
359 +    if (storageLayout_ & dslQuadrupole) {
360 +      internalCopy(quadrupole, source, num, target);
361 +    }
362 +
363 +    if (storageLayout_ & dslElectricField) {
364 +      internalCopy(electricField, source, num, target);
365 +    }
366 +
367 +    if (storageLayout_ & dslSkippedCharge) {
368 +      internalCopy(skippedCharge, source, num, target);
369 +    }
370 +
371 +    if (storageLayout_ & dslFlucQPosition) {
372 +      internalCopy(flucQPos, source, num, target);
373 +    }
374 +
375 +    if (storageLayout_ & dslFlucQVelocity) {
376 +      internalCopy(flucQVel, source, num, target);
377 +    }
378 +    if (storageLayout_ & dslFlucQForce) {
379 +      internalCopy(flucQFrc, source, num, target);
380 +    }
381 +
382 +    if (storageLayout_ & dslSitePotential) {
383 +      internalCopy(sitePotential, source, num, target);
384 +    }
385    }
386  
387    int DataStorage::getStorageLayout() {
# Line 248 | Line 398 | namespace oopse {
398      switch (whichArray) {
399      case dslPosition:
400        return internalGetArrayPointer(position);
251      break;
401              
402      case dslVelocity:
403        return internalGetArrayPointer(velocity);
255      break;
404              
405 +    case dslForce:
406 +      return internalGetArrayPointer(force);
407 +
408      case dslAmat:
409        return internalGetArrayPointer(aMat);
259      break;            
410              
411      case dslAngularMomentum:
412        return internalGetArrayPointer(angularMomentum);
263      break;
413              
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
414      case dslTorque:
415        return internalGetArrayPointer(torque);
279      break;
416  
417      case dslParticlePot:
418        return internalGetArrayPointer(particlePot);
419 <      break;
420 <            
419 >
420 >    case dslDensity:
421 >      return internalGetArrayPointer(density);
422 >
423 >    case dslFunctional:
424 >      return internalGetArrayPointer(functional);
425 >
426 >    case dslFunctionalDerivative:
427 >      return internalGetArrayPointer(functionalDerivative);
428 >
429 >    case dslDipole:
430 >      return internalGetArrayPointer(dipole);
431 >
432 >    case dslQuadrupole:
433 >      return internalGetArrayPointer(quadrupole);
434 >
435 >    case dslElectricField:
436 >      return internalGetArrayPointer(electricField);
437 >
438 >    case dslSkippedCharge:
439 >      return internalGetArrayPointer(skippedCharge);
440 >
441 >    case dslFlucQPosition:
442 >      return internalGetArrayPointer(flucQPos);
443 >
444 >    case dslFlucQVelocity:
445 >      return internalGetArrayPointer(flucQVel);
446 >          
447 >    case dslFlucQForce:
448 >      return internalGetArrayPointer(flucQFrc);
449 >          
450 >    case dslSitePotential:
451 >      return internalGetArrayPointer(sitePotential);
452 >          
453      default:
454        //error message
455        return NULL;
288
456      }
457    }    
458  
459    RealType* DataStorage::internalGetArrayPointer(std::vector<Vector3d>& v) {
460 <    if (v.size() == 0) {
460 >    if (v.empty()) {
461        return NULL;
462      } else {
463        return v[0].getArrayPointer();
464      }
465    }
466  
467 <  RealType* DataStorage::internalGetArrayPointer(std::vector<RotMat3x3d>& v) {
468 <    if (v.size() == 0) {
467 >  RealType* DataStorage::internalGetArrayPointer(std::vector<Mat3x3d>& v) {
468 >    if (v.empty()) {
469        return NULL;
470      } else {
471        return v[0].getArrayPointer();
# Line 307 | Line 474 | namespace oopse {
474    }
475  
476    RealType* DataStorage::internalGetArrayPointer(std::vector<RealType>& v) {
477 <    if (v.size() == 0) {
477 >    if (v.empty()) {
478        return NULL;
479      } else {
480        return &(v[0]);
# Line 357 | Line 524 | namespace oopse {
524      if (layout & dslVelocity) {
525        bytes += sizeof(Vector3d);
526      }
527 +    if (layout & dslForce) {
528 +      bytes += sizeof(Vector3d);
529 +    }
530      if (layout & dslAmat) {
531        bytes += sizeof(RotMat3x3d);    
532      }
533      if (layout & dslAngularMomentum) {
534        bytes += sizeof(Vector3d);
535      }
536 <    if (layout & dslElectroFrame) {
537 <      bytes += sizeof(Mat3x3d);
536 >    if (layout & dslTorque) {
537 >      bytes += sizeof(Vector3d);
538      }
539 <    if (layout & dslZAngle) {
539 >    if (layout & dslParticlePot) {
540        bytes += sizeof(RealType);
541      }
542 <    if (layout & dslForce) {
542 >    if (layout & dslDensity) {
543 >      bytes += sizeof(RealType);
544 >    }
545 >    if (layout & dslFunctional) {
546 >      bytes += sizeof(RealType);
547 >    }
548 >    if (layout & dslFunctionalDerivative) {
549 >      bytes += sizeof(RealType);
550 >    }
551 >    if (layout & dslDipole) {
552        bytes += sizeof(Vector3d);
553      }
554 <    if (layout & dslTorque) {
554 >    if (layout & dslQuadrupole) {
555 >      bytes += sizeof(Mat3x3d);
556 >    }
557 >    if (layout & dslElectricField) {
558        bytes += sizeof(Vector3d);
559      }
560 <    if (layout & dslParticlePot) {
560 >    if (layout & dslSkippedCharge) {
561        bytes += sizeof(RealType);
562      }
563 +    if (layout & dslFlucQPosition) {
564 +      bytes += sizeof(RealType);
565 +    }
566 +    if (layout & dslFlucQVelocity) {
567 +      bytes += sizeof(RealType);
568 +    }
569 +    if (layout & dslFlucQForce) {
570 +      bytes += sizeof(RealType);
571 +    }
572 +    if (layout & dslSitePotential) {
573 +      bytes += sizeof(RealType);
574 +    }
575 +
576      return bytes;
577    }
578  

Comparing trunk/src/brains/DataStorage.cpp (property svn:keywords):
Revision 1245 by chuckv, Tue May 27 16:39:06 2008 UTC vs.
Revision 1993 by gezelter, Tue Apr 29 17:32:31 2014 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines