1 |
tim |
1232 |
#ifndef _SHAKE_H_ |
2 |
|
|
#define _SHAKE_H_ |
3 |
|
|
#include "ConstraintAlgorithm.hpp" |
4 |
|
|
#include "ConstraintPair.hpp" |
5 |
|
|
|
6 |
|
|
class DCShakeFunctor : public CallbackFunctor{ |
7 |
|
|
public: |
8 |
|
|
DCShakeFunctor(SimInfo* rhs) : CallbackFunctor(rhs){} |
9 |
|
|
protected: |
10 |
|
|
virtual int operator()(ConstraintAtom* consAtom1, ConstraintAtom* consAtom2); |
11 |
|
|
virtual int operator()(ConstraintAtom* consAtom,ConstraintRigidBody* consRB); |
12 |
|
|
virtual int operator()(ConstraintRigidBody* consRB1, ConstraintRigidBody* consRB2); |
13 |
tim |
1254 |
private: |
14 |
|
|
double getEffInvMass(ConstraintRigidBody* consRB, double bondDir[3]); |
15 |
|
|
void integrate(ConstraintRigidBody* consRB, double force[3]); |
16 |
tim |
1232 |
}; |
17 |
|
|
|
18 |
|
|
class JCShakeFunctor : public CallbackFunctor{ |
19 |
|
|
public: |
20 |
|
|
JCShakeFunctor(SimInfo* rhs) : CallbackFunctor(rhs){} |
21 |
|
|
protected: |
22 |
|
|
virtual int operator()(ConstraintAtom* consAtom1, ConstraintAtom* consAtom2); |
23 |
|
|
virtual int operator()(ConstraintAtom* consAtom,ConstraintRigidBody* consRB); |
24 |
|
|
virtual int operator()(ConstraintRigidBody* consRB1, ConstraintRigidBody* consRB2); |
25 |
|
|
}; |
26 |
|
|
|
27 |
|
|
|
28 |
|
|
//SHAKE constraint algorithm |
29 |
|
|
//Reference: |
30 |
|
|
//[1] J.P. Ryckaert, G.Ciccotti and H.J.C. Berendsen, J. Comput. Phys., 23, 327 (1977) |
31 |
|
|
//[2] |
32 |
|
|
//[3] |
33 |
|
|
class Shake : public ConstraintAlgorithm{ |
34 |
|
|
public: |
35 |
|
|
Shake(SimInfo* rhs) : ConstraintAlgorithm(rhs){ |
36 |
|
|
registerCallback(typeid(DistanceConstraintPair), new DCShakeFunctor(rhs)); |
37 |
|
|
registerCallback(typeid(JointConstraintPair), new JCShakeFunctor(rhs)); |
38 |
|
|
} |
39 |
|
|
}; |
40 |
|
|
|
41 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
42 |
|
|
//Declaration of ShakeMinAlgorithm |
43 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
44 |
|
|
//class ShakeMinAlgorithm will encapsulate preConstraint, ShakeMinR and ShakeMinF |
45 |
|
|
class ShakeFrameWork : public ConsAlgoFramework{ |
46 |
|
|
public: |
47 |
|
|
ShakeFrameWork(SimInfo* rhs) : ConsAlgoFramework(rhs){ |
48 |
|
|
shakeAlgo = new Shake(rhs); |
49 |
|
|
|
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
~ShakeFrameWork(){ |
53 |
|
|
delete shakeAlgo; |
54 |
|
|
} |
55 |
|
|
|
56 |
tim |
1248 |
int doShake(){ |
57 |
|
|
shakeAlgo->doConstrain(); |
58 |
|
|
return shakeAlgo->haveError()? -1 : 1; |
59 |
tim |
1232 |
} |
60 |
|
|
|
61 |
|
|
private: |
62 |
|
|
Shake* shakeAlgo; |
63 |
|
|
|
64 |
|
|
}; |
65 |
|
|
#endif //end ifndef _SHAKE_H_ |