ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/primitives/RigidBody.hpp
(Generate patch)

Comparing trunk/OOPSE-4/src/primitives/RigidBody.hpp (file contents):
Revision 1492 by tim, Fri Sep 24 16:27:58 2004 UTC vs.
Revision 1973 by tim, Fri Feb 4 22:41:23 2005 UTC

# Line 1 | Line 1
1 < #ifndef __RIGIDBODY_HPP__
2 < #define __RIGIDBODY_HPP__
1 > /*
2 > * 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  
49 + #ifndef PRIMITIVES_RIGIDBODY_HPP
50 + #define PRIMITIVES_RIGIDBODY_HPP
51 +
52   #include <vector>
5 //#include "primitives/Atom.hpp"
6 //#include "types/AtomStamp.hpp"
7 #include "types/RigidBodyStamp.hpp"
8 #include "primitives/StuntDouble.hpp"
9 using namespace std;
53  
54 < class Atom;
55 < class AtomStamp;
56 <
57 < typedef struct {
15 <  double vec[3];
16 <  double& operator[](int index) {return vec[index];}  
17 < } vec3;
18 <
19 < typedef struct {
20 <  double mat[3][3];
21 <  double* operator[](int index) {return mat[index];}  
22 < } mat3x3;
23 <
54 > #include "primitives/StuntDouble.hpp"
55 > #include "primitives/DirectionalAtom.hpp"
56 > #include "types/AtomStamp.hpp"
57 > namespace oopse{
58   class RigidBody : public StuntDouble {
59 +    public:
60  
61 < public:
27 <  
28 <  RigidBody();
29 <  //RigidBody(const RigidBody& rb);
30 <  
31 <  virtual ~RigidBody();
32 <
33 <  void addAtom(Atom* at, AtomStamp* ats);
61 >        typedef std::vector<Atom*>::iterator AtomIterator;        
62  
63 <  void getPos( double theP[3] );
36 <  void setPos( double theP[3] );
63 >        RigidBody();
64  
65 <  void getVel( double theV[3] );
66 <  void setVel( double theV[3] );
65 >        virtual std::string getType() { return name_;}
66 >        
67 >        /** Sets the name of this stuntdouble*/
68 >        virtual void setType(const std::string& name) { name_ = name;}
69 >    
70  
71 <  void getFrc( double theF[3] );
72 <  void addFrc( double theF[3] );
73 <  void zeroForces();
74 <  
75 <  virtual bool isLinear() {return is_linear;}
76 <  virtual int linearAxis() {return linear_axis;}
71 >       /**
72 >         * Sets  the previous rotation matrix of this stuntdouble
73 >         * @param a  new rotation matrix
74 >         */        
75 >       virtual void setPrevA(const RotMat3x3d& a);
76 >      
77 >       /**
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  
92 <  double getMass( void ) { return mass; }
92 >        /**
93 >         * Returns the inertia tensor of this stuntdouble
94 >         * @return the inertia tensor of this stuntdouble
95 >         */
96 >        virtual Mat3x3d getI();
97  
50  void printAmatIndex( void );
51  void setEuler( double phi, double theta, double psi );
52  void getQ( double the_q[4] ); // get the quanternions
53  void setQ( double the_q[4] );
98  
99 <  void getA( double the_A[3][3] ); // get the full rotation matrix
100 <  void setA( double the_A[3][3] );
99 >        /** Sets the internal unit frame of this stuntdouble by three euler angles */
100 >        void setElectroFrameFromEuler(double phi, double theta, double psi);
101 >        
102 >        /**
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  
109 <  void getJ( double theJ[3] );
59 <  void setJ( double theJ[3] );
109 >        virtual void accept(BaseVisitor* v);
110  
111 <  virtual void setType(char* type) {strcpy(rbName, type);}
62 <  virtual char* getType() { return rbName;}
111 >        void addAtom(Atom* at, AtomStamp* ats);
112  
113 <  void getTrq( double theT[3] );
114 <  void addTrq( double theT[3] );
113 >        /** calculate the reference coordinates */
114 >        void calcRefCoords();
115  
116 <  void getI( double the_I[3][3] );
117 <  void lab2Body( double r[3] );
69 <  void body2Lab( double r[3] );
116 >        /** Convert Atomic forces and torques to total forces and torques */
117 >        void calcForcesAndTorques();
118  
119 <  double getZangle( );
120 <  void setZangle( double zAng );
73 <  void addZangle( double zAng );
119 >        /** update the positions of atoms belong to this rigidbody */
120 >        void updateAtoms();
121  
122 <  void calcRefCoords( void );
123 <  void doEulerToRotMat(vec3 &euler, mat3x3 &myA );
124 <  void calcForcesAndTorques( void );
125 <  void updateAtoms( void );
122 >        Atom* beginAtom(std::vector<Atom*>::iterator& i) {
123 >            i = atoms_.begin();
124 >            return i != atoms_.end() ? *i : NULL;
125 >        }
126  
127 <  //void yourAtomsHaveMoved( void );
127 >        Atom* nextAtom(std::vector<Atom*>::iterator& i) {
128 >            ++i;
129 >            return i != atoms_.end() ? *i : NULL;
130 >        }
131  
132 <  // Four functions added for derivatives with respect to Euler Angles:
133 <  // (Needed for minimization routines):
132 >        std::vector<Atom*>::iterator getBeginAtomIter() {
133 >            return atoms_.begin();
134 >        }
135 >        
136 >        std::vector<Atom*>::iterator getEndAtomIter() {
137 >            return atoms_.end();
138 >        }
139  
140 <  void getGrad(double gradient[6] );
141 <  void getEulerAngles( double myEuler[3] );
142 <
143 <  double max(double x, double y);
144 <  double min(double x, double y);
140 >        /**
141 >         * Returns the atoms of this rigid body
142 >         * @return the atoms of this rigid body in a vector
143 >         * @deprecate
144 >         */          
145 >        std::vector<Atom*> getAtoms() {
146 >            return atoms_;
147 >        }
148  
149 +        /**
150 +         * Returns the number of atoms in this rigid body
151 +         * @return the number of atoms in this rigid body
152 +         */
153 +        int getNumAtoms() {
154 +            return atoms_.size();
155 +        }
156  
157 <  // utility routines
157 >        /**
158 >         * Return the position of atom which belongs to this rigid body.
159 >         * @return true if index is valid otherwise return false
160 >         * @param pos the position of atom which will be set on return if index is valid
161 >         * @param index the index of the atom in rigid body's private data member atoms_
162 >         */
163 >        bool getAtomPos(Vector3d& pos, unsigned int index);
164  
165 <  void findCOM( void );
165 >        /**
166 >         * Return the position of atom which belongs to this rigid body.
167 >         * @return true if atom belongs to this rigid body,otherwise return false
168 >         * @param pos position of atom which will be set on return if atom belongs to this rigid body
169 >         * @param atom the pointer to an atom
170 >         */            
171 >        bool getAtomPos(Vector3d& pos, Atom* atom);
172  
173 <  virtual void accept(BaseVisitor* v);
173 >        /**
174 >         * Return the velocity of atom which belongs to this rigid body.
175 >         * @return true if index is valid otherwise return false
176 >         * @param vel the velocity of atom which will be set on return if index is valid
177 >         * @param index the index of the atom in rigid body's private data member atoms_
178 >         */
179 >        bool getAtomVel(Vector3d& vel, unsigned int index);
180  
181 <  vector<Atom*> getAtoms() { return myAtoms;}
182 <  int getNumAtoms() {return myAtoms.size();}
181 >        /**
182 >         * Return the velocity of atom which belongs to this rigid body.
183 >         * @return true if atom belongs to this rigid body,otherwise return false
184 >         * @param vel velocity of atom which will be set on return if atom belongs to this rigid body
185 >         * @param atom the pointer to an atom
186 >         */
187 >        bool getAtomVel(Vector3d& vel, Atom*);
188  
189 <  void getAtomPos(double theP[3], int index);
190 <  void getAtomVel(double theV[3], int index);
191 <  void getAtomRefCoor(double pos[3], int index);
192 < protected:
189 >        /**
190 >         * Return the reference coordinate of atom which belongs to this rigid body.
191 >         * @return true if index is valid otherwise return false
192 >         * @param coor the reference coordinate of atom which will be set on return if index is valid
193 >         * @param index the index of the atom in rigid body's private data member atoms_
194 >         */
195 >        bool getAtomRefCoor(Vector3d& coor, unsigned int index);
196  
197 <  double mass;     // the total mass
198 <  double pos[3];   // the position array (center of mass)
199 <  double vel[3];   // the velocity array (center of mass)
200 <  double frc[3];   // the force array    (center of mass)
201 <  double trq[3];   // the torque vector  ( space fixed )
202 <  double ji[3];    // the angular momentum vector (body fixed)
203 <  double A[3][3];  // the rotation matrix
113 <  double I[3][3];  // the inertial tensor (body fixed)
114 <  double sU[3][3]; // the standard unit vectors (body fixed)
115 <  double zAngle;   // the rotation about the z-axis (body fixed)
197 >        /**
198 >         * Return the velocity of atom which belongs to this rigid body.
199 >         * @return true if atom belongs to this rigid body,otherwise return false
200 >         * @param coor velocity of atom which will be set on return if atom belongs to this rigid body
201 >         * @param atom the pointer to an atom
202 >         */
203 >        bool getAtomRefCoor(Vector3d& coor, Atom* atom);
204  
205 <  bool is_linear;
206 <  int linear_axis;
207 <  double momIntTol;
205 >    private:
206 >        std::string name_;        
207 >        Mat3x3d inertiaTensor_;    
208 >        RotMat3x3d sU_;               /**< body fixed standard unit vector */
209 >        
210 >        std::vector<Atom*> atoms_;
211 >        std::vector<Vector3d> refCoords_;
212 >        std::vector<RotMat3x3d> refOrients_;
213 > };
214  
215 <  vector<Atom*> myAtoms;  // the vector of atoms
122 <  vector<vec3> refCoords;
123 <  vector<mat3x3> refOrients;
215 > }//namepace oopse
216  
217 <  char rbName[100]; //it will eventually be converted into string
126 < };
217 > #endif //PRIMITIVES_RIGIDBODY_HPP
218  
128 #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines