ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ConstraintElement.hpp
Revision: 1284
Committed: Mon Jun 21 18:52:21 2004 UTC (20 years ago) by tim
File size: 6121 byte(s)
Log Message:
roll in progress

File Contents

# User Rev Content
1 tim 1232 #ifndef _CONSTRAINTELEMENT_H_
2     #define _CONSTRAINTELEMENT_H_
3    
4     #include "RigidBody.hpp"
5     #include "Atom.hpp"
6    
7    
8     //class ConstraintElement is designed to not only provide the interface of StuntDouble, but also
9     //neccessary functionality to retrieve old position, old velocity and etc.
10     //First of all, those old data should be stored inside StuntDouble. We decide to store it on StuntDouble's
11     //generic property.
12     ////////////////////////////////////////////////////////////////////////////////
13     //Declaration of ConstraintElement
14     ////////////////////////////////////////////////////////////////////////////////
15     class ConstraintElement{
16     public:
17    
18     virtual ~ConstraintElement() {}
19    
20     //Interface of stunt double
21     bool isAtom() {return refSd->isAtom();}
22     bool isDirectionalAtom() {return refSd->isDirectional();}
23     bool isRigidBody() {return refSd->isRigidBody();}
24    
25     double getMass(void) {return refSd->getMass();}
26    
27     void getPos(double pos[3]) {refSd->getPos(pos);}
28     void setPos(double pos[3]) {refSd->setPos(pos);}
29    
30     void getVel(double vel[3]) {refSd->getVel(vel);}
31     void setVel(double vel[3]) {refSd->setVel(vel);}
32    
33     void getFrc(double frc[3]) {refSd->getFrc(frc);}
34     void addFrc(double frc[3]) {refSd->addFrc(frc);}
35    
36     void getA(double A[3][3]) {refSd->getA(A);}
37     void setA(double A[3][3]) {refSd->setA(A);}
38    
39     void getJ(double j[3]) {refSd->getJ(j);}
40     void setJ(double j[3]) {refSd->setJ(j);}
41    
42     void getQ( double q[4] ) {refSd->getQ(q);}
43     void setQ( double q[4] ) {refSd->setQ(q);}
44    
45     void setType(char* type){refSd->setType(type);}
46     char* getType() {return refSd->getType();}
47    
48     void getTrq(double trq[3]) {refSd->getTrq(trq);}
49     void addTrq(double trq[3]) {refSd->addTrq(trq);}
50    
51     void getI(double I[3][3]) {refSd->getI(I);}
52     void lab2Body(double vec[3]) {refSd->lab2Body(vec);}
53    
54     void getGrad(double grad[6]) {refSd->getGrad(grad);}
55     void setEuler(double phi, double theta, double psi) {refSd->setEuler(phi, theta, psi);}
56     void getEulerAngles(double eulers[3]) {refSd->getEulerAngles(eulers);}
57    
58     bool isLinear() {return refSd->isLinear();}
59     int linearAxis() {return refSd->linearAxis();}
60    
61     double getZangle() {return refSd->getZangle();}
62     void setZangle(double zAngle) {refSd->setZangle(zAngle);}
63     void addZangle(double zAngle) {refSd->addZangle(zAngle);}
64    
65 tim 1254 StuntDouble* getStuntDouble() {return refSd;}
66 tim 1232
67     virtual void getOldPos(double pos[3])=0;
68     virtual void getOldVel(double vel[3])=0;
69     virtual void getOldJ(double j[3])=0;
70     virtual void getOldA(double a[3][3])=0;
71     virtual void getOldQ(double q[4])=0;
72    
73     bool getMoved() {return movedData->getData();}
74     void setMoved(bool status) {movedData->setData(status);}
75    
76     bool getMoving() {return movingData->getData();}
77     void setMoving(bool status) {movingData->setData(status);}
78    
79     virtual void saveOldState() = 0;
80    
81     protected:
82     ConstraintElement(StuntDouble* rhs);
83    
84     StuntDouble* refSd;
85    
86     private:
87     BoolData* movedData;
88     BoolData* movingData;
89    
90     };
91    
92    
93     ////////////////////////////////////////////////////////////////////////////////
94     //Declaration of ConsAtomData
95     ////////////////////////////////////////////////////////////////////////////////
96     struct ConsAtomInfo{
97     double pos[3];
98     double vel[3];
99     double a[3][3];
100     double j[3];
101     double q[4];
102     };
103    
104     class ConsAtomData : public GenericData{
105     public:
106     ConsAtomData() : data(NULL){}
107     ~ConsAtomData(){
108     if(data != NULL)
109     delete data;
110     }
111    
112     ConsAtomInfo* getData() {return data;}
113     void setData(ConsAtomInfo* info) {
114     if (data != NULL)
115     delete data;
116    
117     data = info;
118     }
119    
120     private:
121     ConsAtomInfo* data;
122     };
123     ////////////////////////////////////////////////////////////////////////////////
124     //Declaration of ConstraintElement
125     ////////////////////////////////////////////////////////////////////////////////
126     class ConstraintAtom : public ConstraintElement{
127     public:
128     ConstraintAtom(Atom* rhs);
129    
130     void getOldPos(double pos[3]);
131     void getOldVel(double vel[3]);
132     void getOldJ(double j[3]);
133     void getOldA(double a[3][3]);
134     void getOldQ(double q[4]);
135    
136     Atom* getAtom() {return dynamic_cast<Atom*>(refSd);}
137    
138     virtual void saveOldState();
139    
140     protected:
141     ConsAtomInfo* oldConsAtomInfo;
142    
143     };
144    
145    
146    
147     ////////////////////////////////////////////////////////////////////////////////
148     //Declaration of ConsRbData
149     ////////////////////////////////////////////////////////////////////////////////
150     class ConsRbData : public GenericData{
151     public:
152     ConsRbData() : rb(NULL){}
153     ~ConsRbData(){
154     if (rb != NULL)
155     delete rb;
156     }
157    
158     RigidBody* getData() {return rb;}
159     void setData(RigidBody* rhs) {
160     if (rb != NULL)
161     delete rb;
162     rb = rhs;
163     }
164    
165     private:
166     RigidBody* rb;
167     };
168    
169     ////////////////////////////////////////////////////////////////////////////////
170     //Declaration of ConstraintElement
171     ////////////////////////////////////////////////////////////////////////////////
172     class ConstraintRigidBody : public ConstraintElement{
173     public:
174     ConstraintRigidBody(RigidBody*rhs, int index);
175    
176     void getOldPos(double pos[3]) {oldRb->getPos(pos);}
177     void getOldVel(double vel[3]) {oldRb->getVel(vel);}
178     void getOldJ(double j[3]) {oldRb->getJ(j);}
179     void getOldA(double a[3][3]) {oldRb->getA(a);}
180     void getOldQ(double q[4]) {oldRb->getQ(q);}
181    
182     void getOldAtomPos(double pos[3]) {oldRb->getAtomPos(pos, consAtomIndex);}
183     void getCurAtomPos(double pos[3]) {((RigidBody*)refSd)->getAtomPos(pos, consAtomIndex);}
184 tim 1254
185 tim 1284 void getOldAtomVel(double vel[3]) {oldRb->getAtomVel(vel, consAtomIndex);};
186     void getCurAtomVel(double vel[3]) {((RigidBody*)refSd)->getAtomVel(vel, consAtomIndex);};
187    
188 tim 1254 void getRefCoor(double pos[3]) {return ((RigidBody*)refSd)->getAtomRefCoor(pos, consAtomIndex);}
189 tim 1232 RigidBody* getRigidBody() { return dynamic_cast<RigidBody*>(refSd);}
190    
191     virtual void saveOldState();
192    
193     private:
194     int consAtomIndex;
195     RigidBody* oldRb;
196     };
197     #endif // endif _CONSTRAINTELEMENT_H_

Properties

Name Value
svn:executable *