32 |
|
*/ |
33 |
|
|
34 |
|
#include "brains/ForceManager.hpp" |
35 |
< |
|
35 |
> |
#include "primitives/Molecule.hpp" |
36 |
> |
#include "UseTheForce/doForces_interface.h" |
37 |
> |
#include "utils/simError.h" |
38 |
|
namespace oopse { |
39 |
|
|
40 |
|
void ForceManager::calcForces(bool needPotential, bool needStress) { |
47 |
|
|
48 |
|
calcShortRangeInteraction(); |
49 |
|
|
50 |
< |
calcLongRangeInteraction(); |
50 |
> |
calcLongRangeInteraction(needPotential, needStress); |
51 |
|
|
52 |
< |
postCalculation() |
52 |
> |
postCalculation(); |
53 |
|
|
54 |
|
} |
55 |
|
|
56 |
|
void ForceManager::preCalculation() { |
57 |
< |
typename SimInfo::MoleculeIterator mi; |
57 |
> |
SimInfo::MoleculeIterator mi; |
58 |
|
Molecule* mol; |
59 |
< |
typename Molecule::AtomIterator ai; |
59 |
> |
Molecule::AtomIterator ai; |
60 |
|
Atom* atom; |
61 |
|
|
62 |
|
// forces are zeroed here, before any are accumulated. |
75 |
|
Bond* bond; |
76 |
|
Bend* bend; |
77 |
|
Torsion* torsion; |
78 |
< |
typename SimInfo::MoleculeIterator mi; |
79 |
< |
typename Molecule::RigidBodyIterator rbIter; |
80 |
< |
typename Molecule::BondIterator bondIter;; |
81 |
< |
typename Molecule::BendIterator bendIter; |
82 |
< |
typename Molecule::TorsionIterator torsionIter; |
78 |
> |
SimInfo::MoleculeIterator mi; |
79 |
> |
Molecule::RigidBodyIterator rbIter; |
80 |
> |
Molecule::BondIterator bondIter;; |
81 |
> |
Molecule::BendIterator bendIter; |
82 |
> |
Molecule::TorsionIterator torsionIter; |
83 |
|
|
84 |
|
//calculate short range interactions |
85 |
|
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
90 |
|
} |
91 |
|
|
92 |
|
for (bond = mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { |
93 |
< |
bond->calc_forces(); |
93 |
> |
bond->calcForce(); |
94 |
|
} |
95 |
|
|
96 |
|
for (bend = mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) { |
97 |
< |
bend->calc_forces(); |
97 |
> |
bend->calcForce(); |
98 |
|
} |
99 |
|
|
100 |
|
for (torsion = mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { |
101 |
< |
torsion->calc_forces(); |
101 |
> |
torsion->calcForce(); |
102 |
|
} |
103 |
|
|
104 |
|
} |
112 |
|
double* pos; |
113 |
|
double* trq; |
114 |
|
double* A; |
115 |
< |
double* u_l; |
115 |
> |
double* unitFrame; |
116 |
|
double* rc; |
117 |
|
|
118 |
|
//get current snapshot from SimInfo |
119 |
< |
curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot() |
119 |
> |
curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
120 |
|
|
121 |
|
//get array pointers |
122 |
|
config = &(curSnapshot->atomData); |
124 |
|
pos = config->getArrayPointer(DataStorage::dslPosition); |
125 |
|
trq = config->getArrayPointer(DataStorage::dslTorque); |
126 |
|
A = config->getArrayPointer(DataStorage::dslAmat); |
127 |
< |
u_l = config->getArrayPointer(DataStorage::dslUnitVector); |
127 |
> |
unitFrame = config->getArrayPointer(DataStorage::dslUnitFrame); |
128 |
|
|
129 |
|
//calculate the center of mass of cutoff group |
130 |
< |
typename SimInfo::MoleculeIterator mi; |
130 |
> |
SimInfo::MoleculeIterator mi; |
131 |
|
Molecule* mol; |
132 |
< |
typename Molecule::CutoffGroupIterator ci; |
132 |
> |
Molecule::CutoffGroupIterator ci; |
133 |
|
CutoffGroup* cg; |
134 |
|
Vector3d com; |
135 |
|
std::vector<Vector3d> rcGroup; |
138 |
|
|
139 |
|
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
140 |
|
for(cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
141 |
< |
cg->getCOM(com) |
141 |
> |
cg->getCOM(com); |
142 |
|
rcGroup.push_back(com); |
143 |
|
} |
144 |
|
}// end for (mol) |
145 |
|
|
146 |
< |
rc = rcGroup[0]->getArrayPointer(); |
146 |
> |
rc = rcGroup[0].getArrayPointer(); |
147 |
|
} else { |
148 |
|
// center of mass of the group is the same as position of the atom if cutoff group does not exist |
149 |
|
rc = pos; |
159 |
|
doForceLoop( pos, |
160 |
|
rc, |
161 |
|
A, |
162 |
< |
u_l, |
162 |
> |
unitFrame, |
163 |
|
frc, |
164 |
|
trq, |
165 |
< |
tau, |
165 |
> |
tau.getArrayPointer(), |
166 |
|
&longRangePotential, |
167 |
|
&passedCalcPot, |
168 |
|
&passedCalcStress, |
176 |
|
} |
177 |
|
|
178 |
|
//store the tau and long range potential |
179 |
< |
curSnapshot->statData[Stats::LONGRANGEPOTENTIAL] = longRangePotential; |
179 |
> |
curSnapshot->statData[Stats::LONG_RANGE_POTENTIAL] = longRangePotential; |
180 |
|
curSnapshot->statData[Stats::TAUXX] = tau[0]; |
181 |
|
curSnapshot->statData[Stats::TAUXY] = tau[1]; |
182 |
|
curSnapshot->statData[Stats::TAUXZ] = tau[2]; |
190 |
|
|
191 |
|
|
192 |
|
void ForceManager::postCalculation() { |
193 |
< |
typename SimInfo::MoleculeIterator mi; |
193 |
> |
SimInfo::MoleculeIterator mi; |
194 |
|
Molecule* mol; |
195 |
< |
typename Molecule::RigidBodyIterator rbIter; |
195 |
> |
Molecule::RigidBodyIterator rbIter; |
196 |
|
RigidBody* rb; |
197 |
|
|
198 |
|
// collect the atomic forces onto rigid bodies |