ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/primitives/RigidBody.hpp
Revision: 1813
Committed: Wed Dec 1 17:38:32 2004 UTC (19 years, 9 months ago) by tim
File size: 7278 byte(s)
Log Message:
refactory AtomType

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