1 |
< |
#ifndef _MOLECULE_H_ |
2 |
< |
#define _MOLECULE_H_ |
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 |
< |
#include <set> |
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 "Atom.hpp" |
39 |
< |
#include "SRI.hpp" |
40 |
< |
#include "MoleculeStamp.hpp" |
41 |
< |
#include "RigidBody.hpp" |
42 |
< |
#include "CutoffGroup.hpp" |
38 |
> |
#include "math/Vector3.hpp" |
39 |
> |
#include "primitives/Atom.hpp" |
40 |
> |
#include "primitives/RigidBody.hpp" |
41 |
> |
//#include "primitives/Bond.hpp" |
42 |
> |
//#include "primitives/Bend.hpp" |
43 |
> |
//#include "primitives/Torsion.hpp" |
44 |
> |
#include "primitives/SRI.hpp" |
45 |
> |
#include "primitives/CutoffGroup.hpp" |
46 |
|
|
47 |
< |
using namespace std; |
47 |
> |
namespace oopse{ |
48 |
|
|
49 |
< |
typedef struct{ |
16 |
< |
|
17 |
< |
int stampID; // the ID in the BASS component stamp array |
18 |
< |
int nAtoms; // the number of atoms in the molecule |
19 |
< |
int nBonds; // ... .. .. . .bonds .. .. . . . . |
20 |
< |
int nBends; // . . . . .. . .bends . . . . .. . |
21 |
< |
int nTorsions; // .. . . .. . . torsions . . .. . . |
22 |
< |
int nRigidBodies; // .. .. .. . rigid bodies ... .. |
23 |
< |
int nOriented; // .. . . . .. . oriented atoms . . . |
24 |
< |
|
25 |
< |
Atom** myAtoms; // the array of atoms |
26 |
< |
Bond** myBonds; // arrays of all the short range interactions |
27 |
< |
Bend** myBends; |
28 |
< |
Torsion** myTorsions; |
29 |
< |
vector<RigidBody*> myRigidBodies; |
30 |
< |
vector<StuntDouble*> myIntegrableObjects; |
31 |
< |
vector<CutoffGroup*> myCutoffGroups; |
32 |
< |
} molInit; |
49 |
> |
class Constraint; |
50 |
|
|
51 |
< |
class Molecule{ |
51 |
> |
/** |
52 |
> |
* @class Molecule Molecule.hpp "primitives/Molecule.hpp" |
53 |
> |
* @brief |
54 |
> |
*/ |
55 |
> |
class Molecule { |
56 |
> |
public: |
57 |
|
|
58 |
< |
public: |
59 |
< |
|
60 |
< |
Molecule( void ); |
61 |
< |
~Molecule( void ); |
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 |
|
|
66 |
< |
void initialize( molInit &theInit ); |
66 |
> |
Molecule(int stampId, int globalIndex, const std::string& molName); |
67 |
> |
virtual ~Molecule(); |
68 |
|
|
69 |
< |
void setMyIndex( int theIndex ){ myIndex = theIndex;} |
70 |
< |
int getMyIndex( void ) { return myIndex; } |
69 |
> |
/** |
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 |
|
|
77 |
< |
int getGlobalIndex( void ) { return globalIndex; } |
78 |
< |
void setGlobalIndex( int theIndex ) { globalIndex = theIndex; } |
77 |
> |
/** |
78 |
> |
* 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 |
< |
int getNAtoms ( void ) {return nAtoms;} |
87 |
< |
int getNBonds ( void ) {return nBonds;} |
88 |
< |
int getNBends ( void ) {return nBends;} |
89 |
< |
int getNTorsions( void ) {return nTorsions;} |
90 |
< |
int getNRigidBodies( void ) {return myRigidBodies.size();} |
91 |
< |
int getNOriented( void ) {return nOriented;} |
92 |
< |
int getNMembers ( void ) {return nMembers;} |
93 |
< |
int getStampID ( void ) {return stampID;} |
86 |
> |
/** Returns the name of the molecule */ |
87 |
> |
std::string getType() { |
88 |
> |
return moleculeName_; |
89 |
> |
} |
90 |
> |
|
91 |
> |
/** |
92 |
> |
* Sets the global index of this molecule. |
93 |
> |
* @param new global index to be set |
94 |
> |
*/ |
95 |
> |
int setGlobalIndex(int index) { |
96 |
> |
return globalIndex_; |
97 |
> |
} |
98 |
|
|
99 |
< |
Atom** getMyAtoms ( void ) {return myAtoms;} |
100 |
< |
Bond** getMyBonds ( void ) {return myBonds;} |
101 |
< |
Bend** getMyBends ( void ) {return myBends;} |
61 |
< |
Torsion** getMyTorsions( void ) {return myTorsions;} |
62 |
< |
vector<RigidBody*> getMyRigidBodies( void ) {return myRigidBodies;} |
63 |
< |
vector<StuntDouble*>& getIntegrableObjects(void) {return myIntegrableObjects;} |
99 |
> |
|
100 |
> |
/** add an atom into this molecule */ |
101 |
> |
void addAtom(Atom* atom); |
102 |
|
|
103 |
< |
//beginCutoffGroup return the first group and initialize the iterator |
104 |
< |
CutoffGroup* beginCutoffGroup(vector<CutoffGroup*>::iterator& i){ |
67 |
< |
i = myCutoffGroups.begin(); |
68 |
< |
return i != myCutoffGroups.end()? *i : NULL; |
69 |
< |
} |
103 |
> |
/** add a bond into this molecule */ |
104 |
> |
void addBond(Bond* bond); |
105 |
|
|
106 |
< |
//nextCutoffGroup return next cutoff group based on the iterator |
107 |
< |
CutoffGroup* nextCutoffGroup(vector<CutoffGroup*>::iterator& i){ |
73 |
< |
i++; |
74 |
< |
return i != myCutoffGroups.end()? *i : NULL; |
75 |
< |
} |
106 |
> |
/** add a bend into this molecule */ |
107 |
> |
void addBend(Bend* bend); |
108 |
|
|
109 |
< |
int getNCutoffGroups() {return nCutoffGroups;} |
109 |
> |
/** add a torsion into this molecule*/ |
110 |
> |
void addTorsion(Torsion* torsion); |
111 |
|
|
112 |
< |
void setStampID( int info ) {stampID = info;} |
112 |
> |
/** add a rigidbody into this molecule */ |
113 |
> |
void addRigidBody(RigidBody *rb); |
114 |
|
|
115 |
< |
void calcForces( void ); |
116 |
< |
void atoms2rigidBodies( void ); |
83 |
< |
double getPotential( void ); |
84 |
< |
|
85 |
< |
void printMe( void ); |
115 |
> |
/** add a cutoff group into this molecule */ |
116 |
> |
void addCutoffGroup(CutoffGroup* cp); |
117 |
|
|
118 |
< |
void getCOM( double COM[3] ); |
119 |
< |
void moveCOM( double delta[3] ); |
89 |
< |
double getCOMvel( double COMvel[3] ); |
90 |
< |
|
91 |
< |
double getTotalMass(); |
118 |
> |
/** */ |
119 |
> |
void complete(); |
120 |
|
|
121 |
< |
private: |
121 |
> |
/** Returns the total number of atoms in this molecule */ |
122 |
> |
unsigned int getNAtoms() { |
123 |
> |
return atoms_.size(); |
124 |
> |
} |
125 |
|
|
126 |
< |
int stampID; // the ID in the BASS component stamp array |
127 |
< |
int nAtoms; // the number of atoms in the molecule |
128 |
< |
int nBonds; // ... .. .. . .bonds .. .. . . . . |
129 |
< |
int nBends; // . . . . .. . .bends . . . . .. . |
99 |
< |
int nTorsions; // .. . . .. . . torsions . . .. . . |
100 |
< |
int nRigidBodies; // .. . . .. .rigid bodies . . .. . . |
101 |
< |
int nOriented; // .. . . . .. . oriented atoms . . . |
102 |
< |
int nMembers; // .. . . . . . .atoms (legacy code) . . . |
103 |
< |
int nCutoffGroups; |
104 |
< |
|
105 |
< |
int myIndex; // mostly just for debug (and for making pressure calcs work) |
106 |
< |
int globalIndex; |
126 |
> |
/** Returns the total number of bonds in this molecule */ |
127 |
> |
unsigned int getNBonds(){ |
128 |
> |
return bonds_.size(); |
129 |
> |
} |
130 |
|
|
131 |
< |
Atom** myAtoms; // the array of atoms |
132 |
< |
Bond** myBonds; // arrays of all the short range interactions |
133 |
< |
Bend** myBends; |
134 |
< |
Torsion** myTorsions; |
135 |
< |
vector<RigidBody*> myRigidBodies; |
136 |
< |
vector<StuntDouble*> myIntegrableObjects; |
137 |
< |
vector<CutoffGroup*> myCutoffGroups; |
131 |
> |
/** Returns the total number of bends in this molecule */ |
132 |
> |
unsigned int getNBends() { |
133 |
> |
return bends_.size(); |
134 |
> |
} |
135 |
> |
|
136 |
> |
/** Returns the total number of torsions in this molecule */ |
137 |
> |
unsigned int getNTorsions() { |
138 |
> |
return torsions_.size(); |
139 |
> |
} |
140 |
> |
|
141 |
> |
/** Returns the total number of rigid bodies in this molecule */ |
142 |
> |
unsigned int getNRigidBodies() { |
143 |
> |
return rigidBodies_.size(); |
144 |
> |
} |
145 |
> |
|
146 |
> |
/** Returns the total number of integrable objects in this molecule */ |
147 |
> |
unsigned int getNIntegrableObjects() { |
148 |
> |
return integrableObjects_.size(); |
149 |
> |
} |
150 |
> |
|
151 |
> |
/** Returns the total number of cutoff groups in this molecule */ |
152 |
> |
unsigned int getNCutoffGroups() { |
153 |
> |
return cutoffGroups_.size(); |
154 |
> |
} |
155 |
> |
|
156 |
> |
/** Returns the total number of constraints in this molecule */ |
157 |
> |
unsigned int getNConstraints() { |
158 |
> |
return constraints_.size(); |
159 |
> |
} |
160 |
> |
|
161 |
> |
Atom* getAtomAt(unsigned int i) { |
162 |
> |
assert(i < atoms_.size()); |
163 |
> |
return atoms_[i]; |
164 |
> |
} |
165 |
> |
/** |
166 |
> |
* Returns the first atom in this molecule and initialize the iterator. |
167 |
> |
* @return the first atom, return NULL if there is not cut off group in this molecule |
168 |
> |
* @param i iteraotr |
169 |
> |
*/ |
170 |
> |
Atom* beginAtom(std::vector<Atom*>::iterator& i); |
171 |
> |
|
172 |
> |
Atom* nextAtom(std::vector<Atom*>::iterator& i); |
173 |
> |
|
174 |
> |
/** |
175 |
> |
* Returns the first bond in this molecule and initialize the iterator. |
176 |
> |
* @return the first bond, return NULL if there is not cut off group in this molecule |
177 |
> |
* @param i iteraotr |
178 |
> |
*/ |
179 |
> |
Bond* beginBond(std::vector<Bond*>::iterator& i); |
180 |
> |
|
181 |
> |
Bond* nextBond(std::vector<Bond*>::iterator& i); |
182 |
> |
|
183 |
> |
/** |
184 |
> |
* Returns the first bend in this molecule and initialize the iterator. |
185 |
> |
* @return the first bend, return NULL if there is not cut off group in this molecule |
186 |
> |
* @param i iteraotr |
187 |
> |
*/ |
188 |
> |
Bend* beginBend(std::vector<Bend*>::iterator& i); |
189 |
> |
|
190 |
> |
Bend* nextBend(std::vector<Bend*>::iterator& i); |
191 |
> |
|
192 |
> |
/** |
193 |
> |
* Returns the first torsion in this molecule and initialize the iterator. |
194 |
> |
* @return the first torsion, return NULL if there is not cut off group in this molecule |
195 |
> |
* @param i iteraotr |
196 |
> |
*/ |
197 |
> |
Torsion* beginTorsion(std::vector<Torsion*>::iterator& i); |
198 |
> |
Torsion* nextTorsion(std::vector<Torsion*>::iterator& i); |
199 |
> |
|
200 |
> |
/** |
201 |
> |
* Returns the first rigid body in this molecule and initialize the iterator. |
202 |
> |
* @return the first rigid body, return NULL if there is not cut off group in this molecule |
203 |
> |
* @param i iteraotr |
204 |
> |
*/ |
205 |
> |
RigidBody* beginRigidBody(std::vector<RigidBody*>::iterator& i); |
206 |
> |
|
207 |
> |
RigidBody* nextRigidBody(std::vector<RigidBody*>::iterator& i); |
208 |
> |
|
209 |
> |
/** |
210 |
> |
* Returns the first integrable object in this molecule and initialize the iterator. |
211 |
> |
* @return the first integrable object, return NULL if there is not cut off group in this molecule |
212 |
> |
* @param i iteraotr |
213 |
> |
*/ |
214 |
> |
StuntDouble* beginIntegrableObject(std::vector<StuntDouble*>::iterator& i); |
215 |
> |
|
216 |
> |
StuntDouble* nextIntegrableObject(std::vector<StuntDouble*>::iterator& i); |
217 |
> |
|
218 |
> |
/** |
219 |
> |
* Returns the first cutoff group in this molecule and initialize the iterator. |
220 |
> |
* @return the first cutoff group, return NULL if there is not cut off group in this molecule |
221 |
> |
* @param i iteraotr |
222 |
> |
*/ |
223 |
> |
CutoffGroup* beginCutoffGroup(std::vector<CutoffGroup*>::iterator& i); |
224 |
> |
|
225 |
> |
/** |
226 |
> |
* Returns next cutoff group based on the iterator |
227 |
> |
* @return next cutoff group |
228 |
> |
* @param i |
229 |
> |
*/ |
230 |
> |
CutoffGroup* nextCutoffGroup(std::vector<CutoffGroup*>::iterator& i); |
231 |
> |
|
232 |
> |
Constraint* beginConstraint(std::vector<Constraint*>::iterator& i); |
233 |
> |
|
234 |
> |
Constraint* nextConstraint(std::vector<Constraint*>::iterator& i); |
235 |
> |
|
236 |
> |
//void setStampID( int info ) {stampID = info;} |
237 |
> |
|
238 |
> |
void calcForces( void ); |
239 |
> |
|
240 |
> |
void atoms2rigidBodies( void ); |
241 |
> |
|
242 |
> |
/** return the total potential energy of short range interaction of this molecule */ |
243 |
> |
double getPotential(); |
244 |
> |
|
245 |
> |
|
246 |
> |
/** return the center of mass of this molecule */ |
247 |
> |
Vector3d getCom(); |
248 |
> |
|
249 |
> |
/** Moves the center of this molecule */ |
250 |
> |
void moveCom(const Vector3d& delta); |
251 |
> |
|
252 |
> |
/** Returns the velocity of center of mass of this molecule */ |
253 |
> |
Vector3d getComVel(); |
254 |
> |
|
255 |
> |
/** Returns the total mass of this molecule */ |
256 |
> |
double getTotalMass(); |
257 |
> |
|
258 |
> |
friend std::ostream& operator <<(std::ostream& o, Molecule& mol); |
259 |
> |
|
260 |
> |
private: |
261 |
> |
|
262 |
> |
int globalIndex_; |
263 |
> |
|
264 |
> |
std::vector<Atom*> atoms_; |
265 |
> |
std::vector<Bond*> bonds_; |
266 |
> |
std::vector<Bend*> bends_; |
267 |
> |
std::vector<Torsion*> torsions_; |
268 |
> |
std::vector<RigidBody*> rigidBodies_; |
269 |
> |
std::vector<StuntDouble*> integrableObjects_; |
270 |
> |
std::vector<CutoffGroup*> cutoffGroups_; |
271 |
> |
std::vector<Constraint*> constraints_; |
272 |
> |
|
273 |
> |
int stampId_; |
274 |
> |
std::string moleculeName_; |
275 |
|
}; |
276 |
|
|
277 |
< |
#endif |
277 |
> |
} //namespace oopse |
278 |
> |
#endif // |