1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/struct/brake.h,v 1.20 2017/01/12 14:46:43 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati	<masarati@aero.polimi.it>
9  * Paolo Mantegazza	<mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
30  */
31 
32 
33 #ifndef BRAKEJ_H
34 #define BRAKEJ_H
35 
36 #include "joint.h"
37 #include "drive.h"
38 #include "friction.h"
39 
40 /* Brake - begin */
41 
42 class Brake : virtual public Elem, public Joint {
43  private:
44 	/*
45 	 * Brake
46 	 *
47 	 * rotation axis about local axis 3
48 	 */
49 
50    /* Freno - asse di rotazione dato dall'asse 3 del sistema di
51     * riferimento della cerniera. Tale sistema e' noto relativamente ai due
52     * nodi. In particolare rispetto al nodo 1 la trasformazione dal sistema
53     * di riferimento della cerniera al sistema globale e': R1*R1h, mentre per
54     * il nodo 2 la medesima trasformazion e': R2*R2h.
55     * I vettori d1 e d2 esprimono, nel sistema di riferimento dei rispettivi
56     * nodi, la distanza della cerniera dai nodi stessi.
57     * I vettori F, M esprimono le reazioni vincolari di forza e coppia. */
58    const StructNode* pNode1;
59    const StructNode* pNode2;
60    Vec3 d1;
61    Mat3x3 R1h;
62    Vec3 d2;
63    Mat3x3 R2h;
64    //Vec3 F;
65    Vec3 M;
66 
67    /* if the brake generates a force, Dir is the direction
68     * with respect to node 1 (supposed to be the fixed one) */
69 #if 0
70    bool isForce;
71    Vec3 Dir;
72 #endif
73 
74    mutable doublereal dTheta;
75 
76    /* friction related data */
77    BasicShapeCoefficient *const Sh_c;
78    BasicFriction *const fc;
79    const doublereal preF;
80    const doublereal r;
81    DriveOwner brakeForce;
82    static const unsigned int NumSelfDof;
83    static const unsigned int NumDof;
84    /* end of friction related data */
85 
86  public:
87    /* Costruttore non banale */
88    Brake(unsigned int uL, const DofOwner* pDO,
89 		   const StructNode* pN1, const StructNode* pN2,
90 		   const Vec3& dTmp1, const Vec3& dTmp2,
91 		   const Mat3x3& R1hTmp, const Mat3x3& R2hTmp, flag fOut,
92 		   const doublereal rr,
93 		   const doublereal pref,
94 		   BasicShapeCoefficient *const sh,
95 		   BasicFriction *const f,
96 #if 0
97 		   bool isforce,
98 		   const Vec3& dir,
99 #endif
100 		   DriveCaller *pdc);
101 
102    /* Distruttore */
103    ~Brake(void);
104 
105    /* Contributo al file di restart */
106    virtual std::ostream& Restart(std::ostream& out) const;
107 
108    /* Tipo di Joint */
GetJointType(void)109    virtual Joint::Type GetJointType(void) const {
110       return Joint::BRAKE;
111    };
112 
113    virtual unsigned int iGetNumDof(void) const;
114 
115    DofOrder::Order GetDofType(unsigned int i) const;
116 
117    virtual void SetValue(DataManager *pDM,
118 		   VectorHandler& X, VectorHandler& XP,
119 		   SimulationEntity::Hints *ph = 0);
120 
121    virtual void AfterConvergence(const VectorHandler& X,
122 			const VectorHandler& XP);
123 
WorkSpaceDim(integer * piNumRows,integer * piNumCols)124    void WorkSpaceDim(integer* piNumRows, integer* piNumCols) const {
125       *piNumRows = NumDof;
126       *piNumCols = NumDof;
127       if (fc) {
128           *piNumRows += fc->iGetNumDof();
129           *piNumCols += fc->iGetNumDof();
130       }
131    };
132 
133 
134    VariableSubMatrixHandler& AssJac(VariableSubMatrixHandler& WorkMat,
135 				    doublereal dCoef,
136 				    const VectorHandler& XCurr,
137 				    const VectorHandler& XPrimeCurr);
138    SubVectorHandler& AssRes(SubVectorHandler& WorkVec,
139 			    doublereal dCoef,
140 			    const VectorHandler& XCurr,
141 			    const VectorHandler& XPrimeCurr);
142 
143    DofOrder::Order GetEqType(unsigned int i) const;
144 
145    void Output(OutputHandler& OH) const;
146 
147 
148    /* funzioni usate nell'assemblaggio iniziale */
149 
iGetInitialNumDof(void)150    virtual unsigned int iGetInitialNumDof(void) const {
151       return 10;
152    };
InitialWorkSpaceDim(integer * piNumRows,integer * piNumCols)153    virtual void InitialWorkSpaceDim(integer* piNumRows,
154 				    integer* piNumCols) const {
155       *piNumRows = 34;
156       *piNumCols = 34;
157    };
158 
159    /* Contributo allo jacobiano durante l'assemblaggio iniziale */
160    VariableSubMatrixHandler& InitialAssJac(VariableSubMatrixHandler& WorkMat,
161 					   const VectorHandler& XCurr);
162 
163    /* Contributo al residuo durante l'assemblaggio iniziale */
164    SubVectorHandler& InitialAssRes(SubVectorHandler& WorkVec,
165 				   const VectorHandler& XCurr);
166 
167    /* Dati privati */
168    virtual unsigned int iGetNumPrivData(void) const;
169    virtual unsigned int iGetPrivDataIdx(const char *s) const;
170    virtual doublereal dGetPrivData(unsigned int i) const;
171 
172    /* *******PER IL SOLUTORE PARALLELO******** */
173    /* Fornisce il tipo e la label dei nodi che sono connessi all'elemento
174       utile per l'assemblaggio della matrice di connessione fra i dofs */
GetConnectedNodes(std::vector<const Node * > & connectedNodes)175    virtual void GetConnectedNodes(std::vector<const Node *>& connectedNodes) const {
176      connectedNodes.resize(2);
177      connectedNodes[0] = pNode1;
178      connectedNodes[1] = pNode2;
179    };
180    /* ************************************************ */
181 };
182 
183 /* Brake - end */
184 
185 
186 
187 #endif /* PLANEJ_H */
188 
189