ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/primitives/StuntDouble.hpp
Revision: 1245
Committed: Tue May 27 16:39:06 2008 UTC (16 years, 11 months ago) by chuckv
Original Path: trunk/src/primitives/StuntDouble.hpp
File size: 32405 byte(s)
Log Message:
Checking in changes for Hefland moment calculations

File Contents

# User Rev Content
1 gezelter 507 /*
2 gezelter 246 * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3     *
4     * The University of Notre Dame grants you ("Licensee") a
5     * non-exclusive, royalty free, license to use, modify and
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
19     * notice, this list of conditions and the following disclaimer.
20     *
21     * 3. Redistributions in binary form must reproduce the above copyright
22     * notice, this list of conditions and the following disclaimer in the
23     * documentation and/or other materials provided with the
24     * distribution.
25     *
26     * This software is provided "AS IS," without a warranty of any
27     * kind. All express or implied conditions, representations and
28     * warranties, including any implied warranty of merchantability,
29     * fitness for a particular purpose or non-infringement, are hereby
30     * excluded. The University of Notre Dame and its licensors shall not
31     * be liable for any damages suffered by licensee as a result of
32     * using, modifying or distributing the software or its
33     * derivatives. In no event will the University of Notre Dame or its
34     * licensors be liable for any lost revenue, profit or data, or for
35     * direct, indirect, special, consequential, incidental or punitive
36     * damages, however caused and regardless of the theory of liability,
37     * arising out of the use of or inability to use software, even if the
38     * University of Notre Dame has been advised of the possibility of
39     * such damages.
40     */
41    
42     /**
43     * @file StuntDouble.hpp
44     * @author tlin
45     * @date 10/22/2004
46     * @version 1.0
47     */
48    
49 gezelter 507 #ifndef PRIMITIVES_STUNTDOUBLE_HPP
50     #define PRIMITIVES_STUNTDOUBLE_HPP
51 gezelter 2
52 gezelter 246 #include <vector>
53 gezelter 2
54 gezelter 246 #include "visitors/BaseVisitor.hpp"
55     #include "math/Quaternion.hpp"
56     #include "math/SquareMatrix3.hpp"
57     #include "math/Vector3.hpp"
58     #include "utils/PropertyMap.hpp"
59     #include "brains/Snapshot.hpp"
60     #include "brains/SnapshotManager.hpp"
61     namespace oopse{
62 gezelter 2
63 tim 132
64 gezelter 246
65     /**
66     * @class StuntDouble StuntDouble.hpp "Primitives/StuntDouble.hpp"
67     * @brief
68 gezelter 573 * "Don't move, or you're dead! Stand up! Captain, we've got them!"
69     *
70     * "Spectacular stunt, my friends, but all for naught. Turn around
71     * please. Ha. What a pity. What a pity. So, Princess, you thought
72     * you could outwit the imperious forces of...."
73     *
74     * "You idiots! These are not them. You've captured their stunt
75     * doubles! Search the area. Find them! Find them!"
76     *
77 gezelter 246 * StuntDouble is a very strange idea. A StuntDouble stands in for
78     * some object that can be manipulated by the Integrators or
79     * Minimizers. Some of the manipulable objects are Atoms, some are
80     * DirectionalAtoms, and some are RigidBodies. StuntDouble
81     * provides an interface for the Integrators and Minimizers to use,
82     * and does some preliminary sanity checking so that the program
83 gezelter 573 * doesn't try to do something stupid like torque an Atom (The
84     * quotes above are from Spaceballs...)
85     *
86 chuckv 1245 * @note the dynamic data of stuntDouble will be stored outside of the class
87 gezelter 246 */
88 gezelter 507 class StuntDouble{
89     public:
90 gezelter 2
91 gezelter 507 enum ObjectType{
92     otAtom,
93     otDAtom,
94     otRigidBody
95     };
96 gezelter 2
97 gezelter 507 virtual ~StuntDouble();
98 gezelter 246
99 gezelter 507 /**
100 chuckv 1245 * Returns the global index of this stuntDouble.
101     * @return the global index of this stuntDouble
102 gezelter 507 */
103     int getGlobalIndex() {
104     return globalIndex_;
105     }
106 gezelter 2
107 gezelter 507 /**
108 chuckv 1245 * Sets the global index of this stuntDouble.
109 gezelter 507 * @param new global index to be set
110     */
111     void setGlobalIndex(int index) {
112     globalIndex_ = index;
113     }
114 chuckv 1245
115 gezelter 507 /**
116 chuckv 1245 * Returns the local index of this stuntDouble
117     * @return the local index of this stuntDouble
118 gezelter 507 */
119     int getLocalIndex() {
120     return localIndex_;
121     }
122 gezelter 2
123 gezelter 507 /**
124 chuckv 1245 * Sets the local index of this stuntDouble
125 gezelter 507 * @param index new index to be set
126     */
127     void setLocalIndex(int index) {
128     localIndex_ = index;
129     }
130 chuckv 1245
131     int getGlobalIntegrableObjectIndex(){
132     return globalIntegrableObjectIndex_;
133     }
134     void setGlobalIntegrableObjectIndex(int index) {
135     globalIntegrableObjectIndex_ = index;
136     }
137 gezelter 2
138 gezelter 507 /**
139 chuckv 1245 * Sets the Snapshot Manager of this stuntDouble
140 gezelter 507 */
141     void setSnapshotManager(SnapshotManager* sman) {
142     snapshotMan_ = sman;
143     }
144 gezelter 2
145 gezelter 507 /**
146 chuckv 1245 * Tests if this stuntDouble is an atom
147     * @return true is this stuntDouble is an atom(or a directional atom), return false otherwise
148 gezelter 507 */
149     bool isAtom(){
150     return objType_ == otAtom || objType_ == otDAtom;
151     }
152 gezelter 2
153 gezelter 507 /**
154 chuckv 1245 * Tests if this stuntDouble is an directional atom
155     * @return true if this stuntDouble is an directional atom, return false otherwise
156 gezelter 507 */
157     bool isDirectionalAtom(){
158     return objType_ == otDAtom;
159     }
160 gezelter 2
161 gezelter 507 /**
162 chuckv 1245 * Tests if this stuntDouble is a rigid body.
163     * @return true if this stuntDouble is a rigid body, otherwise return false
164 gezelter 507 */
165     bool isRigidBody(){
166     return objType_ == otRigidBody;
167     }
168 gezelter 2
169 gezelter 507 /**
170 chuckv 1245 * Tests if this stuntDouble is a directional one.
171     * @return true is this stuntDouble is a directional atom or a rigid body, return false otherwise
172 gezelter 507 */
173     bool isDirectional(){
174     return isDirectionalAtom() || isRigidBody();
175     }
176 gezelter 2
177 gezelter 507 /**
178 gezelter 945 * Freezes out all velocity, angular velocity, forces and torques
179     * on this StuntDouble. Also computes the number of frozen degrees
180     * of freedom.
181     * @return the total number of frozen degrees of freedom
182     */
183     int freeze() {
184    
185     int fdf = 3;
186    
187     setVel(V3Zero);
188     setFrc(V3Zero);
189     if (isDirectional()){
190     setJ(V3Zero);
191     setTrq(V3Zero);
192     if (isLinear())
193     fdf +=2;
194     else
195     fdf +=3;
196     }
197     return fdf;
198     }
199    
200     /**
201 chuckv 1245 * Returns the previous position of this stuntDouble
202     * @return the position of this stuntDouble
203 gezelter 507 */
204     Vector3d getPrevPos() {
205     return ((snapshotMan_->getPrevSnapshot())->*storage_).position[localIndex_];
206     }
207 gezelter 246
208 gezelter 507 /**
209 chuckv 1245 * Returns the current position of this stuntDouble
210     * @return the position of this stuntDouble
211 gezelter 507 */
212     Vector3d getPos() {
213     return ((snapshotMan_->getCurrentSnapshot())->*storage_).position[localIndex_];
214     }
215 gezelter 2
216 gezelter 507 /**
217 chuckv 1245 * Returns the position of this stuntDouble in specified snapshot
218     * @return the position of this stuntDouble
219 gezelter 507 * @param snapshotNo
220     */
221     Vector3d getPos(int snapshotNo) {
222     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).position[localIndex_];
223     }
224 gezelter 2
225 gezelter 507 /**
226 chuckv 1245 * Sets the previous position of this stuntDouble
227 gezelter 507 * @param pos new position
228     * @see #getPos
229     */
230     void setPrevPos(const Vector3d& pos) {
231     ((snapshotMan_->getPrevSnapshot())->*storage_).position[localIndex_] = pos;
232     }
233 gezelter 246
234 gezelter 507 /**
235 chuckv 1245 * Sets the current position of this stuntDouble
236 gezelter 507 * @param pos new position
237     */
238     void setPos(const Vector3d& pos) {
239     DataStorage& data = snapshotMan_->getCurrentSnapshot()->*storage_;
240     data.position[localIndex_] = pos;
241     //((snapshotMan_->getCurrentSnapshot())->*storage_).position[localIndex_] = pos;
242     }
243 gezelter 2
244 gezelter 507 /**
245 chuckv 1245 * Sets the position of this stuntDouble in specified snapshot
246 gezelter 507 * @param pos position to be set
247     * @param snapshotNo
248     * @see #getPos
249     */
250     void setPos(const Vector3d& pos, int snapshotNo) {
251 gezelter 2
252 gezelter 507 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).position[localIndex_] = pos;
253 gezelter 2
254 gezelter 507 }
255 gezelter 246
256 gezelter 507 /**
257 chuckv 1245 * Returns the previous velocity of this stuntDouble
258     * @return the velocity of this stuntDouble
259 gezelter 507 */
260     Vector3d getPrevVel() {
261     return ((snapshotMan_->getPrevSnapshot())->*storage_).velocity[localIndex_];
262     }
263 gezelter 246
264 gezelter 507 /**
265 chuckv 1245 * Returns the current velocity of this stuntDouble
266     * @return the velocity of this stuntDouble
267 gezelter 507 */
268     Vector3d getVel() {
269     return ((snapshotMan_->getCurrentSnapshot())->*storage_).velocity[localIndex_];
270     }
271 gezelter 2
272 gezelter 507 /**
273 chuckv 1245 * Returns the velocity of this stuntDouble in specified snapshot
274     * @return the velocity of this stuntDouble
275 gezelter 507 * @param snapshotNo
276     */
277     Vector3d getVel(int snapshotNo) {
278     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).velocity[localIndex_];
279     }
280 gezelter 2
281 gezelter 507 /**
282 chuckv 1245 * Sets the previous velocity of this stuntDouble
283 gezelter 507 * @param vel new velocity
284     * @see #getVel
285     */
286     void setPrevVel(const Vector3d& vel) {
287     ((snapshotMan_->getPrevSnapshot())->*storage_).velocity[localIndex_] = vel;
288     }
289 gezelter 246
290 gezelter 507 /**
291 chuckv 1245 * Sets the current velocity of this stuntDouble
292 gezelter 507 * @param vel new velocity
293     */
294     void setVel(const Vector3d& vel) {
295     ((snapshotMan_->getCurrentSnapshot())->*storage_).velocity[localIndex_] = vel;
296     }
297 gezelter 246
298 gezelter 507 /**
299 chuckv 1245 * Sets the velocity of this stuntDouble in specified snapshot
300 gezelter 507 * @param vel velocity to be set
301     * @param snapshotNo
302     * @see #getVel
303     */
304     void setVel(const Vector3d& vel, int snapshotNo) {
305     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).velocity[localIndex_] = vel;
306     }
307 gezelter 246
308 gezelter 507 /**
309 chuckv 1245 * Returns the previous rotation matrix of this stuntDouble
310     * @return the rotation matrix of this stuntDouble
311 gezelter 507 */
312     RotMat3x3d getPrevA() {
313     return ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_];
314     }
315 gezelter 246
316 gezelter 507 /**
317 chuckv 1245 * Returns the current rotation matrix of this stuntDouble
318     * @return the rotation matrix of this stuntDouble
319 gezelter 507 */
320     RotMat3x3d getA() {
321     return ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_];
322     }
323 gezelter 246
324 gezelter 507 /**
325 chuckv 1245 * Returns the rotation matrix of this stuntDouble in specified snapshot
326 gezelter 507 *
327 chuckv 1245 * @return the rotation matrix of this stuntDouble
328 gezelter 507 * @param snapshotNo
329     */
330     RotMat3x3d getA(int snapshotNo) {
331     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_];
332     }
333 gezelter 246
334 gezelter 507 /**
335 chuckv 1245 * Sets the previous rotation matrix of this stuntDouble
336 gezelter 507 * @param a new rotation matrix
337     * @see #getA
338     */
339     virtual void setPrevA(const RotMat3x3d& a) {
340     ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_] = a;
341     }
342 gezelter 246
343 gezelter 507 /**
344 chuckv 1245 * Sets the current rotation matrix of this stuntDouble
345 gezelter 507 * @param a new rotation matrix
346     */
347     virtual void setA(const RotMat3x3d& a) {
348     ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_] = a;
349     }
350 gezelter 246
351 gezelter 507 /**
352 chuckv 1245 * Sets the rotation matrix of this stuntDouble in specified snapshot
353 gezelter 507 * @param a rotation matrix to be set
354     * @param snapshotNo
355     * @see #getA
356     */
357     virtual void setA(const RotMat3x3d& a, int snapshotNo) {
358     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_] = a;
359     }
360 gezelter 246
361 gezelter 507 /**
362 chuckv 1245 * Returns the previous angular momentum of this stuntDouble (body-fixed).
363     * @return the angular momentum of this stuntDouble
364 gezelter 507 */
365     Vector3d getPrevJ() {
366     return ((snapshotMan_->getPrevSnapshot())->*storage_).angularMomentum[localIndex_];
367     }
368 gezelter 246
369 gezelter 507 /**
370 chuckv 1245 * Returns the current angular momentum of this stuntDouble (body -fixed).
371     * @return the angular momentum of this stuntDouble
372 gezelter 507 */
373     Vector3d getJ() {
374     return ((snapshotMan_->getCurrentSnapshot())->*storage_).angularMomentum[localIndex_];
375     }
376 gezelter 246
377 gezelter 507 /**
378 chuckv 1245 * Returns the angular momentum of this stuntDouble in specified snapshot (body-fixed).
379     * @return the angular momentum of this stuntDouble
380 gezelter 507 * @param snapshotNo
381     */
382     Vector3d getJ(int snapshotNo) {
383     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).angularMomentum[localIndex_];
384     }
385 gezelter 246
386 gezelter 507 /**
387 chuckv 1245 * Sets the previous angular momentum of this stuntDouble (body-fixed).
388 gezelter 507 * @param angMom new angular momentum
389     * @see #getJ
390     */
391     void setPrevJ(const Vector3d& angMom) {
392     ((snapshotMan_->getPrevSnapshot())->*storage_).angularMomentum[localIndex_] = angMom;
393     }
394 gezelter 246
395 gezelter 507 /**
396 chuckv 1245 * Sets the current angular momentum of this stuntDouble (body-fixed).
397 gezelter 507 * @param angMom new angular momentum
398     */
399     void setJ(const Vector3d& angMom) {
400     ((snapshotMan_->getCurrentSnapshot())->*storage_).angularMomentum[localIndex_] = angMom;
401     }
402 gezelter 246
403 gezelter 507 /**
404 chuckv 1245 * Sets the angular momentum of this stuntDouble in specified snapshot(body-fixed).
405 gezelter 507 * @param angMom angular momentum to be set
406     * @param snapshotNo
407     * @see #getJ
408     */
409     void setJ(const Vector3d& angMom, int snapshotNo) {
410     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).angularMomentum[localIndex_] = angMom;
411     }
412 chuckv 1112
413 gezelter 507 /**
414 chuckv 1245 * Returns system Center of Mass for stuntDouble frame from snapshot
415 chuckv 1112 *
416     */
417     Vector3d getCOM(){
418     return (snapshotMan_->getCurrentSnapshot())->getCOM();
419     }
420    
421     /**
422 chuckv 1245 * Returns system Center of Mass velocity for stuntDouble frame from snapshot
423 chuckv 1112 *
424     */
425    
426     Vector3d getCOMvel(){
427     return (snapshotMan_->getCurrentSnapshot())->getCOMvel();
428     }
429    
430     /**
431 chuckv 1245 * Returns system Center of Mass angular momentum for stuntDouble frame from snapshot
432 chuckv 1112 *
433     */
434     Vector3d getCOMw(){
435     return (snapshotMan_->getCurrentSnapshot())->getCOMw();
436     }
437    
438     /**
439 chuckv 1245 * Returns system Center of Mass for stuntDouble frame from snapshot
440 chuckv 1112 *
441     */
442     Vector3d getCOM(int snapshotNo){
443     return (snapshotMan_->getSnapshot(snapshotNo))->getCOM();
444     }
445    
446     /**
447 chuckv 1245 * Returns system Center of Mass velocity for stuntDouble frame from snapshot
448 chuckv 1112 *
449     */
450    
451     Vector3d getCOMvel(int snapshotNo){
452     return (snapshotMan_->getSnapshot(snapshotNo))->getCOMvel();
453     }
454    
455     /**
456 chuckv 1245 * Returns system Center of Mass angular momentum for stuntDouble frame from snapshot
457 chuckv 1112 *
458     */
459     Vector3d getCOMw(int snapshotNo){
460     return (snapshotMan_->getSnapshot(snapshotNo))->getCOMw();
461     }
462    
463     /**
464 chuckv 1245 * Returns the previous quaternion of this stuntDouble
465     * @return the quaternion of this stuntDouble
466 gezelter 507 */
467     Quat4d getPrevQ() {
468     return ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_].toQuaternion();
469     }
470 gezelter 246
471 gezelter 507 /**
472 chuckv 1245 * Returns the current quaternion of this stuntDouble
473     * @return the quaternion of this stuntDouble
474 gezelter 507 */
475     Quat4d getQ() {
476     return ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_].toQuaternion();
477     }
478 gezelter 246
479 gezelter 507 /**
480 chuckv 1245 * Returns the quaternion of this stuntDouble in specified snapshot
481     * @return the quaternion of this stuntDouble
482 gezelter 507 * @param snapshotNo
483     */
484     Quat4d getQ(int snapshotNo) {
485     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_].toQuaternion();
486     }
487 gezelter 246
488 gezelter 507 /**
489 chuckv 1245 * Sets the previous quaternion of this stuntDouble
490 gezelter 507 * @param q new quaternion
491     * @note actual storage data is rotation matrix
492     */
493     void setPrevQ(const Quat4d& q) {
494     setPrevA(q);
495     }
496 gezelter 246
497 gezelter 507 /**
498 chuckv 1245 * Sets the current quaternion of this stuntDouble
499 gezelter 507 * @param q new quaternion
500     * @note actual storage data is rotation matrix
501     */
502     void setQ(const Quat4d& q) {
503     setA(q);
504     }
505 gezelter 246
506 gezelter 507 /**
507 chuckv 1245 * Sets the quaternion of this stuntDouble in specified snapshot
508 gezelter 507 *
509     * @param q quaternion to be set
510     * @param snapshotNo
511     * @note actual storage data is rotation matrix
512     */
513     void setQ(const Quat4d& q, int snapshotNo) {
514     setA(q, snapshotNo);
515     }
516 gezelter 246
517 gezelter 507 /**
518 chuckv 1245 * Returns the previous euler angles of this stuntDouble
519     * @return the euler angles of this stuntDouble
520 gezelter 507 */
521     Vector3d getPrevEuler() {
522     return ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_].toEulerAngles();
523     }
524 gezelter 246
525 gezelter 507 /**
526 chuckv 1245 * Returns the current euler angles of this stuntDouble
527     * @return the euler angles of this stuntDouble
528 gezelter 507 */
529     Vector3d getEuler() {
530     return ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_].toEulerAngles();
531     }
532 gezelter 246
533 gezelter 507 /**
534 chuckv 1245 * Returns the euler angles of this stuntDouble in specified snapshot.
535     * @return the euler angles of this stuntDouble
536 gezelter 507 * @param snapshotNo
537     */
538     Vector3d getEuler(int snapshotNo) {
539     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_].toEulerAngles();
540     }
541 gezelter 246
542 gezelter 507 /**
543 chuckv 1245 * Sets the previous euler angles of this stuntDouble.
544 gezelter 507 * @param euler new euler angles
545     * @see #getEuler
546     * @note actual storage data is rotation matrix
547     */
548     void setPrevEuler(const Vector3d& euler) {
549     ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_] = euler;
550     }
551 gezelter 246
552 gezelter 507 /**
553 chuckv 1245 * Sets the current euler angles of this stuntDouble
554 gezelter 507 * @param euler new euler angles
555     */
556     void setEuler(const Vector3d& euler) {
557     ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_] = euler;
558     }
559 gezelter 246
560 gezelter 507 /**
561 chuckv 1245 * Sets the euler angles of this stuntDouble in specified snapshot
562 gezelter 507 *
563     * @param euler euler angles to be set
564     * @param snapshotNo
565     * @note actual storage data is rotation matrix
566     */
567     void setEuler(const Vector3d& euler, int snapshotNo) {
568     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_] = euler;
569     }
570 gezelter 246
571 gezelter 507 /**
572 chuckv 1245 * Returns the previous unit vectors of this stuntDouble
573     * @return the unit vectors of this stuntDouble
574 gezelter 507 */
575     RotMat3x3d getPrevElectroFrame() {
576     return ((snapshotMan_->getPrevSnapshot())->*storage_).electroFrame[localIndex_];
577     }
578 gezelter 246
579 gezelter 507 /**
580 chuckv 1245 * Returns the current unit vectors of this stuntDouble
581     * @return the unit vectors of this stuntDouble
582 gezelter 507 */
583     RotMat3x3d getElectroFrame() {
584     return ((snapshotMan_->getCurrentSnapshot())->*storage_).electroFrame[localIndex_];
585     }
586 gezelter 246
587 gezelter 507 /**
588 chuckv 1245 * Returns the unit vectors of this stuntDouble in specified snapshot
589 gezelter 507 *
590 chuckv 1245 * @return the unit vectors of this stuntDouble
591 gezelter 507 * @param snapshotNo
592     */
593     RotMat3x3d getElectroFrame(int snapshotNo) {
594     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).electroFrame[localIndex_];
595     }
596 gezelter 246
597 gezelter 507 /**
598 chuckv 1245 * Returns the previous force of this stuntDouble
599     * @return the force of this stuntDouble
600 gezelter 507 */
601     Vector3d getPrevFrc() {
602     return ((snapshotMan_->getPrevSnapshot())->*storage_).force[localIndex_];
603     }
604 gezelter 246
605 gezelter 507 /**
606 chuckv 1245 * Returns the current force of this stuntDouble
607     * @return the force of this stuntDouble
608 gezelter 507 */
609     Vector3d getFrc() {
610     return ((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_];
611     }
612 gezelter 246
613 gezelter 507 /**
614 chuckv 1245 * Returns the force of this stuntDouble in specified snapshot
615 gezelter 507 *
616 chuckv 1245 * @return the force of this stuntDouble
617 gezelter 507 * @param snapshotNo
618     */
619     Vector3d getFrc(int snapshotNo) {
620     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_];
621     }
622 gezelter 246
623 gezelter 507 /**
624 chuckv 1245 * Sets the previous force of this stuntDouble
625 gezelter 507 *
626     * @param frc new force
627     * @see #getFrc
628     */
629     void setPrevFrc(const Vector3d& frc) {
630     ((snapshotMan_->getPrevSnapshot())->*storage_).force[localIndex_] = frc;
631     }
632 gezelter 246
633 gezelter 507 /**
634 chuckv 1245 * Sets the current force of this stuntDouble
635 gezelter 507 * @param frc new force
636     */
637     void setFrc(const Vector3d& frc) {
638     ((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_] = frc;
639     }
640 gezelter 246
641 gezelter 507 /**
642 chuckv 1245 * Sets the force of this stuntDouble in specified snapshot
643 gezelter 507 *
644     * @param frc force to be set
645     * @param snapshotNo
646     * @see #getFrc
647     */
648     void setFrc(const Vector3d& frc, int snapshotNo) {
649     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_] = frc;
650     }
651 gezelter 246
652 gezelter 507 /**
653 chuckv 1245 * Adds force into the previous force of this stuntDouble
654 gezelter 507 *
655     * @param frc new force
656     * @see #getFrc
657     */
658     void addPrevFrc(const Vector3d& frc) {
659     ((snapshotMan_->getPrevSnapshot())->*storage_).force[localIndex_] += frc;
660     }
661 gezelter 246
662 gezelter 507 /**
663 chuckv 1245 * Adds force into the current force of this stuntDouble
664 gezelter 507 * @param frc new force
665     */
666     void addFrc(const Vector3d& frc) {
667     ((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_] += frc;
668     }
669 gezelter 246
670 gezelter 507 /**
671 chuckv 1245 * Adds force into the force of this stuntDouble in specified snapshot
672 gezelter 507 *
673     * @param frc force to be set
674     * @param snapshotNo
675     * @see #getFrc
676     */
677     void addFrc(const Vector3d& frc, int snapshotNo) {
678     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_] += frc;
679     }
680 gezelter 246
681 gezelter 507 /**
682 chuckv 1245 * Returns the previous torque of this stuntDouble
683     * @return the torque of this stuntDouble
684 gezelter 507 */
685     Vector3d getPrevTrq() {
686     return ((snapshotMan_->getPrevSnapshot())->*storage_).torque[localIndex_];
687     }
688 gezelter 246
689 gezelter 507 /**
690 chuckv 1245 * Returns the current torque of this stuntDouble
691     * @return the torque of this stuntDouble
692 gezelter 507 */
693     Vector3d getTrq() {
694     return ((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_];
695     }
696 gezelter 246
697 gezelter 507 /**
698 chuckv 1245 * Returns the torque of this stuntDouble in specified snapshot
699 gezelter 507 *
700 chuckv 1245 * @return the torque of this stuntDouble
701 gezelter 507 * @param snapshotNo
702     */
703     Vector3d getTrq(int snapshotNo) {
704     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_];
705     }
706 gezelter 246
707 gezelter 507 /**
708 chuckv 1245 * Sets the previous torque of this stuntDouble
709 gezelter 507 *
710     * @param trq new torque
711     * @see #getTrq
712     */
713     void setPrevTrq(const Vector3d& trq) {
714     ((snapshotMan_->getPrevSnapshot())->*storage_).torque[localIndex_] = trq;
715     }
716 gezelter 246
717 gezelter 507 /**
718 chuckv 1245 * Sets the current torque of this stuntDouble
719 gezelter 507 * @param trq new torque
720     */
721     void setTrq(const Vector3d& trq) {
722     ((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_] = trq;
723     }
724 gezelter 246
725 gezelter 507 /**
726 chuckv 1245 * Sets the torque of this stuntDouble in specified snapshot
727 gezelter 507 *
728     * @param trq torque to be set
729     * @param snapshotNo
730     * @see #getTrq
731     */
732     void setTrq(const Vector3d& trq, int snapshotNo) {
733     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_] = trq;
734     }
735 gezelter 246
736 gezelter 507 /**
737 chuckv 1245 * Adds torque into the previous torque of this stuntDouble
738 gezelter 507 *
739     * @param trq new torque
740     * @see #getTrq
741     */
742     void addPrevTrq(const Vector3d& trq) {
743     ((snapshotMan_->getPrevSnapshot())->*storage_).torque[localIndex_] += trq;
744     }
745 gezelter 246
746 gezelter 507 /**
747 chuckv 1245 * Adds torque into the current torque of this stuntDouble
748 gezelter 507 * @param trq new torque
749     */
750     void addTrq(const Vector3d& trq) {
751     ((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_] += trq;
752     }
753 gezelter 246
754 gezelter 507 /**
755 chuckv 1245 * Adds torque into the torque of this stuntDouble in specified snapshot
756 gezelter 507 *
757     * @param trq torque to be add
758     * @param snapshotNo
759     * @see #getTrq
760     */
761     void addTrq(const Vector3d& trq, int snapshotNo) {
762     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_] += trq;
763     }
764 gezelter 246
765    
766 gezelter 507 /**
767 chuckv 1245 * Returns the previous z-angle of this stuntDouble
768     * @return the z-angle of this stuntDouble
769 gezelter 507 */
770 tim 963 RealType getPrevZangle() {
771 gezelter 507 return ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_];
772     }
773 gezelter 246
774 gezelter 507 /**
775 chuckv 1245 * Returns the current z-angle of this stuntDouble
776     * @return the z-angle of this stuntDouble
777 gezelter 507 */
778 tim 963 RealType getZangle() {
779 gezelter 507 return ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_];
780     }
781 gezelter 246
782 gezelter 507 /**
783 chuckv 1245 * Returns the z-angle of this stuntDouble in specified snapshot
784     * @return the z-angle of this stuntDouble
785 gezelter 507 * @param snapshotNo
786     */
787 tim 963 RealType getZangle(int snapshotNo) {
788 gezelter 507 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_];
789     }
790 gezelter 246
791 gezelter 507 /**
792 chuckv 1245 * Sets the previous z-angle of this stuntDouble
793 gezelter 507 * @param angle new z-angle
794     * @see #getZangle
795     */
796 tim 963 void setPrevZangle(RealType angle) {
797 gezelter 507 ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] = angle;
798     }
799 gezelter 246
800 gezelter 507 /**
801 chuckv 1245 * Sets the current z-angle of this stuntDouble
802 gezelter 507 * @param angle new z-angle
803     */
804 tim 963 void setZangle(RealType angle) {
805 gezelter 507 ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] = angle;
806     }
807 gezelter 246
808 gezelter 507 /**
809 chuckv 1245 * Sets the z-angle of this stuntDouble in specified snapshot
810 gezelter 507 * @param angle z-angle to be set
811     * @param snapshotNo
812     * @see #getZangle
813     */
814 tim 963 void setZangle(RealType angle, int snapshotNo) {
815 gezelter 507 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] = angle;
816     }
817 gezelter 246
818 gezelter 507 /**
819 chuckv 1245 * Adds z-angle into the previous z-angle of this stuntDouble
820 gezelter 507 * @param angle new z-angle
821     * @see #getZangle
822     */
823 tim 963 void addPrevZangle(RealType angle) {
824 gezelter 507 ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] += angle;
825     }
826 gezelter 246
827 gezelter 507 /**
828 chuckv 1245 * Adds z-angle into the current z-angle of this stuntDouble
829 gezelter 507 * @param angle new z-angle
830     */
831 tim 963 void addZangle(RealType angle) {
832 gezelter 507 ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] += angle;
833     }
834 gezelter 246
835 gezelter 507 /**
836 chuckv 1245 * Adds z-angle into the z-angle of this stuntDouble in specified snapshot
837 gezelter 507 * @param angle z-angle to be add
838     * @param snapshotNo
839     * @see #getZangle
840     */
841 tim 963 void addZangle(RealType angle, int snapshotNo) {
842 gezelter 507 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] += angle;
843     }
844 gezelter 246
845 chuckv 1245 /** Set the force of this stuntDouble to zero */
846 gezelter 507 void zeroForcesAndTorques();
847     /**
848 chuckv 1245 * Returns the inertia tensor of this stuntDouble
849     * @return the inertia tensor of this stuntDouble
850 gezelter 507 */
851     virtual Mat3x3d getI() = 0;
852 gezelter 246
853 gezelter 507 /**
854 chuckv 1245 * Returns the gradient of this stuntDouble
855     * @return the gradient of this stuntDouble
856 gezelter 507 */
857 tim 963 virtual std::vector<RealType> getGrad() = 0;
858 gezelter 246
859 gezelter 507 /**
860 chuckv 1245 * Tests the if this stuntDouble is a linear rigidbody
861 gezelter 507 *
862 chuckv 1245 * @return true if this stuntDouble is a linear rigidbody, otherwise return false
863 gezelter 507 * @note atom and directional atom will always return false
864     *
865     * @see #linearAxis
866     */
867     bool isLinear() {
868     return linear_;
869     }
870 gezelter 246
871 gezelter 507 /**
872     * Returns the linear axis of the rigidbody, atom and directional atom will always return -1
873     *
874     * @return the linear axis of the rigidbody
875     *
876     * @see #isLinear
877     */
878     int linearAxis() {
879     return linearAxis_;
880     }
881 gezelter 246
882 chuckv 1245 /** Returns the mass of this stuntDouble */
883 tim 963 RealType getMass() {
884 gezelter 507 return mass_;
885     }
886 gezelter 246
887 gezelter 507 /**
888     * Sets the mass of this stuntdoulbe
889     * @param mass the mass to be set
890     */
891 tim 963 void setMass(RealType mass) {
892 gezelter 507 mass_ = mass;
893     }
894 gezelter 246
895 chuckv 1245 /** Returns the name of this stuntDouble */
896 gezelter 507 virtual std::string getType() = 0;
897 gezelter 246
898 chuckv 1245 /** Sets the name of this stuntDouble*/
899 gezelter 507 virtual void setType(const std::string& name) {}
900 gezelter 246
901 gezelter 507 /**
902     * Converts a lab fixed vector to a body fixed vector.
903     * @return body fixed vector
904     * @param v lab fixed vector
905     */
906     Vector3d lab2Body(const Vector3d& v) {
907     return getA() * v;
908     }
909 gezelter 246
910 gezelter 507 Vector3d lab2Body(const Vector3d& v, int frame) {
911     return getA(frame) * v;
912     }
913 tim 334
914 gezelter 507 /**
915     * Converts a body fixed vector to a lab fixed vector.
916     * @return corresponding lab fixed vector
917     * @param v body fixed vector
918     */
919     Vector3d body2Lab(const Vector3d& v){
920     return getA().transpose() * v;
921     }
922 tim 334
923 gezelter 507 Vector3d body2Lab(const Vector3d& v, int frame){
924     return getA(frame).transpose() * v;
925     }
926 chuckv 1245
927 gezelter 507 /**
928 chuckv 1245 * Returns the previous particle potential of this stuntDouble
929     * @return the particle potential of this stuntDouble
930     */
931     RealType getPrevParticlePot() {
932     return ((snapshotMan_->getPrevSnapshot())->*storage_).particlePot[localIndex_];
933     }
934    
935     /**
936     * Returns the current particle potential of this stuntDouble
937     * @return the particle potential of this stuntDouble
938     */
939     RealType getParticlePot() {
940     return ((snapshotMan_->getCurrentSnapshot())->*storage_).particlePot[localIndex_];
941     }
942    
943     /**
944     * Returns the particle potential of this stuntDouble in specified snapshot
945     * @return the particle potential of this stuntDouble
946     * @param snapshotNo
947     */
948     RealType getParticlePot(int snapshotNo) {
949     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).particlePot[localIndex_];
950     }
951    
952     /**
953     * Sets the previous particle potential of this stuntDouble
954     * @param po tnew particle potential
955     * @see #getParticlePot
956     */
957     void setPrevParticlePot(RealType pot) {
958     ((snapshotMan_->getPrevSnapshot())->*storage_).particlePot[localIndex_] = pot;
959     }
960    
961     /**
962     * Sets the current velocity of this stuntDouble
963     * @param vel new velocity
964     */
965     void setParticlePot(RealType pot) {
966     ((snapshotMan_->getCurrentSnapshot())->*storage_).particlePot[localIndex_] = pot;
967     }
968    
969     /**
970     * Sets the particle potential of this stuntDouble in specified snapshot
971     * @param pot potential to be set
972     * @param snapshotNo
973     * @see #getVel
974     */
975     void setParticlePot(RealType pot, int snapshotNo) {
976     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).particlePot[localIndex_] = pot;
977     }
978    
979     /**
980 gezelter 507 * <p>
981     * The purpose of the Visitor Pattern is to encapsulate an operation that you want to perform on
982     * the elements of a data structure. In this way, you can change the operation being performed
983     * on a structure without the need of changing the classes of the elements that you are operating
984     * on. Using a Visitor pattern allows you to decouple the classes for the data structure and the
985     * algorithms used upon them
986     * </p>
987     * @param v visitor
988     */
989     virtual void accept(BaseVisitor* v) = 0;
990 gezelter 246
991 gezelter 507 //below functions are just forward functions
992     /**
993     * Adds property into property map
994     * @param genData GenericData to be added into PropertyMap
995     */
996     void addProperty(GenericData* genData);
997 gezelter 246
998 gezelter 507 /**
999     * Removes property from PropertyMap by name
1000     * @param propName the name of property to be removed
1001     */
1002     void removeProperty(const std::string& propName);
1003 gezelter 246
1004 gezelter 507 /**
1005     * clear all of the properties
1006     */
1007     void clearProperties();
1008 gezelter 246
1009 gezelter 507 /**
1010     * Returns all names of properties
1011     * @return all names of properties
1012     */
1013     std::vector<std::string> getPropertyNames();
1014 gezelter 246
1015 gezelter 507 /**
1016     * Returns all of the properties in PropertyMap
1017     * @return all of the properties in PropertyMap
1018     */
1019     std::vector<GenericData*> getProperties();
1020 gezelter 246
1021 gezelter 507 /**
1022     * Returns property
1023     * @param propName name of property
1024     * @return a pointer point to property with propName. If no property named propName
1025     * exists, return NULL
1026     */
1027     GenericData* getPropertyByName(const std::string& propName);
1028 gezelter 246
1029 gezelter 507 protected:
1030 gezelter 246
1031 gezelter 507 StuntDouble(ObjectType objType, DataStoragePointer storage);
1032 gezelter 246
1033 gezelter 507 StuntDouble(const StuntDouble& sd);
1034     StuntDouble& operator=(const StuntDouble& sd);
1035 gezelter 246
1036 gezelter 507 ObjectType objType_;
1037     DataStoragePointer storage_;
1038     SnapshotManager* snapshotMan_;
1039 gezelter 246
1040 gezelter 507 bool linear_;
1041     int linearAxis_;
1042 gezelter 246
1043    
1044 gezelter 507 int globalIndex_;
1045 tim 1024 int globalIntegrableObjectIndex_;
1046 gezelter 507 int localIndex_;
1047 gezelter 246
1048    
1049 tim 963 RealType mass_;
1050 gezelter 246
1051 gezelter 507 private:
1052 gezelter 246
1053 gezelter 507 PropertyMap properties_;
1054     };
1055 gezelter 2
1056 gezelter 246 }//end namespace oopse
1057     #endif //PRIMITIVES_STUNTDOUBLE_HPP

Properties

Name Value
svn:executable *