ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-4/src/primitives/Molecule.hpp
Revision: 1910
Committed: Fri Jan 7 21:50:13 2005 UTC (19 years, 7 months ago) by tim
File size: 9780 byte(s)
Log Message:
ZConstraintForceManager in progress

File Contents

# Content
1 /*
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 #ifndef PRIMITIVES_MOLECULE_HPP
34 #define PRIMITIVES_MOLECULE_HPP
35 #include <vector>
36 #include <iostream>
37
38 #include "constraints/ConstraintPair.hpp"
39 #include "math/Vector3.hpp"
40 #include "primitives/Atom.hpp"
41 #include "primitives/RigidBody.hpp"
42 #include "primitives/Bond.hpp"
43 #include "primitives/Bend.hpp"
44 #include "primitives/Torsion.hpp"
45 #include "primitives/CutoffGroup.hpp"
46
47 namespace oopse{
48
49 class Constraint;
50
51 /**
52 * @class Molecule Molecule.hpp "primitives/Molecule.hpp"
53 * @brief
54 */
55 class Molecule {
56 public:
57
58 typedef std::vector<Atom*>::iterator AtomIterator;
59 typedef std::vector<Bond*>::iterator BondIterator;
60 typedef std::vector<Bend*>::iterator BendIterator;
61 typedef std::vector<Torsion*>::iterator TorsionIterator;
62 typedef std::vector<RigidBody*>::iterator RigidBodyIterator;
63 typedef std::vector<CutoffGroup*>::iterator CutoffGroupIterator;
64 typedef std::vector<StuntDouble*>::iterator IntegrableObjectIterator;
65 typedef std::vector<ConstraintPair*>::iterator ConstraintPairIterator;
66 typedef std::vector<ConstraintElem*>::iterator ConstraintElemIterator;
67
68
69 Molecule(int stampId, int globalIndex, const std::string& molName);
70 virtual ~Molecule();
71
72 /**
73 * Returns the global index of this molecule.
74 * @return the global index of this molecule
75 */
76 int getGlobalIndex() {
77 return globalIndex_;
78 }
79
80 /**
81 * Returns the stamp id of this molecule
82 * @note Ideally, every molecule should keep a pointer of its molecule stamp instead of its
83 * stamp id. However, the pointer will become invalid, if the molecule migrate to other processor.
84 */
85 int getStampId() {
86 return stampId_;
87 }
88
89 /** Returns the name of the molecule */
90 std::string getType() {
91 return moleculeName_;
92 }
93
94 /**
95 * Sets the global index of this molecule.
96 * @param new global index to be set
97 */
98 int setGlobalIndex(int index) {
99 return globalIndex_;
100 }
101
102
103 /** add an atom into this molecule */
104 void addAtom(Atom* atom);
105
106 /** add a bond into this molecule */
107 void addBond(Bond* bond);
108
109 /** add a bend into this molecule */
110 void addBend(Bend* bend);
111
112 /** add a torsion into this molecule*/
113 void addTorsion(Torsion* torsion);
114
115 /** add a rigidbody into this molecule */
116 void addRigidBody(RigidBody *rb);
117
118 /** add a cutoff group into this molecule */
119 void addCutoffGroup(CutoffGroup* cp);
120
121 void addConstraintPair(ConstraintPair* consPair);
122
123 void addConstraintElem(ConstraintElem* consElem);
124
125 /** */
126 void complete();
127
128 /** Returns the total number of atoms in this molecule */
129 unsigned int getNAtoms() {
130 return atoms_.size();
131 }
132
133 /** Returns the total number of bonds in this molecule */
134 unsigned int getNBonds(){
135 return bonds_.size();
136 }
137
138 /** Returns the total number of bends in this molecule */
139 unsigned int getNBends() {
140 return bends_.size();
141 }
142
143 /** Returns the total number of torsions in this molecule */
144 unsigned int getNTorsions() {
145 return torsions_.size();
146 }
147
148 /** Returns the total number of rigid bodies in this molecule */
149 unsigned int getNRigidBodies() {
150 return rigidBodies_.size();
151 }
152
153 /** Returns the total number of integrable objects in this molecule */
154 unsigned int getNIntegrableObjects() {
155 return integrableObjects_.size();
156 }
157
158 /** Returns the total number of cutoff groups in this molecule */
159 unsigned int getNCutoffGroups() {
160 return cutoffGroups_.size();
161 }
162
163 /** Returns the total number of constraints in this molecule */
164 unsigned int getNConstraintPairs() {
165 return constraintPairs_.size();
166 }
167
168 Atom* getAtomAt(unsigned int i) {
169 assert(i < atoms_.size());
170 return atoms_[i];
171 }
172
173 Atom* beginAtom(std::vector<Atom*>::iterator& i) {
174 i = atoms_.begin();
175 return (i == atoms_.end()) ? NULL : *i;
176 }
177
178 Atom* nextAtom(std::vector<Atom*>::iterator& i) {
179 ++i;
180 return (i == atoms_.end()) ? NULL : *i;
181 }
182
183 Bond* beginBond(std::vector<Bond*>::iterator& i) {
184 i = bonds_.begin();
185 return (i == bonds_.end()) ? NULL : *i;
186 }
187
188 Bond* nextBond(std::vector<Bond*>::iterator& i) {
189 ++i;
190 return (i == bonds_.end()) ? NULL : *i;
191
192 }
193
194 Bend* beginBend(std::vector<Bend*>::iterator& i) {
195 i = bends_.begin();
196 return (i == bends_.end()) ? NULL : *i;
197 }
198
199 Bend* nextBend(std::vector<Bend*>::iterator& i) {
200 ++i;
201 return (i == bends_.end()) ? NULL : *i;
202 }
203
204 Torsion* beginTorsion(std::vector<Torsion*>::iterator& i) {
205 i = torsions_.begin();
206 return (i == torsions_.end()) ? NULL : *i;
207 }
208
209 Torsion* nextTorsion(std::vector<Torsion*>::iterator& i) {
210 ++i;
211 return (i == torsions_.end()) ? NULL : *i;
212 }
213
214 RigidBody* beginRigidBody(std::vector<RigidBody*>::iterator& i) {
215 i = rigidBodies_.begin();
216 return (i == rigidBodies_.end()) ? NULL : *i;
217 }
218
219 RigidBody* nextRigidBody(std::vector<RigidBody*>::iterator& i) {
220 ++i;
221 return (i == rigidBodies_.end()) ? NULL : *i;
222 }
223
224 StuntDouble* beginIntegrableObject(std::vector<StuntDouble*>::iterator& i) {
225 i = integrableObjects_.begin();
226 return (i == integrableObjects_.end()) ? NULL : *i;
227 }
228
229 StuntDouble* nextIntegrableObject(std::vector<StuntDouble*>::iterator& i) {
230 ++i;
231 return (i == integrableObjects_.end()) ? NULL : *i;
232 }
233
234 CutoffGroup* beginCutoffGroup(std::vector<CutoffGroup*>::iterator& i) {
235 i = cutoffGroups_.begin();
236 return (i == cutoffGroups_.end()) ? NULL : *i;
237 }
238
239 CutoffGroup* nextCutoffGroup(std::vector<CutoffGroup*>::iterator& i) {
240 ++i;
241 return (i == cutoffGroups_.end()) ? NULL : *i;
242 }
243
244 ConstraintPair* beginConstraintPair(std::vector<ConstraintPair*>::iterator& i) {
245 i = constraintPairs_.begin();
246 return (i == constraintPairs_.end()) ? NULL : *i;
247 }
248
249 ConstraintPair* nextConstraintPair(std::vector<ConstraintPair*>::iterator& i) {
250 ++i;
251 return (i == constraintPairs_.end()) ? NULL : *i;
252 }
253
254 ConstraintElem* beginConstraintElem(std::vector<ConstraintElem*>::iterator& i) {
255 i = constraintElems_.begin();
256 return (i == constraintElems_.end()) ? NULL : *i;
257 }
258
259 ConstraintElem* nextConstraintElem(std::vector<ConstraintElem*>::iterator& i) {
260 ++i;
261 return (i == constraintElems_.end()) ? NULL : *i;
262 }
263
264 /** return the total potential energy of short range interaction of this molecule */
265 double getPotential();
266
267 /** get total mass of this molecule */
268 double getMass();
269
270 /** return the center of mass of this molecule */
271 Vector3d getCom();
272
273 /** Moves the center of this molecule */
274 void moveCom(const Vector3d& delta);
275
276 /** Returns the velocity of center of mass of this molecule */
277 Vector3d getComVel();
278
279 friend std::ostream& operator <<(std::ostream& o, Molecule& mol);
280
281 private:
282
283 int globalIndex_;
284
285 std::vector<Atom*> atoms_;
286 std::vector<Bond*> bonds_;
287 std::vector<Bend*> bends_;
288 std::vector<Torsion*> torsions_;
289 std::vector<RigidBody*> rigidBodies_;
290 std::vector<StuntDouble*> integrableObjects_;
291 std::vector<CutoffGroup*> cutoffGroups_;
292 std::vector<ConstraintPair*> constraintPairs_;
293 std::vector<ConstraintElem*> constraintElems_;
294 int stampId_;
295 std::string moleculeName_;
296 };
297
298 } //namespace oopse
299 #endif //