1 |
tim |
1686 |
/* |
2 |
|
|
* Copyright (C) 2000-2004 Object Oriented Parallel Simulation Engine (OOPSE) project |
3 |
|
|
* |
4 |
|
|
* Contact: oopse@oopse.org |
5 |
|
|
* |
6 |
|
|
* This program is free software; you can redistribute it and/or |
7 |
|
|
* modify it under the terms of the GNU Lesser General Public License |
8 |
|
|
* as published by the Free Software Foundation; either version 2.1 |
9 |
|
|
* of the License, or (at your option) any later version. |
10 |
|
|
* All we ask is that proper credit is given for our work, which includes |
11 |
|
|
* - but is not limited to - adding the above copyright notice to the beginning |
12 |
|
|
* of your source code files, and to any copyright notice that you may distribute |
13 |
|
|
* with programs based on this work. |
14 |
|
|
* |
15 |
|
|
* This program is distributed in the hope that it will be useful, |
16 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
|
|
* GNU Lesser General Public License for more details. |
19 |
|
|
* |
20 |
|
|
* You should have received a copy of the GNU Lesser General Public License |
21 |
|
|
* along with this program; if not, write to the Free Software |
22 |
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23 |
|
|
* |
24 |
|
|
*/ |
25 |
|
|
|
26 |
|
|
/** |
27 |
|
|
* @file Molecule.hpp |
28 |
|
|
* @author tlin |
29 |
|
|
* @date 10/25/2004 |
30 |
|
|
* @version 1.0 |
31 |
|
|
*/ |
32 |
|
|
|
33 |
|
|
#include "primitives/Molecule.hpp" |
34 |
|
|
|
35 |
|
|
namespace oopse { |
36 |
|
|
|
37 |
|
|
Molecule::~Molecule() { |
38 |
|
|
|
39 |
|
|
deleteVectorOfPointer(atoms_); |
40 |
|
|
deleteVectorOfPointer(bonds_); |
41 |
|
|
deleteVectorOfPointer(bends_); |
42 |
|
|
deleteVectorOfPointer(torsions_); |
43 |
|
|
deleteVectorOfPointer(rigidbodies_); |
44 |
|
|
deleteVectorOfPointer(cutoffGroups_); |
45 |
|
|
|
46 |
|
|
integrableObjects_.clear(); |
47 |
|
|
|
48 |
|
|
} |
49 |
|
|
|
50 |
|
|
|
51 |
|
|
Atom* Molecule::beginAtom(std::vector<Atom*>::iterator& i) { |
52 |
|
|
i = atoms_.begin(); |
53 |
|
|
return (i == atoms_.end()) ? NULL : *i; |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
Atom* Molecule::nextAtom(std::vector<Atom*>::iterator& i) { |
57 |
|
|
++i; |
58 |
|
|
return (i == atoms_.end()) ? NULL : *i; |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
Bond* Molecule::beginBond(std::vector<Bond*>::iterator& i) { |
62 |
|
|
i = bonds_.begin(); |
63 |
|
|
return (i == bonds_.end()) ? NULL : *i; |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
Bond* Molecule::nextBond(std::vector<Bond*>::iterator& i) { |
67 |
|
|
++i; |
68 |
|
|
return (i == bonds_.end()) ? NULL : *i; |
69 |
|
|
|
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
|
73 |
|
|
Bend* Molecule::beginBend(std::vector<Bend*>::iterator& i) { |
74 |
|
|
i = bends_.begin(); |
75 |
|
|
return (i == bends_.end()) ? NULL : *i; |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
Bend* Molecule::nextBend(std::vector<Bend*>::iterator& i) { |
79 |
|
|
++i; |
80 |
|
|
return (i == bends_.end()) ? NULL : *i; |
81 |
|
|
} |
82 |
|
|
|
83 |
|
|
Torsion* Molecule::beginTorsion(std::vector<Torsion*>::iterator& i) { |
84 |
|
|
i = torsions_.begin(); |
85 |
|
|
return (i == torsions_.end()) ? NULL : *i; |
86 |
|
|
} |
87 |
|
|
|
88 |
|
|
Torsion* Molecule::nextTorsion(std::vector<Torsion*>::iterator& i) { |
89 |
|
|
++i; |
90 |
|
|
return (i == torsions_.end()) ? NULL : *i; |
91 |
|
|
} |
92 |
|
|
|
93 |
|
|
RigidBody* Molecule::beginRigidBody(std::vector<RigidBody*>::iterator& i) { |
94 |
|
|
i = rigidBodies_.begin(); |
95 |
|
|
return (i == rigidBodies_.end()) ? NULL : *i; |
96 |
|
|
} |
97 |
|
|
|
98 |
|
|
RigidBody* Molecule::nextRigidBody(std::vector<RigidBody*>::iterator& i) { |
99 |
|
|
++i; |
100 |
|
|
return (i == rigidBodies_.end()) ? NULL : *i; |
101 |
|
|
} |
102 |
|
|
|
103 |
|
|
StuntDouble* Molecule::beginIntegrableObject(std::vector<StuntDouble*>::iterator& i) { |
104 |
|
|
i = integrableObjects_.begin(); |
105 |
|
|
return (i == integrableObjects_.end()) ? NULL : *i; |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
StuntDouble* Molecule::nextIntegrableObject(std::vector<StuntDouble*>::iterator& i) { |
109 |
|
|
++i; |
110 |
|
|
return (i == integrableObjects_.end()) ? NULL : *i; |
111 |
|
|
} |
112 |
|
|
|
113 |
|
|
CutoffGroup* Molecule::beginCutoffGroup(std::vector<CutoffGroup*>::iterator& i) { |
114 |
|
|
i = cutoffGroups_.begin(); |
115 |
|
|
return (i == cutoffGroups_.end()) ? NULL : *i; |
116 |
|
|
} |
117 |
|
|
|
118 |
|
|
CutoffGroup* Molecule::nextCutoffGroup(std::vector<CutoffGroup*>::iterator& i) { |
119 |
|
|
++i; |
120 |
|
|
return (i == cutoffGroups_.end()) ? NULL : *i; |
121 |
|
|
} |
122 |
|
|
|
123 |
|
|
void Molecule::calcForces() { |
124 |
|
|
RigidBody* rb; |
125 |
|
|
Bond* bond; |
126 |
|
|
Bend* bend; |
127 |
|
|
Torsion* torsion; |
128 |
|
|
std::vector<RigidBody*> rbIter; |
129 |
|
|
std::vector<Bond*> bondIter;; |
130 |
|
|
std::vector<Bend*> bendIter; |
131 |
|
|
std::vector<Torsion*> torsionIter; |
132 |
|
|
|
133 |
|
|
for (rb = beginRigidBody(rbIter); rb != NULL; rb = nextRigidBody(rbIter)) { |
134 |
|
|
rb->updateAtoms(); |
135 |
|
|
} |
136 |
|
|
|
137 |
|
|
for (bond = beginBond(bondIter); bond != NULL; bond = nextBond(bondIter)) { |
138 |
|
|
bond->calcForce(); |
139 |
|
|
} |
140 |
|
|
|
141 |
|
|
for (bend = beginBend(bendIter); bend != NULL; bend = nextBend(bendIter)) { |
142 |
|
|
bend->calcForce(); |
143 |
|
|
} |
144 |
|
|
|
145 |
|
|
for (torsion = beginTorsion(torsionIter); torsion != NULL; torsion = nextTorsion(torsionIter)) { |
146 |
|
|
torsion->calcForce(); |
147 |
|
|
} |
148 |
|
|
|
149 |
|
|
} |
150 |
|
|
|
151 |
|
|
}//end namespace oopse |