60 objType_(objType), storage_(storage), snapshotMan_(NULL), linear_(false),
61 linearAxis_(-1), globalIndex_(-1), globalIntegrableObjectIndex_(-1),
64 void StuntDouble::zeroForcesAndTorques() {
65 int sl = (snapshotMan_->getCurrentSnapshot()->*storage_).getStorageLayout();
67 if (sl & DataStorage::dslForce) setFrc(V3Zero);
68 if (sl & DataStorage::dslTorque) setTrq(V3Zero);
69 if (sl & DataStorage::dslParticlePot) setParticlePot(0.0);
70 if (sl & DataStorage::dslFlucQForce) setFlucQFrc(0.0);
71 if (sl & DataStorage::dslElectricField) setElectricField(V3Zero);
72 if (sl & DataStorage::dslSitePotential) setSitePotential(0.0);
76 RealType multA, RealType multB) {
77 int sl = (snapshotMan_->getCurrentSnapshot()->*storage_).getStorageLayout();
79 assert(sl == (snapA->*storage_).getStorageLayout());
80 assert(sl == (snapB->*storage_).getStorageLayout());
82 if (sl & DataStorage::dslForce) {
83 Vector3d forceA = (snapA->*storage_).force[localIndex_];
84 Vector3d forceB = (snapB->*storage_).force[localIndex_];
86 ((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_] =
87 multA * forceA + multB * forceB;
90 if (sl & DataStorage::dslTorque) {
91 Vector3d torqueA = (snapA->*storage_).torque[localIndex_];
92 Vector3d torqueB = (snapB->*storage_).torque[localIndex_];
94 ((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_] =
95 multA * torqueA + multB * torqueB;
98 if (sl & DataStorage::dslParticlePot) {
99 RealType particlePotA = (snapA->*storage_).particlePot[localIndex_];
100 RealType particlePotB = (snapB->*storage_).particlePot[localIndex_];
102 ((snapshotMan_->getCurrentSnapshot())->*storage_)
103 .particlePot[localIndex_] =
104 multA * particlePotA + multB * particlePotB;
107 if (sl & DataStorage::dslFlucQForce) {
108 RealType flucQFrcA = (snapA->*storage_).flucQFrc[localIndex_];
109 RealType flucQFrcB = (snapB->*storage_).flucQFrc[localIndex_];
111 ((snapshotMan_->getCurrentSnapshot())->*storage_).flucQFrc[localIndex_] =
112 multA * flucQFrcA + multB * flucQFrcB;
115 if (sl & DataStorage::dslElectricField) {
116 Vector3d electricFieldA = (snapA->*storage_).electricField[localIndex_];
117 Vector3d electricFieldB = (snapB->*storage_).electricField[localIndex_];
119 ((snapshotMan_->getCurrentSnapshot())->*storage_)
120 .electricField[localIndex_] =
121 multA * electricFieldA + multB * electricFieldB;
124 if (sl & DataStorage::dslSitePotential) {
125 RealType sitePotentialA = (snapA->*storage_).sitePotential[localIndex_];
126 RealType sitePotentialB = (snapB->*storage_).sitePotential[localIndex_];
128 ((snapshotMan_->getCurrentSnapshot())->*storage_)
129 .sitePotential[localIndex_] =
130 multA * sitePotentialA + multB * sitePotentialB;