ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-4/src/primitives/RigidBody.hpp
Revision: 1805
Committed: Tue Nov 30 20:50:47 2004 UTC (19 years, 7 months ago) by tim
File size: 7048 byte(s)
Log Message:
brains get built, io is next

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 RigidBody.hpp
28 * @author tlin
29 * @date 10/23/2004
30 * @version 1.0
31 */
32
33 #ifndef PRIMITIVES_RIGIDBODY_HPP
34 #define PRIMITIVES_RIGIDBODY_HPP
35
36 #include <vector>
37
38 #include "primitives/StuntDouble.hpp"
39 #include "primitives/DirectionalAtom.hpp"
40 #include "types/AtomStamp.hpp"
41 namespace oopse{
42 class RigidBody : public StuntDouble {
43 public:
44 RigidBody();
45
46 /**
47 * Sets the previous rotation matrix of this stuntdouble
48 * @param a new rotation matrix
49 */
50 virtual void setPrevA(const RotMat3x3d& a);
51
52 /**
53 * Sets the current rotation matrix of this stuntdouble
54 * @param a new rotation matrix
55 */
56 virtual void setA(const RotMat3x3d& a);
57 /**
58 * Sets the rotation matrix of this stuntdouble in specified snapshot
59 * @param a rotation matrix to be set
60 * @param snapshotNo
61 * @see #getA
62 */
63 virtual void setA(const RotMat3x3d& a, int snapshotNo);
64
65 /**
66 * Returns the inertia tensor of this stuntdouble
67 * @return the inertia tensor of this stuntdouble
68 */
69 virtual Mat3x3d getI();
70
71
72 /** Sets the internal unit frame of this stuntdouble by three euler angles */
73 void setUnitFrameFromEuler(double phi, double theta, double psi);
74
75 /**
76 * Returns the gradient of this stuntdouble
77 * @return the inertia tensor of this stuntdouble
78 * @see #setI
79 */
80 virtual std::vector<double> getGrad();
81
82 virtual void accept(BaseVisitor* v);
83
84 void addAtom(Atom* at, AtomStamp* ats);
85
86 /** calculate the reference coordinates */
87 void calcRefCoords();
88
89 /** Convert Atomic forces and torques to total forces and torques */
90 void calcForcesAndTorques();
91
92 /** update the positions of atoms belong to this rigidbody */
93 void updateAtoms();
94
95 Atom* beginAtom(std::vector<Atom*>::iterator& i);
96
97 Atom* nextAtom(std::vector<Atom*>::iterator& i);
98
99 std::vector<Atom*>::iterator getBeginAtomIter() {
100 return atoms_.begin();
101 }
102
103 std::vector<Atom*>::iterator getEndAtomIter() {
104 return atoms_.end();
105 }
106
107 /**
108 * Returns the atoms of this rigid body
109 * @return the atoms of this rigid body in a vector
110 * @deprecate
111 */
112 std::vector<Atom*> getAtoms() {
113 return atoms_;
114 }
115
116 /**
117 * Returns the number of atoms in this rigid body
118 * @return the number of atoms in this rigid body
119 */
120 int getNumAtoms() {
121 return atoms_.size();
122 }
123
124 /**
125 * Return the position of atom which belongs to this rigid body.
126 * @return true if index is valid otherwise return false
127 * @param pos the position of atom which will be set on return if index is valid
128 * @param index the index of the atom in rigid body's private data member atoms_
129 */
130 bool getAtomPos(Vector3d& pos, unsigned int index);
131
132 /**
133 * Return the position of atom which belongs to this rigid body.
134 * @return true if atom belongs to this rigid body,otherwise return false
135 * @param pos position of atom which will be set on return if atom belongs to this rigid body
136 * @param atom the pointer to an atom
137 */
138 bool getAtomPos(Vector3d& pos, Atom* atom);
139
140 /**
141 * Return the velocity of atom which belongs to this rigid body.
142 * @return true if index is valid otherwise return false
143 * @param vel the velocity of atom which will be set on return if index is valid
144 * @param index the index of the atom in rigid body's private data member atoms_
145 */
146 bool getAtomVel(Vector3d& vel, unsigned int index);
147
148 /**
149 * Return the velocity of atom which belongs to this rigid body.
150 * @return true if atom belongs to this rigid body,otherwise return false
151 * @param vel velocity of atom which will be set on return if atom belongs to this rigid body
152 * @param atom the pointer to an atom
153 */
154 bool getAtomVel(Vector3d& vel, Atom*);
155
156 /**
157 * Return the reference coordinate of atom which belongs to this rigid body.
158 * @return true if index is valid otherwise return false
159 * @param coor the reference coordinate of atom which will be set on return if index is valid
160 * @param index the index of the atom in rigid body's private data member atoms_
161 */
162 bool getAtomRefCoor(Vector3d& coor, unsigned int index);
163
164 /**
165 * Return the velocity of atom which belongs to this rigid body.
166 * @return true if atom belongs to this rigid body,otherwise return false
167 * @param coor velocity of atom which will be set on return if atom belongs to this rigid body
168 * @param atom the pointer to an atom
169 */
170 bool getAtomRefCoor(Vector3d& coor, Atom* atom);
171
172 private:
173
174 Mat3x3d inertiaTensor_;
175 RotMat3x3d sU_; /**< body fixed standard unit vector */
176
177 std::vector<Atom*> atoms_;
178 std::vector<Vector3d> refCoords_;
179 };
180
181 }//namepace oopse
182
183 #endif //PRIMITIVES_RIGIDBODY_HPP
184