52#ifndef PRIMITIVES_STUNTDOUBLE_HPP
53#define PRIMITIVES_STUNTDOUBLE_HPP
58#include "brains/Snapshot.hpp"
64#include "visitors/BaseVisitor.hpp"
93 enum ObjectType { otAtom, otDAtom, otRigidBody };
121 int getGlobalIntegrableObjectIndex() {
122 return globalIntegrableObjectIndex_;
125 void setGlobalIntegrableObjectIndex(
int index) {
126 globalIntegrableObjectIndex_ = index;
139 bool isAtom() {
return objType_ == otAtom || objType_ == otDAtom; }
189 .position[localIndex_];
198 .position[localIndex_];
207 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
208 .position[localIndex_];
227 data.position[localIndex_] = pos;
239 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
240 .position[localIndex_] = pos;
249 .velocity[localIndex_];
258 .velocity[localIndex_];
267 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
268 .velocity[localIndex_];
272 return (snapshot->*storage_).velocity[localIndex_];
301 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
302 .velocity[localIndex_] = vel;
310 return ((snapshotMan_->
getPrevSnapshot())->*storage_).aMat[localIndex_];
329 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
357 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_] =
367 .angularMomentum[localIndex_];
376 .angularMomentum[localIndex_];
386 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
387 .angularMomentum[localIndex_];
397 .angularMomentum[localIndex_] = angMom;
406 .angularMomentum[localIndex_] = angMom;
417 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
418 .angularMomentum[localIndex_] = angMom;
447 return (snapshotMan_->getSnapshot(snapshotNo))->getCOM();
455 return (snapshotMan_->getSnapshot(snapshotNo))->getCOMvel();
463 return (snapshotMan_->getSnapshot(snapshotNo))->getCOMw();
492 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
546 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
581 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
591 return ((snapshotMan_->
getPrevSnapshot())->*storage_).dipole[localIndex_];
600 .dipole[localIndex_];
610 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
611 .dipole[localIndex_];
620 .quadrupole[localIndex_];
629 .quadrupole[localIndex_];
639 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
640 .quadrupole[localIndex_];
648 return ((snapshotMan_->
getPrevSnapshot())->*storage_).force[localIndex_];
667 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
678 ((snapshotMan_->
getPrevSnapshot())->*storage_).force[localIndex_] = frc;
698 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_] =
709 ((snapshotMan_->
getPrevSnapshot())->*storage_).force[localIndex_] += frc;
729 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_] +=
738 return ((snapshotMan_->
getPrevSnapshot())->*storage_).torque[localIndex_];
747 .torque[localIndex_];
757 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
758 .torque[localIndex_];
768 ((snapshotMan_->
getPrevSnapshot())->*storage_).torque[localIndex_] = trq;
788 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_] =
799 ((snapshotMan_->
getPrevSnapshot())->*storage_).torque[localIndex_] += trq;
819 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
820 .torque[localIndex_] += trq;
829 .particlePot[localIndex_];
838 .particlePot[localIndex_];
848 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
849 .particlePot[localIndex_];
859 ((snapshotMan_->
getPrevSnapshot())->*storage_).particlePot[localIndex_] =
869 .particlePot[localIndex_] = particlePot;
880 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
881 .particlePot[localIndex_] = particlePot;
891 ((snapshotMan_->
getPrevSnapshot())->*storage_).particlePot[localIndex_] +=
901 .particlePot[localIndex_] += particlePot;
913 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
914 .particlePot[localIndex_] += particlePot;
923 .flucQPos[localIndex_];
932 .flucQPos[localIndex_];
941 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
942 .flucQPos[localIndex_];
971 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
972 .flucQPos[localIndex_] = charge;
982 ((snapshotMan_->
getPrevSnapshot())->*storage_).flucQPos[localIndex_] +=
1004 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1005 .flucQPos[localIndex_] += charge;
1014 .flucQVel[localIndex_];
1023 .flucQVel[localIndex_];
1032 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1033 .flucQVel[localIndex_];
1042 ((snapshotMan_->
getPrevSnapshot())->*storage_).flucQVel[localIndex_] =
1062 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1063 .flucQVel[localIndex_] = cvel;
1073 ((snapshotMan_->
getPrevSnapshot())->*storage_).flucQVel[localIndex_] +=
1094 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1095 .flucQVel[localIndex_] += cvel;
1104 .flucQFrc[localIndex_];
1113 .flucQFrc[localIndex_];
1122 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1123 .flucQFrc[localIndex_];
1132 ((snapshotMan_->
getPrevSnapshot())->*storage_).flucQFrc[localIndex_] =
1152 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1153 .flucQFrc[localIndex_] = cfrc;
1162 ((snapshotMan_->
getPrevSnapshot())->*storage_).flucQFrc[localIndex_] +=
1183 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1184 .flucQFrc[localIndex_] += cfrc;
1193 .electricField[localIndex_];
1202 .electricField[localIndex_];
1211 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1212 .electricField[localIndex_];
1222 .electricField[localIndex_] = eField;
1231 .electricField[localIndex_] = eField;
1241 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1242 .electricField[localIndex_] = eField;
1254 .electricField[localIndex_] += eField;
1263 .electricField[localIndex_] += eField;
1275 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1276 .electricField[localIndex_] += eField;
1285 .sitePotential[localIndex_];
1294 .sitePotential[localIndex_];
1303 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1304 .sitePotential[localIndex_];
1314 .sitePotential[localIndex_] = spot;
1323 .sitePotential[localIndex_] = spot;
1333 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1334 .sitePotential[localIndex_] = spot;
1344 .sitePotential[localIndex_] += spot;
1353 .sitePotential[localIndex_] += spot;
1364 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1365 .sitePotential[localIndex_] += spot;
1374 .density[localIndex_];
1383 .density[localIndex_];
1392 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1393 .density[localIndex_];
1422 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1423 .density[localIndex_] = dens;
1432 ((snapshotMan_->
getPrevSnapshot())->*storage_).density[localIndex_] +=
1452 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_)
1453 .density[localIndex_] += dens;
1470 RealType multA, RealType multB);
1537 return getA(frame).transpose() * v;
1559 void addProperty(std::shared_ptr<GenericData> genData);
1588 StuntDouble(ObjectType objType, DataStoragePointer storage);
1593 ObjectType objType_;
1594 DataStoragePointer storage_;
1601 int globalIntegrableObjectIndex_;
PropertyMap class maintains a list of GenericData.
Quaternion is a sort of a higher-level complex number.
The Snapshot class is a repository storing dynamic data during a Simulation.
SnapshotManager class is an abstract class which maintains a series of snapshots.
Snapshot * getPrevSnapshot()
Returns the pointer of previous snapshot.
Snapshot * getCurrentSnapshot()
Returns the pointer of current snapshot.
"Don't move, or you're dead! Stand up! Captain, we've got them!"
void setFlucQVel(RealType cvel)
Sets the current charge velocity of this stuntDouble.
Quat4d getQ()
Returns the current quaternion of this stuntDouble.
Mat3x3d getPrevQuadrupole()
Returns the previous quadrupole tensor of this stuntDouble.
void addPrevFlucQFrc(RealType cfrc)
Adds charge force into the previous charge force of this stuntDouble.
RealType getPrevDensity()
Returns the previous density of this stuntDouble.
void combineForcesAndTorques(Snapshot *snapA, Snapshot *snapB, RealType multA, RealType multB)
Linearly combines the properties from two different snapshots.
void setPrevTrq(const Vector3d &trq)
Sets the previous torque of this stuntDouble.
void addPrevFrc(const Vector3d &frc)
Adds force into the previous force of this stuntDouble.
void setPrevEuler(const Vector3d &euler)
Sets the previous euler angles of this stuntDouble.
void zeroForcesAndTorques()
Set the properties of this stuntDouble to zero.
Vector3d getTrq()
Returns the current torque of this stuntDouble.
virtual void setPrevA(const RotMat3x3d &a)
Sets the previous rotation matrix of this stuntDouble.
RotMat3x3d getPrevA()
Returns the previous rotation matrix of this stuntDouble.
void addFlucQFrc(RealType cfrc)
Adds charge force into the current charge force of this stuntDouble.
void setPrevFrc(const Vector3d &frc)
Sets the previous force of this stuntDouble.
Vector3d getPrevVel()
Returns the previous velocity of this stuntDouble.
Vector3d lab2Body(const Vector3d &v)
Converts a lab fixed vector to a body fixed vector.
RealType getSitePotential(int snapshotNo)
Returns the site potential of this stuntDouble in specified snapshot.
void setPrevParticlePot(const RealType &particlePot)
Sets the previous particlePot of this stuntDouble.
RotMat3x3d getA()
Returns the current rotation matrix of this stuntDouble.
void addFlucQPos(RealType charge, int snapshotNo)
Adds fluctuating charge into the fluctuating charge of this stuntDouble in specified snapshot.
Vector3d getVel()
Returns the current velocity of this stuntDouble.
virtual void setA(const RotMat3x3d &a)
Sets the current rotation matrix of this stuntDouble.
void addElectricField(const Vector3d &eField)
Adds electric field into the current electric field of this stuntDouble.
virtual void accept(BaseVisitor *v)=0
void setElectricField(const Vector3d &eField, int snapshotNo)
Sets the electric field of this stuntDouble in specified snapshot.
Vector3d getVel(int snapshotNo)
Returns the velocity of this stuntDouble in specified snapshot.
Vector3d getJ(int snapshotNo)
Returns the angular momentum of this stuntDouble in specified snapshot (body-fixed).
int linearAxis()
Returns the linear axis of the rigidbody, atom and directional atom will always return -1.
Vector3d getEuler(int snapshotNo)
Returns the euler angles of this stuntDouble in specified snapshot.
Vector3d getEuler()
Returns the current euler angles of this stuntDouble.
Vector3d getElectricField(int snapshotNo)
Returns the electric field of this stuntDouble in specified snapshot.
void setPrevElectricField(const Vector3d &eField)
Sets the previous electric field of this stuntDouble.
RealType getFlucQVel(int snapshotNo)
Returns the charge velocity of this stuntDouble in specified snapshot.
Vector3d getPrevJ()
Returns the previous angular momentum of this stuntDouble (body-fixed).
void setDensity(RealType dens, int snapshotNo)
Sets the density of this stuntDouble in specified snapshot.
void addPrevFlucQVel(RealType cvel)
Adds charge velocity into the previous charge velocity of this stuntDouble.
void setParticlePot(const RealType &particlePot, int snapshotNo)
Sets the particlePot of this stuntDouble in specified snapshot.
RealType getMass()
Returns the mass of this stuntDouble.
void setEuler(const Vector3d &euler, int snapshotNo)
Sets the euler angles of this stuntDouble in specified snapshot.
void setPrevVel(const Vector3d &vel)
Sets the previous velocity of this stuntDouble.
Mat3x3d getQuadrupole()
Returns the current quadrupole tensor of this stuntDouble.
void addPrevDensity(RealType dens)
Adds density into the previous charge force of this stuntDouble.
Vector3d getPrevDipole()
Returns the previous dipole vector of this stuntDouble.
void addPrevParticlePot(const RealType &particlePot)
Adds particlePot into the previous particlePot of this stuntDouble.
std::vector< std::shared_ptr< GenericData > > getProperties()
Returns all of the properties in PropertyMap.
Vector3d getPos(int snapshotNo)
Returns the position of this stuntDouble in specified snapshot.
bool isDirectionalAtom()
Tests if this stuntDouble is an directional atom.
Vector3d getCOMvel(int snapshotNo)
Returns system Center of Mass velocity for stuntDouble frame from snapshot.
std::shared_ptr< GenericData > getPropertyByName(const std::string &propName)
Returns property.
virtual Mat3x3d getI()=0
Returns the inertia tensor of this stuntDouble.
void setPos(const Vector3d &pos, int snapshotNo)
Sets the position of this stuntDouble in specified snapshot.
void addProperty(std::shared_ptr< GenericData > genData)
Adds property into property map.
virtual std::string getType()=0
Returns the name of this stuntDouble.
void setQ(const Quat4d &q, int snapshotNo)
Sets the quaternion of this stuntDouble in specified snapshot.
void setFlucQPos(RealType charge)
Sets the current fluctuating charge of this stuntDouble.
Vector3d getCOMvel()
Returns system Center of Mass velocity for stuntDouble frame from snapshot.
bool isLinear()
Tests the if this stuntDouble is a linear rigidbody.
void setFrc(const Vector3d &frc, int snapshotNo)
Sets the force of this stuntDouble in specified snapshot.
void addDensity(RealType dens)
Adds density into the current charge force of this stuntDouble.
void setParticlePot(const RealType &particlePot)
Sets the current particlePot of this stuntDouble.
Vector3d getPos()
Returns the current position of this stuntDouble.
Vector3d body2Lab(const Vector3d &v)
Converts a body fixed vector to a lab fixed vector.
void setPrevFlucQFrc(RealType cfrc)
Sets the previous charge force of this stuntDouble.
RealType getFlucQFrc(int snapshotNo)
Returns the charge force of this stuntDouble in specified snapshot.
RealType getFlucQFrc()
Returns the current charge force of this stuntDouble.
void addPrevElectricField(const Vector3d &eField)
Adds electric field into the previous electric field of this stuntDouble.
RealType getFlucQPos(int snapshotNo)
Returns the fluctuating charge of this stuntDouble in specified snapshot.
void addFlucQVel(RealType cvel)
Adds charge velocity into the current charge velocity of this stuntDouble.
void setSitePotential(RealType spot)
Sets the current site potential of this stuntDouble.
RealType getFlucQPos()
Returns the current fluctuating charge of this stuntDouble.
void setPos(const Vector3d &pos)
Sets the current position of this stuntDouble.
Vector3d getDipole()
Returns the current dipole vector of this stuntDouble.
void addPrevSitePotential(RealType spot)
Adds site potential into the previous charge force of this stuntDouble.
RealType getPrevFlucQFrc()
Returns the previous charge force of this stuntDouble.
Vector3d getElectricField()
Returns the current electric field of this stuntDouble.
Vector3d getFrc(int snapshotNo)
Returns the force of this stuntDouble in specified snapshot.
void setJ(const Vector3d &angMom, int snapshotNo)
Sets the angular momentum of this stuntDouble in specified snapshot(body-fixed).
RealType getParticlePot(int snapshotNo)
Returns the particlePot of this stuntDouble in specified snapshot.
Vector3d getPrevTrq()
Returns the previous torque of this stuntDouble.
void setTrq(const Vector3d &trq)
Sets the current torque of this stuntDouble.
void addPrevTrq(const Vector3d &trq)
Adds torque into the previous torque of this stuntDouble.
Mat3x3d getQuadrupole(int snapshotNo)
Returns the quadrupole tensor of this stuntDouble in specified snapshot.
void setGlobalIndex(int index)
Sets the global index of this stuntDouble.
Vector3d getPrevFrc()
Returns the previous force of this stuntDouble.
Vector3d getCOM()
Returns system Center of Mass for stuntDouble frame from snapshot.
void addPrevFlucQPos(RealType charge)
Adds fluctuating charge into the previous fluctuating charge of this stuntDouble.
Quat4d getPrevQ()
Returns the previous quaternion of this stuntDouble.
void setSnapshotManager(SnapshotManager *sman)
Sets the Snapshot Manager of this stuntDouble.
RealType getParticlePot()
Returns the current particlePot of this stuntDouble.
Vector3d getCOM(int snapshotNo)
Returns system Center of Mass for stuntDouble frame from snapshot.
RealType getSitePotential()
Returns the current site potential of this stuntDouble.
RealType getDensity()
Returns the current density of this stuntDouble.
std::vector< std::string > getPropertyNames()
Returns all names of properties.
void setTrq(const Vector3d &trq, int snapshotNo)
Sets the torque of this stuntDouble in specified snapshot.
void setElectricField(const Vector3d &eField)
Sets the current electric field of this stuntDouble.
void setPrevFlucQPos(RealType charge)
Sets the previous fluctuating charge of this stuntDouble.
void setEuler(const Vector3d &euler)
Sets the current euler angles of this stuntDouble.
void removeProperty(const std::string &propName)
Removes property from PropertyMap by name.
void setVel(const Vector3d &vel)
Sets the current velocity of this stuntDouble.
void addTrq(const Vector3d &trq)
Adds torque into the current torque of this stuntDouble.
RealType getPrevParticlePot()
Returns the previous particlePot of this stuntDouble.
void addDensity(RealType dens, int snapshotNo)
Adds density into the density of this stuntDouble in specified snapshot.
Vector3d getCOMw()
Returns system Center of Mass angular momentum for stuntDouble frame from snapshot.
void setPrevDensity(RealType dens)
Sets the previous density of this stuntDouble.
void addParticlePot(const RealType &particlePot)
Adds particlePot into the current particlePot of this stuntDouble.
RealType getPrevSitePotential()
Returns the previous site potential of this stuntDouble.
bool isRigidBody()
Tests if this stuntDouble is a rigid body.
Vector3d getTrq(int snapshotNo)
Returns the torque of this stuntDouble in specified snapshot.
virtual void setA(const RotMat3x3d &a, int snapshotNo)
Sets the rotation matrix of this stuntDouble in specified snapshot.
Vector3d getJ()
Returns the current angular momentum of this stuntDouble (body -fixed).
Quat4d getQ(int snapshotNo)
Returns the quaternion of this stuntDouble in specified snapshot.
void setFlucQVel(RealType cvel, int snapshotNo)
Sets the charge velocity of this stuntDouble in specified snapshot.
int getGlobalIndex()
Returns the global index of this stuntDouble.
void addSitePotential(RealType spot, int snapshotNo)
Adds site potential into the site potential of this stuntDouble in specified snapshot.
RealType getDensity(int snapshotNo)
Returns the density of this stuntDouble in specified snapshot.
void setPrevSitePotential(RealType spot)
Sets the previous site potential of this stuntDouble.
bool isAtom()
Tests if this stuntDouble is an atom.
RealType getPrevFlucQPos()
Returns the previous fluctuating charge of this stuntDouble.
void addElectricField(const Vector3d &eField, int snapshotNo)
Adds electric field into the electric field of this stuntDouble in specified snapshot.
RotMat3x3d getA(int snapshotNo)
Returns the rotation matrix of this stuntDouble in specified snapshot.
void addParticlePot(const RealType &particlePot, int snapshotNo)
Adds particlePot into the particlePot of this stuntDouble in specified snapshot.
void addTrq(const Vector3d &trq, int snapshotNo)
Adds torque into the torque of this stuntDouble in specified snapshot.
Vector3d getCOMw(int snapshotNo)
Returns system Center of Mass angular momentum for stuntDouble frame from snapshot.
Vector3d getPrevPos()
Returns the previous position of this stuntDouble.
void setPrevFlucQVel(RealType cvel)
Sets the previous charge velocity of this stuntDouble.
void setQ(const Quat4d &q)
Sets the current quaternion of this stuntDouble.
Vector3d getPrevEuler()
Returns the previous euler angles of this stuntDouble.
bool isDirectional()
Tests if this stuntDouble is a directional one.
Vector3d getDipole(int snapshotNo)
Returns the dipole vector of this stuntDouble in specified snapshot.
int freeze()
Freezes out all velocity, angular velocity, forces and torques on this StuntDouble.
void addFlucQVel(RealType cvel, int snapshotNo)
Adds charge velocity into the charge velocity of this stuntDouble in specified snapshot.
RealType getPrevFlucQVel()
Returns the previous charge velocity of this stuntDouble.
Vector3d getFrc()
Returns the current force of this stuntDouble.
int getLocalIndex()
Returns the local index of this stuntDouble.
void setMass(RealType mass)
Sets the mass of this stuntdoulbe.
Vector3d getPrevElectricField()
Returns the previous electric field of this stuntDouble.
virtual void setType(const std::string &)
Sets the name of this stuntDouble.
void addSitePotential(RealType spot)
Adds site potential into the current charge force of this stuntDouble.
void setFrc(const Vector3d &frc)
Sets the current force of this stuntDouble.
void setJ(const Vector3d &angMom)
Sets the current angular momentum of this stuntDouble (body-fixed).
void setVel(const Vector3d &vel, int snapshotNo)
Sets the velocity of this stuntDouble in specified snapshot.
void setFlucQFrc(RealType cfrc)
Sets the current charge force of this stuntDouble.
virtual std::vector< RealType > getGrad()=0
Returns the gradient of this stuntDouble.
void setPrevJ(const Vector3d &angMom)
Sets the previous angular momentum of this stuntDouble (body-fixed).
void addFlucQPos(RealType charge)
Adds fluctuating charge into the current fluctuating charge of this stuntDouble.
RealType getFlucQVel()
Returns the current charge velocity of this stuntDouble.
void setFlucQFrc(RealType cfrc, int snapshotNo)
Sets the charge force of this stuntDouble in specified snapshot.
void setSitePotential(RealType spot, int snapshotNo)
Sets the site potential of this stuntDouble in specified snapshot.
void setLocalIndex(int index)
Sets the local index of this stuntDouble.
void setFlucQPos(RealType charge, int snapshotNo)
Sets the fluctuating charge of this stuntDouble in specified snapshot.
void setDensity(RealType dens)
Sets the current density of this stuntDouble.
void setPrevPos(const Vector3d &pos)
Sets the previous position of this stuntDouble.
void addFrc(const Vector3d &frc)
Adds force into the current force of this stuntDouble.
void addFlucQFrc(RealType cfrc, int snapshotNo)
Adds charge force into the charge force of this stuntDouble in specified snapshot.
void addFrc(const Vector3d &frc, int snapshotNo)
Adds force into the force of this stuntDouble in specified snapshot.
void setPrevQ(const Quat4d &q)
Sets the previous quaternion of this stuntDouble.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.