ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/primitives/Molecule.hpp
Revision: 1901
Committed: Tue Jan 4 22:18:36 2005 UTC (19 years, 6 months ago) by tim
File size: 9406 byte(s)
Log Message:
constraints in progress

File Contents

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