ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/primitives/RigidBody.hpp
Revision: 2204
Committed: Fri Apr 15 22:04:00 2005 UTC (19 years, 2 months ago) by gezelter
File size: 7787 byte(s)
Log Message:
xemacs has been drafted to perform our indentation services

File Contents

# User Rev Content
1 gezelter 2204 /*
2 gezelter 1930 * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3     *
4     * The University of Notre Dame grants you ("Licensee") a
5     * non-exclusive, royalty free, license to use, modify and
6     * redistribute this software in source and binary code form, provided
7     * that the following conditions are met:
8     *
9     * 1. Acknowledgement of the program authors must be made in any
10     * publication of scientific results based in part on use of the
11     * program. An acceptable form of acknowledgement is citation of
12     * the article in which the program was described (Matthew
13     * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14     * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15     * Parallel Simulation Engine for Molecular Dynamics,"
16     * J. Comput. Chem. 26, pp. 252-271 (2005))
17     *
18     * 2. Redistributions of source code must retain the above copyright
19     * notice, this list of conditions and the following disclaimer.
20     *
21     * 3. Redistributions in binary form must reproduce the above copyright
22     * notice, this list of conditions and the following disclaimer in the
23     * documentation and/or other materials provided with the
24     * distribution.
25     *
26     * This software is provided "AS IS," without a warranty of any
27     * kind. All express or implied conditions, representations and
28     * warranties, including any implied warranty of merchantability,
29     * fitness for a particular purpose or non-infringement, are hereby
30     * excluded. The University of Notre Dame and its licensors shall not
31     * be liable for any damages suffered by licensee as a result of
32     * using, modifying or distributing the software or its
33     * derivatives. In no event will the University of Notre Dame or its
34     * licensors be liable for any lost revenue, profit or data, or for
35     * direct, indirect, special, consequential, incidental or punitive
36     * damages, however caused and regardless of the theory of liability,
37     * arising out of the use of or inability to use software, even if the
38     * University of Notre Dame has been advised of the possibility of
39     * such damages.
40     */
41    
42     /**
43     * @file RigidBody.hpp
44     * @author tlin
45     * @date 10/23/2004
46     * @version 1.0
47     */
48 gezelter 1490
49 gezelter 1930 #ifndef PRIMITIVES_RIGIDBODY_HPP
50     #define PRIMITIVES_RIGIDBODY_HPP
51    
52 gezelter 1490 #include <vector>
53 gezelter 1930
54 tim 1492 #include "primitives/StuntDouble.hpp"
55 gezelter 1930 #include "primitives/DirectionalAtom.hpp"
56     #include "types/AtomStamp.hpp"
57     namespace oopse{
58 gezelter 2204 class RigidBody : public StuntDouble {
59     public:
60 tim 1968
61 gezelter 2204 typedef std::vector<Atom*>::iterator AtomIterator;
62 tim 1968
63 gezelter 2204 RigidBody();
64 gezelter 1490
65 gezelter 2204 virtual std::string getType() { return name_;}
66 gezelter 1930
67 gezelter 2204 /** Sets the name of this stuntdouble*/
68     virtual void setType(const std::string& name) { name_ = name;}
69 gezelter 1930
70 gezelter 1490
71 gezelter 2204 /**
72     * Sets the previous rotation matrix of this stuntdouble
73     * @param a new rotation matrix
74     */
75     virtual void setPrevA(const RotMat3x3d& a);
76 gezelter 1930
77 gezelter 2204 /**
78     * Sets the current rotation matrix of this stuntdouble
79     * @param a new rotation matrix
80     * @note setA will not change the position and rotation matrix of Directional atoms belong to
81     * this rigidbody. If you want to do that, use #updateAtoms
82     */
83     virtual void setA(const RotMat3x3d& a);
84     /**
85     * Sets the rotation matrix of this stuntdouble in specified snapshot
86     * @param a rotation matrix to be set
87     * @param snapshotNo
88     * @see #getA
89     */
90     virtual void setA(const RotMat3x3d& a, int snapshotNo);
91 gezelter 1490
92 gezelter 2204 /**
93     * Returns the inertia tensor of this stuntdouble
94     * @return the inertia tensor of this stuntdouble
95     */
96     virtual Mat3x3d getI();
97 gezelter 1490
98    
99 gezelter 2204 /** Sets the internal unit frame of this stuntdouble by three euler angles */
100     void setElectroFrameFromEuler(double phi, double theta, double psi);
101 gezelter 1930
102 gezelter 2204 /**
103     * Returns the gradient of this stuntdouble
104     * @return the inertia tensor of this stuntdouble
105     * @see #setI
106     */
107     virtual std::vector<double> getGrad();
108 gezelter 1490
109 gezelter 2204 virtual void accept(BaseVisitor* v);
110 gezelter 1490
111 gezelter 2204 void addAtom(Atom* at, AtomStamp* ats);
112 gezelter 1490
113 gezelter 2204 /** calculate the reference coordinates */
114     void calcRefCoords();
115 gezelter 1490
116 gezelter 2204 /** Convert Atomic forces and torques to total forces and torques */
117     void calcForcesAndTorques();
118 gezelter 1490
119 gezelter 2204 /** update the positions of atoms belong to this rigidbody */
120     void updateAtoms();
121 gezelter 1490
122 gezelter 2204 void updateAtoms(int frame);
123 tim 2002
124 gezelter 2204 void updateAtomVel();
125 tim 2002
126 gezelter 2204 void updateAtomVel(int frame);
127 tim 2002
128 gezelter 2204 Atom* beginAtom(std::vector<Atom*>::iterator& i) {
129     i = atoms_.begin();
130     return i != atoms_.end() ? *i : NULL;
131     }
132 gezelter 1490
133 gezelter 2204 Atom* nextAtom(std::vector<Atom*>::iterator& i) {
134     ++i;
135     return i != atoms_.end() ? *i : NULL;
136     }
137 gezelter 1490
138 gezelter 2204 std::vector<Atom*>::iterator getBeginAtomIter() {
139     return atoms_.begin();
140     }
141 gezelter 1930
142 gezelter 2204 std::vector<Atom*>::iterator getEndAtomIter() {
143     return atoms_.end();
144     }
145 gezelter 1490
146 gezelter 2204 /**
147     * Returns the atoms of this rigid body
148     * @return the atoms of this rigid body in a vector
149     * @deprecate
150     */
151     std::vector<Atom*> getAtoms() {
152     return atoms_;
153     }
154 gezelter 1490
155 gezelter 2204 /**
156     * Returns the number of atoms in this rigid body
157     * @return the number of atoms in this rigid body
158     */
159     int getNumAtoms() {
160     return atoms_.size();
161     }
162 gezelter 1490
163 gezelter 2204 /**
164     * Return the position of atom which belongs to this rigid body.
165     * @return true if index is valid otherwise return false
166     * @param pos the position of atom which will be set on return if index is valid
167     * @param index the index of the atom in rigid body's private data member atoms_
168     */
169     bool getAtomPos(Vector3d& pos, unsigned int index);
170 gezelter 1490
171 gezelter 2204 /**
172     * Return the position of atom which belongs to this rigid body.
173     * @return true if atom belongs to this rigid body,otherwise return false
174     * @param pos position of atom which will be set on return if atom belongs to this rigid body
175     * @param atom the pointer to an atom
176     */
177     bool getAtomPos(Vector3d& pos, Atom* atom);
178 gezelter 1490
179 gezelter 2204 /**
180     * Return the velocity of atom which belongs to this rigid body.
181     * @return true if index is valid otherwise return false
182     * @param vel the velocity of atom which will be set on return if index is valid
183     * @param index the index of the atom in rigid body's private data member atoms_
184     */
185     bool getAtomVel(Vector3d& vel, unsigned int index);
186 gezelter 1490
187 gezelter 2204 /**
188     * Return the velocity of atom which belongs to this rigid body.
189     * @return true if atom belongs to this rigid body,otherwise return false
190     * @param vel velocity of atom which will be set on return if atom belongs to this rigid body
191     * @param atom the pointer to an atom
192     */
193     bool getAtomVel(Vector3d& vel, Atom*);
194 gezelter 1490
195 gezelter 2204 /**
196     * Return the reference coordinate of atom which belongs to this rigid body.
197     * @return true if index is valid otherwise return false
198     * @param coor the reference coordinate of atom which will be set on return if index is valid
199     * @param index the index of the atom in rigid body's private data member atoms_
200     */
201     bool getAtomRefCoor(Vector3d& coor, unsigned int index);
202 gezelter 1490
203 gezelter 2204 /**
204     * Return the velocity of atom which belongs to this rigid body.
205     * @return true if atom belongs to this rigid body,otherwise return false
206     * @param coor velocity of atom which will be set on return if atom belongs to this rigid body
207     * @param atom the pointer to an atom
208     */
209     bool getAtomRefCoor(Vector3d& coor, Atom* atom);
210 gezelter 1490
211 gezelter 2204 private:
212     std::string name_;
213     Mat3x3d inertiaTensor_;
214     RotMat3x3d sU_; /**< body fixed standard unit vector */
215 gezelter 1930
216 gezelter 2204 std::vector<Atom*> atoms_;
217     std::vector<Vector3d> refCoords_;
218     std::vector<RotMat3x3d> refOrients_;
219     };
220 gezelter 1490
221 gezelter 1930 }//namepace oopse
222 gezelter 1490
223 gezelter 1930 #endif //PRIMITIVES_RIGIDBODY_HPP
224 gezelter 1490