1 |
tim |
1232 |
#ifndef _SHAKEMIN_H_ |
2 |
|
|
#define _SHAKEMIN_H_ |
3 |
|
|
|
4 |
|
|
#include "ConstraintAlgorithm.hpp" |
5 |
|
|
#include "ConstraintPair.hpp" |
6 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
7 |
|
|
//Declaration of DCShakeMinRFunctor |
8 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
9 |
|
|
class DCShakeRMinFunctor : public CallbackFunctor{ |
10 |
|
|
public: |
11 |
|
|
DCShakeRMinFunctor(SimInfo* rhs) : CallbackFunctor(rhs){} |
12 |
|
|
protected: |
13 |
|
|
virtual int operator()(ConstraintAtom* consAtom1, ConstraintAtom* consAtom2); |
14 |
|
|
virtual int operator()(ConstraintAtom* consAtom,ConstraintRigidBody* consRB); |
15 |
|
|
virtual int operator()(ConstraintRigidBody* consRB1, ConstraintRigidBody* consRB2); |
16 |
|
|
}; |
17 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
18 |
|
|
//Declaration of JCShakeMinRFunctor |
19 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
20 |
|
|
class JCShakeRMInFunctor : public CallbackFunctor{ |
21 |
|
|
public: |
22 |
|
|
JCShakeRMInFunctor(SimInfo* rhs) : CallbackFunctor(rhs){} |
23 |
|
|
protected: |
24 |
|
|
virtual int operator()(ConstraintAtom* consAtom1, ConstraintAtom* consAtom2); |
25 |
|
|
virtual int operator()(ConstraintAtom* consAtom,ConstraintRigidBody* consRB); |
26 |
|
|
virtual int operator()(ConstraintRigidBody* consRB1, ConstraintRigidBody* consRB2); |
27 |
|
|
}; |
28 |
|
|
|
29 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
30 |
|
|
//Declaration of ShakeMinR |
31 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
32 |
|
|
//constraint the bond during energy minimization |
33 |
|
|
//only works for steepest descent and conjugate gradient algorithm |
34 |
|
|
class ShakeMinR : public ConstraintAlgorithm{ |
35 |
|
|
public: |
36 |
|
|
ShakeMinR(SimInfo* rhs) : ConstraintAlgorithm(rhs){ |
37 |
|
|
registerCallback(typeid(DistanceConstraintPair), new DCShakeRMinFunctor(rhs)); |
38 |
|
|
registerCallback(typeid(JointConstraintPair), new JCShakeRMInFunctor(rhs)); |
39 |
|
|
} |
40 |
|
|
}; |
41 |
|
|
|
42 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
43 |
|
|
//Declaration of DCShakeMinFFunctor |
44 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
45 |
|
|
|
46 |
|
|
class DCShakeMinFFunctor : public CallbackFunctor{ |
47 |
|
|
public: |
48 |
|
|
DCShakeMinFFunctor(SimInfo* rhs) : CallbackFunctor(rhs){} |
49 |
|
|
protected: |
50 |
|
|
virtual int operator()(ConstraintAtom* consAtom1, ConstraintAtom* consAtom2); |
51 |
|
|
virtual int operator()(ConstraintAtom* consAtom,ConstraintRigidBody* consRB); |
52 |
|
|
virtual int operator()(ConstraintRigidBody* consRB1, ConstraintRigidBody* consRB2); |
53 |
|
|
}; |
54 |
|
|
|
55 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
56 |
|
|
//Declaration of JCShakeMinFFunctor |
57 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
58 |
|
|
class JCShakeMinFFunctor : public CallbackFunctor{ |
59 |
|
|
public: |
60 |
|
|
JCShakeMinFFunctor(SimInfo* rhs) : CallbackFunctor(rhs){} |
61 |
|
|
protected: |
62 |
|
|
virtual int operator()(ConstraintAtom* consAtom1, ConstraintAtom* consAtom2); |
63 |
|
|
virtual int operator()(ConstraintAtom* consAtom,ConstraintRigidBody* consRB); |
64 |
|
|
virtual int operator()(ConstraintRigidBody* consRB1, ConstraintRigidBody* consRB2); |
65 |
|
|
}; |
66 |
|
|
|
67 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
68 |
|
|
//Declaration of ShakeMinF |
69 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
70 |
|
|
//remove the force component along the bond direction during energy minimization |
71 |
|
|
class ShakeMinF : public ConstraintAlgorithm{ |
72 |
|
|
public: |
73 |
|
|
ShakeMinF(SimInfo* rhs) : ConstraintAlgorithm(rhs){ |
74 |
|
|
registerCallback(typeid(DistanceConstraintPair), new DCShakeMinFFunctor(rhs)); |
75 |
|
|
registerCallback(typeid(JointConstraintPair), new JCShakeMinFFunctor(rhs)); |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
}; |
79 |
|
|
|
80 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
81 |
|
|
//Declaration of ShakeMinAlgorithm |
82 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
83 |
|
|
//class ShakeMinAlgorithm will encapsulate preConstraint, ShakeMinR and ShakeMinF |
84 |
|
|
class ShakeMinFramework : public ConsAlgoFramework{ |
85 |
|
|
public: |
86 |
|
|
ShakeMinFramework(SimInfo* rhs) : ConsAlgoFramework(rhs){ |
87 |
|
|
srAlgo = new ShakeMinR(rhs); |
88 |
|
|
sfAlgo = new ShakeMinF(rhs); |
89 |
|
|
} |
90 |
|
|
|
91 |
|
|
~ShakeMinFramework(){ |
92 |
|
|
delete srAlgo; |
93 |
|
|
delete sfAlgo; |
94 |
|
|
} |
95 |
|
|
|
96 |
tim |
1248 |
int doShakeR(){ |
97 |
tim |
1232 |
srAlgo->doConstrain(); |
98 |
tim |
1248 |
return srAlgo->haveError()? -1 : 1; |
99 |
tim |
1232 |
} |
100 |
|
|
|
101 |
tim |
1248 |
int doShakeF(){ |
102 |
tim |
1232 |
sfAlgo->doConstrain(); |
103 |
tim |
1248 |
return sfAlgo->haveError()? -1 : 1; |
104 |
tim |
1232 |
} |
105 |
|
|
private: |
106 |
|
|
ShakeMinR* srAlgo; |
107 |
|
|
ShakeMinF* sfAlgo; |
108 |
|
|
}; |
109 |
|
|
#endif //end ifndef _SHAKEMIN_H_ |