ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/primitives/RigidBody.hpp
(Generate patch)

Comparing:
trunk/src/primitives/RigidBody.hpp (file contents), Revision 3 by tim, Fri Sep 24 16:27:58 2004 UTC vs.
branches/development/src/primitives/RigidBody.hpp (file contents), Revision 1808 by gezelter, Mon Oct 22 20:42:10 2012 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. Redistributions of source code must retain the above copyright
10 > *    notice, this list of conditions and the following disclaimer.
11 > *
12 > * 2. Redistributions in binary form must reproduce the above copyright
13 > *    notice, this list of conditions and the following disclaimer in the
14 > *    documentation and/or other materials provided with the
15 > *    distribution.
16 > *
17 > * This software is provided "AS IS," without a warranty of any
18 > * kind. All express or implied conditions, representations and
19 > * warranties, including any implied warranty of merchantability,
20 > * fitness for a particular purpose or non-infringement, are hereby
21 > * excluded.  The University of Notre Dame and its licensors shall not
22 > * be liable for any damages suffered by licensee as a result of
23 > * using, modifying or distributing the software or its
24 > * derivatives. In no event will the University of Notre Dame or its
25 > * licensors be liable for any lost revenue, profit or data, or for
26 > * direct, indirect, special, consequential, incidental or punitive
27 > * damages, however caused and regardless of the theory of liability,
28 > * arising out of the use of or inability to use software, even if the
29 > * University of Notre Dame has been advised of the possibility of
30 > * such damages.
31 > *
32 > * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 > * research, please cite the appropriate papers when you publish your
34 > * work.  Good starting points are:
35 > *                                                                      
36 > * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37 > * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
39 > * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 > * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41 > */
42 >
43 > /**
44 > * @file RigidBody.hpp
45 > * @author    tlin
46 > * @date  10/23/2004
47 > * @version 1.0
48 > */
49  
50 + #ifndef PRIMITIVES_RIGIDBODY_HPP
51 + #define PRIMITIVES_RIGIDBODY_HPP
52 +
53   #include <vector>
54 < //#include "primitives/Atom.hpp"
6 < //#include "types/AtomStamp.hpp"
7 < #include "types/RigidBodyStamp.hpp"
54 >
55   #include "primitives/StuntDouble.hpp"
56 < using namespace std;
56 > #include "primitives/DirectionalAtom.hpp"
57 > #include "types/AtomStamp.hpp"
58 > namespace OpenMD{
59 >  class RigidBody : public StuntDouble {
60 >  public:
61  
62 < class Atom;
12 < class AtomStamp;
62 >    typedef std::vector<Atom*>::iterator AtomIterator;        
63  
64 < typedef struct {
15 <  double vec[3];
16 <  double& operator[](int index) {return vec[index];}  
17 < } vec3;
64 >    RigidBody();
65  
66 < typedef struct {
67 <  double mat[3][3];
68 <  double* operator[](int index) {return mat[index];}  
69 < } mat3x3;
66 >    virtual std::string getType() { return name_;}
67 >        
68 >    /** Sets the name of this stuntRealType*/
69 >    virtual void setType(const std::string& name) { name_ = name;}
70 >    
71  
72 < class RigidBody : public StuntDouble {
72 >    /**
73 >     * Sets  the previous rotation matrix of this stuntdouble
74 >     * @param a  new rotation matrix
75 >     */        
76 >    virtual void setPrevA(const RotMat3x3d& a);
77 >      
78 >    /**
79 >     * Sets  the current rotation matrix of this stuntdouble
80 >     * @param a  new rotation matrix
81 >     * @note setA will not change the position and rotation matrix of Directional atoms belong to
82 >     * this rigidbody. If you want to do that, use #updateAtoms
83 >     */        
84 >    virtual void setA(const RotMat3x3d& a);
85 >    /**
86 >     * Sets  the rotation matrix of this stuntdouble in specified snapshot
87 >     * @param a rotation matrix to be set
88 >     * @param snapshotNo
89 >     * @see #getA
90 >     */        
91 >    virtual void setA(const RotMat3x3d& a, int snapshotNo);
92  
93 < public:
94 <  
95 <  RigidBody();
96 <  //RigidBody(const RigidBody& rb);
97 <  
31 <  virtual ~RigidBody();
32 <
33 <  void addAtom(Atom* at, AtomStamp* ats);
93 >    /**
94 >     * Returns the inertia tensor of this stuntdouble
95 >     * @return the inertia tensor of this stuntdouble
96 >     */
97 >    virtual Mat3x3d getI();
98  
99 <  void getPos( double theP[3] );
100 <  void setPos( double theP[3] );
99 >    /**
100 >     * Returns the gradient of this stuntdouble
101 >     * @return the gradient of this stuntdouble
102 >     */
103 >    virtual std::vector<RealType> getGrad();
104  
105 <  void getVel( double theV[3] );
39 <  void setVel( double theV[3] );
105 >    virtual void accept(BaseVisitor* v);
106  
107 <  void getFrc( double theF[3] );
42 <  void addFrc( double theF[3] );
43 <  void zeroForces();
44 <  
45 <  virtual bool isLinear() {return is_linear;}
46 <  virtual int linearAxis() {return linear_axis;}
107 >    void addAtom(Atom* at, AtomStamp* ats);
108  
109 <  double getMass( void ) { return mass; }
109 >    /** calculates the reference coordinates */
110 >    void calcRefCoords();
111  
112 <  void printAmatIndex( void );
113 <  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] );
112 >    /** Converts Atomic forces and torques to total forces and torques */
113 >    void calcForcesAndTorques();
114  
115 <  void getA( double the_A[3][3] ); // get the full rotation matrix
116 <  void setA( double the_A[3][3] );
115 >    /**
116 >        Converts Atomic forces and torques to total forces and torques
117 >        and computes the rigid body contribution to the virial.
118 >        Returns the rigid body contribution to the virial as a 3x3
119 >        matrix.
120 >        */
121 >    Mat3x3d calcForcesAndTorquesAndVirial();
122 >    
123 >    /** update the positions of atoms belong to this rigidbody */
124 >    void updateAtoms();
125  
126 <  void getJ( double theJ[3] );
59 <  void setJ( double theJ[3] );
126 >    void updateAtoms(int frame);
127  
128 <  virtual void setType(char* type) {strcpy(rbName, type);}
62 <  virtual char* getType() { return rbName;}
128 >    void updateAtomVel();
129  
130 <  void getTrq( double theT[3] );
131 <  void addTrq( double theT[3] );
130 >    void updateAtomVel(int frame);
131 >        
132 >    Atom* beginAtom(std::vector<Atom*>::iterator& i) {
133 >      i = atoms_.begin();
134 >      return i != atoms_.end() ? *i : NULL;
135 >    }
136  
137 <  void getI( double the_I[3][3] );
138 <  void lab2Body( double r[3] );
139 <  void body2Lab( double r[3] );
137 >    Atom* nextAtom(std::vector<Atom*>::iterator& i) {
138 >      ++i;
139 >      return i != atoms_.end() ? *i : NULL;
140 >    }
141  
142 <  double getZangle( );
143 <  void setZangle( double zAng );
144 <  void addZangle( double zAng );
142 >    std::vector<Atom*>::iterator getBeginAtomIter() {
143 >      return atoms_.begin();
144 >    }
145 >        
146 >    std::vector<Atom*>::iterator getEndAtomIter() {
147 >      return atoms_.end();
148 >    }
149  
150 <  void calcRefCoords( void );
151 <  void doEulerToRotMat(vec3 &euler, mat3x3 &myA );
152 <  void calcForcesAndTorques( void );
153 <  void updateAtoms( void );
150 >    /**
151 >     * Returns the atoms of this rigid body
152 >     * @return the atoms of this rigid body in a vector
153 >     * @deprecated
154 >     */          
155 >    std::vector<Atom*> getAtoms() {
156 >      return atoms_;
157 >    }
158  
159 <  //void yourAtomsHaveMoved( void );
159 >    /**
160 >     * Returns the number of atoms in this rigid body
161 >     * @return the number of atoms in this rigid body
162 >     */
163 >    int getNumAtoms() {
164 >      return atoms_.size();
165 >    }
166  
167 <  // Four functions added for derivatives with respect to Euler Angles:
168 <  // (Needed for minimization routines):
167 >    /**
168 >     * Return the position of atom which belongs to this rigid body.
169 >     * @return true if index is valid otherwise return false
170 >     * @param pos the position of atom which will be set on return if index is valid
171 >     * @param index the index of the atom in rigid body's private data member atoms_
172 >     */
173 >    bool getAtomPos(Vector3d& pos, unsigned int index);
174  
175 <  void getGrad(double gradient[6] );
176 <  void getEulerAngles( double myEuler[3] );
177 <
178 <  double max(double x, double y);
179 <  double min(double x, double y);
175 >    /**
176 >     * Return the position of atom which belongs to this rigid body.
177 >     * @return true if atom belongs to this rigid body,otherwise return false
178 >     * @param pos position of atom which will be set on return if atom belongs to this rigid body
179 >     * @param atom the pointer to an atom
180 >     */            
181 >    bool getAtomPos(Vector3d& pos, Atom* atom);
182  
183 +    /**
184 +     * Return the velocity of atom which belongs to this rigid body.
185 +     * @return true if index is valid otherwise return false
186 +     * @param vel the velocity of atom which will be set on return if index is valid
187 +     * @param index the index of the atom in rigid body's private data member atoms_
188 +     */
189 +    bool getAtomVel(Vector3d& vel, unsigned int index);
190  
191 <  // utility routines
191 >    /**
192 >     * Return the velocity of atom which belongs to this rigid body.
193 >     * @return true if atom belongs to this rigid body,otherwise return false
194 >     * @param vel velocity of atom which will be set on return if atom belongs to this rigid body
195 >     * @param atom the pointer to an atom
196 >     */
197 >    bool getAtomVel(Vector3d& vel, Atom*);
198  
199 <  void findCOM( void );
199 >    /**
200 >     * Return the reference coordinate of atom which belongs to this rigid body.
201 >     * @return true if index is valid otherwise return false
202 >     * @param coor the reference coordinate of atom which will be set on return if index is valid
203 >     * @param index the index of the atom in rigid body's private data member atoms_
204 >     */
205 >    bool getAtomRefCoor(Vector3d& coor, unsigned int index);
206  
207 <  virtual void accept(BaseVisitor* v);
207 >    /**
208 >     * Return the velocity of atom which belongs to this rigid body.
209 >     * @return true if atom belongs to this rigid body,otherwise return false
210 >     * @param coor velocity of atom which will be set on return if atom belongs to this rigid body
211 >     * @param atom the pointer to an atom
212 >     */
213 >    bool getAtomRefCoor(Vector3d& coor, Atom* atom);
214  
215 <  vector<Atom*> getAtoms() { return myAtoms;}
216 <  int getNumAtoms() {return myAtoms.size();}
215 >  private:
216 >    std::string name_;        
217 >    Mat3x3d inertiaTensor_;    
218 >    RotMat3x3d sU_;               /**< body fixed standard unit vector */
219 >        
220 >    std::vector<Atom*> atoms_;
221 >    std::vector<Vector3d> refCoords_;
222 >    std::vector<RotMat3x3d> refOrients_;
223 >  };
224  
225 <  void getAtomPos(double theP[3], int index);
102 <  void getAtomVel(double theV[3], int index);
103 <  void getAtomRefCoor(double pos[3], int index);
104 < protected:
225 > }//namespace OpenMD
226  
227 <  double mass;     // the total mass
107 <  double pos[3];   // the position array (center of mass)
108 <  double vel[3];   // the velocity array (center of mass)
109 <  double frc[3];   // the force array    (center of mass)
110 <  double trq[3];   // the torque vector  ( space fixed )
111 <  double ji[3];    // the angular momentum vector (body fixed)
112 <  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)
227 > #endif //PRIMITIVES_RIGIDBODY_HPP
228  
117  bool is_linear;
118  int linear_axis;
119  double momIntTol;
120
121  vector<Atom*> myAtoms;  // the vector of atoms
122  vector<vec3> refCoords;
123  vector<mat3x3> refOrients;
124
125  char rbName[100]; //it will eventually be converted into string
126 };
127
128 #endif

Comparing:
trunk/src/primitives/RigidBody.hpp (property svn:keywords), Revision 3 by tim, Fri Sep 24 16:27:58 2004 UTC vs.
branches/development/src/primitives/RigidBody.hpp (property svn:keywords), Revision 1808 by gezelter, Mon Oct 22 20:42:10 2012 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines