| 51 |
|
|
| 52 |
|
void RigidBody::setPrevA(const RotMat3x3d& a) { |
| 53 |
|
((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_] = a; |
| 54 |
– |
//((snapshotMan_->getPrevSnapshot())->*storage_).electroFrame[localIndex_] = a.transpose() * sU_; |
| 54 |
|
|
| 55 |
|
for (int i =0 ; i < atoms_.size(); ++i){ |
| 56 |
|
if (atoms_[i]->isDirectional()) { |
| 57 |
< |
atoms_[i]->setPrevA(a * refOrients_[i]); |
| 57 |
> |
atoms_[i]->setPrevA(refOrients_[i].transpose() * a); |
| 58 |
|
} |
| 59 |
|
} |
| 60 |
|
|
| 63 |
|
|
| 64 |
|
void RigidBody::setA(const RotMat3x3d& a) { |
| 65 |
|
((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_] = a; |
| 67 |
– |
//((snapshotMan_->getCurrentSnapshot())->*storage_).electroFrame[localIndex_] = a.transpose() * sU_; |
| 66 |
|
|
| 67 |
|
for (int i =0 ; i < atoms_.size(); ++i){ |
| 68 |
|
if (atoms_[i]->isDirectional()) { |
| 69 |
< |
atoms_[i]->setA(a * refOrients_[i]); |
| 69 |
> |
atoms_[i]->setA(refOrients_[i].transpose() * a); |
| 70 |
|
} |
| 71 |
|
} |
| 72 |
|
} |
| 77 |
|
|
| 78 |
|
for (int i =0 ; i < atoms_.size(); ++i){ |
| 79 |
|
if (atoms_[i]->isDirectional()) { |
| 80 |
< |
atoms_[i]->setA(a * refOrients_[i], snapshotNo); |
| 80 |
> |
atoms_[i]->setA(refOrients_[i].transpose() * a, snapshotNo); |
| 81 |
|
} |
| 82 |
|
} |
| 83 |
|
|
| 87 |
|
return inertiaTensor_; |
| 88 |
|
} |
| 89 |
|
|
| 90 |
< |
std::vector<double> RigidBody::getGrad() { |
| 91 |
< |
std::vector<double> grad(6, 0.0); |
| 90 |
> |
std::vector<RealType> RigidBody::getGrad() { |
| 91 |
> |
std::vector<RealType> grad(6, 0.0); |
| 92 |
|
Vector3d force; |
| 93 |
|
Vector3d torque; |
| 94 |
|
Vector3d myEuler; |
| 95 |
< |
double phi, theta, psi; |
| 96 |
< |
double cphi, sphi, ctheta, stheta; |
| 95 |
> |
RealType phi, theta, psi; |
| 96 |
> |
RealType cphi, sphi, ctheta, stheta; |
| 97 |
|
Vector3d ephi; |
| 98 |
|
Vector3d etheta; |
| 99 |
|
Vector3d epsi; |
| 146 |
|
|
| 147 |
|
/**@todo need modification */ |
| 148 |
|
void RigidBody::calcRefCoords() { |
| 149 |
< |
double mtmp; |
| 149 |
> |
RealType mtmp; |
| 150 |
|
Vector3d refCOM(0.0); |
| 151 |
|
mass_ = 0.0; |
| 152 |
|
for (std::size_t i = 0; i < atoms_.size(); ++i) { |
| 167 |
|
Mat3x3d IAtom(0.0); |
| 168 |
|
mtmp = atoms_[i]->getMass(); |
| 169 |
|
IAtom -= outProduct(refCoords_[i], refCoords_[i]) * mtmp; |
| 170 |
< |
double r2 = refCoords_[i].lengthSquare(); |
| 170 |
> |
RealType r2 = refCoords_[i].lengthSquare(); |
| 171 |
|
IAtom(0, 0) += mtmp * r2; |
| 172 |
|
IAtom(1, 1) += mtmp * r2; |
| 173 |
|
IAtom(2, 2) += mtmp * r2; |
| 245 |
|
|
| 246 |
|
} |
| 247 |
|
|
| 248 |
< |
setFrc(frc); |
| 249 |
< |
setTrq(trq); |
| 248 |
> |
addFrc(frc); |
| 249 |
> |
addTrq(trq); |
| 250 |
|
|
| 251 |
|
} |
| 252 |
|
|
| 269 |
|
if (atoms_[i]->isDirectional()) { |
| 270 |
|
|
| 271 |
|
dAtom = (DirectionalAtom *) atoms_[i]; |
| 272 |
< |
dAtom->setA(refOrients_[i] * a); |
| 272 |
> |
dAtom->setA(refOrients_[i].transpose() * a); |
| 273 |
|
} |
| 274 |
|
|
| 275 |
|
} |
| 296 |
|
if (atoms_[i]->isDirectional()) { |
| 297 |
|
|
| 298 |
|
dAtom = (DirectionalAtom *) atoms_[i]; |
| 299 |
< |
dAtom->setA(refOrients_[i] * a, frame); |
| 299 |
> |
dAtom->setA(refOrients_[i].transpose() * a, frame); |
| 300 |
|
} |
| 301 |
|
|
| 302 |
|
} |
| 481 |
|
"RigidBody error.\n" |
| 482 |
|
"\tAtom %s does not have a position specified.\n" |
| 483 |
|
"\tThis means RigidBody cannot set up reference coordinates.\n", |
| 484 |
< |
ats->getType() ); |
| 484 |
> |
ats->getType().c_str() ); |
| 485 |
|
painCave.isFatal = 1; |
| 486 |
|
simError(); |
| 487 |
|
} |
| 501 |
|
"RigidBody error.\n" |
| 502 |
|
"\tAtom %s does not have an orientation specified.\n" |
| 503 |
|
"\tThis means RigidBody cannot set up reference orientations.\n", |
| 504 |
< |
ats->getType() ); |
| 504 |
> |
ats->getType().c_str() ); |
| 505 |
|
painCave.isFatal = 1; |
| 506 |
|
simError(); |
| 507 |
|
} |