MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
rottrim.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/elec/rottrim.cc,v 1.46 2017/01/12 14:46:22 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 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
33 
34 #include "genel.h"
35 #include "drive.h"
36 #include "dataman.h"
37 #include "constltp.h"
38 #include "strnode.h"
39 #include "rottrim.h"
40 
42  const DofOwner* pDO,
43  const ScalarDifferentialNode* pNode1,
44  const ScalarDifferentialNode* pNode2,
45  const ScalarDifferentialNode* pNode3,
46  const DriveCaller* pDThrust,
47  const DriveCaller* pDRollMoment,
48  const DriveCaller* pDPitchMoment,
49  const doublereal& dG,
50  const doublereal& dp,
51  const doublereal& dT0,
52  const doublereal& dT1,
53  const doublereal& dK0,
54  const doublereal& dK1,
55  const DriveCaller *pTrigger,
56  flag fOut)
57 : Elem(uL, fOut),
58 Genel(uL, pDO, fOut),
59 dRadius(-1.),
60 DThrust(pDThrust),
61 DRollMoment(pDRollMoment),
62 DPitchMoment(pDPitchMoment),
63 Trigger(pTrigger),
64 dGamma(dG),
65 dP(dp),
66 dP2(dP*dP),
67 dC(8.*(dP*dP - 1.)/dGamma),
68 dC2(dC*dC),
69 dTau0(dT0),
70 dTau1(dT1),
71 dKappa0(dK0),
72 dKappa1(dK1)
73 {
74  ASSERT(pNode1 != NULL);
75  ASSERT(pNode2 != NULL);
76  ASSERT(pNode3 != NULL);
77  ASSERT(dGamma > 0.);
78  ASSERT(dP > 0.);
79 
80  pvNodes[0] = pNode1;
81  pvNodes[1] = pNode2;
82  pvNodes[2] = pNode3;
83 }
84 
86 {
87  NO_OP;
88 }
89 
90 unsigned int
92 {
93  return 0;
94 }
95 
96 /* Dimensioni del workspace */
97 void
98 RotorTrimBase::WorkSpaceDim(integer* piNumRows, integer* piNumCols) const
99 {
100  *piNumRows = 3;
101  *piNumCols = 3;
102 }
103 
104 /* assemblaggio jacobiano */
107  doublereal dCoef,
108  const VectorHandler& /* XCurr */ ,
109  const VectorHandler& /* XPrimeCurr */ )
110 {
111  DEBUGCOUT("Entering RotorTrimBase::AssJac()" << std::endl);
112 
113  SparseSubMatrixHandler& WM = WorkMat.SetSparse();
114  WM.Resize(3, 0);
115 
116  doublereal d[3];
117  if (Trigger.dGet() == 0.) {
118  d[0] = dCoef;
119  d[1] = dCoef;
120  d[2] = dCoef;
121 
122  } else {
123  d[0] = dTau0 + dCoef;
124  d[1] = dTau1 + dCoef;
125  d[2] = dTau1 + dCoef;
126  }
127 
128  for (int iIdx = 0; iIdx < 3; iIdx++ ) {
129  integer iRowIndex = pvNodes[iIdx]->iGetFirstRowIndex() + 1;
130  integer iColIndex = pvNodes[iIdx]->iGetFirstColIndex() + 1;
131  WM.PutItem(iIdx + 1, iRowIndex, iColIndex, d[iIdx]);
132  }
133 
134  return WorkMat;
135 }
136 
137 /* assemblaggio residuo */
140  doublereal dCoef,
141  const VectorHandler& /* XCurr */ ,
142  const VectorHandler& /* XPrimeCurr */ )
143 {
144  DEBUGCOUT("Entering RotorTrimBase::AssRes()" << std::endl);
145 
146  WorkVec.Resize(3);
147 
148  WorkVec.PutRowIndex(1, pvNodes[0]->iGetFirstRowIndex() + 1);
149  WorkVec.PutRowIndex(2, pvNodes[1]->iGetFirstRowIndex() + 1);
150  WorkVec.PutRowIndex(3, pvNodes[2]->iGetFirstRowIndex() + 1);
151 
152  doublereal dX1 = pvNodes[0]->dGetX();
153  doublereal dX2 = pvNodes[1]->dGetX();
154  doublereal dX3 = pvNodes[2]->dGetX();
155 
156  if (Trigger.dGet() == 0.) {
157  WorkVec.PutCoef(1, -dX1);
158  WorkVec.PutCoef(2, -dX2);
159  WorkVec.PutCoef(3, -dX3);
160 
161  return WorkVec;
162  }
163 
164  doublereal dX1Prime = pvNodes[0]->dGetXPrime();
165  doublereal dX2Prime = pvNodes[1]->dGetXPrime();
166  doublereal dX3Prime = pvNodes[2]->dGetXPrime();
167 
168  doublereal dThrust;
169  doublereal dRollMoment;
170  doublereal dPitchMoment;
171  doublereal dRho;
172  doublereal dOmega;
173  doublereal dMu;
174 
175  GetData(dThrust, dRollMoment, dPitchMoment, dRho, dOmega, dMu);
176 
177  doublereal d = M_PI*pow(dRadius, 4)*dRho*dOmega*dOmega;
178  dThrust /= d;
179  d *= dRadius;
180  dRollMoment /= d;
181  dPitchMoment /= d;
182 
183  doublereal dMu2 = dMu*dMu;
184 
185  const doublereal f = dC/(1. + dC2);
186 
187  Mat3x3 m((1. + 3./2.*dMu2)/6.,
188  -f*dMu/6.*(dC - dGamma/(16.*dP2)),
189  f*dMu/6.*(1. + dC*dGamma/(16.*dP2)),
190  2./9.*dMu,
191  -f/16.*(dC*(1. + 3./2.*dMu2) - 2./9.*dMu2*dGamma/dP2),
192  f/16.*((1. + 2.*dMu2) + 2./9.*dMu2*dC*dGamma/dP2),
193  0.,
194  -f/16.,
195  -f*dC/16.*(1. + 1./2.*dMu2));
196  Vec3 v(DThrust.dGet() - dThrust,
197  DRollMoment.dGet() - dRollMoment,
198  DPitchMoment.dGet() - dPitchMoment);
199  v = m.Solve(v);
200 
201  WorkVec.PutCoef(1, v(1)*dKappa0 - dX1 - dTau0*dX1Prime);
202  WorkVec.PutCoef(2, v(2)*dKappa1 - dX2 - dTau1*dX2Prime);
203  WorkVec.PutCoef(3, v(3)*dKappa1 - dX3 - dTau1*dX3Prime);
204 
205  return WorkVec;
206 }
207 
208 void
209 RotorTrimBase::GetConnectedNodes(std::vector<const Node *>& connectedNodes) const
210 {
211  connectedNodes.resize(3);
212  for (int i = 0; i < 3; i++) {
213  connectedNodes[i] = pvNodes[i];
214  }
215 }
216 
217 static unsigned iRotorTz = 0;
218 static unsigned iRotorMx = 0;
219 static unsigned iRotorMy = 0;
220 
221 RotorTrim::RotorTrim(unsigned int uL,
222  const DofOwner* pDO,
223  const Rotor* pRot,
224  const ScalarDifferentialNode* pNode1,
225  const ScalarDifferentialNode* pNode2,
226  const ScalarDifferentialNode* pNode3,
227  const DriveCaller* pDThrust,
228  const DriveCaller* pDRollMoment,
229  const DriveCaller* pDPitchMoment,
230  const doublereal& dG,
231  const doublereal& dp,
232  const doublereal& dT0,
233  const doublereal& dT1,
234  const doublereal& dK0,
235  const doublereal& dK1,
236  const DriveCaller *pTrigger,
237  flag fOut)
238 : Elem(uL, fOut),
239 RotorTrimBase(uL, pDO, pNode1, pNode2, pNode3,
240  pDThrust, pDRollMoment, pDPitchMoment,
241  dG, dp, dT0, dT1, dK0, dK1, pTrigger, fOut),
242 pRotor(pRot)
243 {
244  ASSERT(pRotor != NULL);
245 
247 
248  if (iRotorTz == 0) {
249  /* first RotorTrim */
253  }
254 }
255 
257 {
258  NO_OP;
259 }
260 
261 /* Scrive il contributo dell'elemento al file di restart */
262 std::ostream&
263 RotorTrim::Restart(std::ostream& out) const
264 {
265  return out << " /* rotor trim not implemented yet */ ";
266 }
267 
268 void
270  doublereal &dRollMoment,
271  doublereal &dPitchMoment,
272  doublereal &dRho,
273  doublereal &dOmega,
274  doublereal &dMu) const
275 {
276  dThrust = pRotor->dGetPrivData(iRotorTz);
277  dRollMoment = pRotor->dGetPrivData(iRotorMx);
278  dPitchMoment = pRotor->dGetPrivData(iRotorMy);
279  dRho = pRotor->dGetAirDensity(pRotor->GetXCurr());
280  dOmega = pRotor->dGetOmega(); // absolute value?
281  dMu = pRotor->dGetMu();
282 }
283 
284 void
285 RotorTrim::GetConnectedNodes(std::vector<const Node *>& connectedNodes) const
286 {
287  pRotor->GetConnectedNodes(connectedNodes);
288  int NumNodes = connectedNodes.size();
289  connectedNodes.resize(NumNodes + 3);
290  for (int i = 0; i < 3; i++) {
291  connectedNodes[NumNodes + i] = pvNodes[i];
292  }
293 }
294 
296  const DofOwner *pDO,
297  const StructNode *pStrNode,
298  const DriveCaller *pThrust,
299  const DriveCaller *pRollMoment,
300  const DriveCaller *pPitchMoment,
301  const AirProperties *pAP,
302  doublereal dRadius,
303  const DriveCaller *pOmega,
304  const DriveCaller *pMu,
305  const ScalarDifferentialNode* pNode1,
306  const ScalarDifferentialNode* pNode2,
307  const ScalarDifferentialNode* pNode3,
308  const DriveCaller* pDThrust,
309  const DriveCaller* pDRollMoment,
310  const DriveCaller* pDPitchMoment,
311  const doublereal& dG,
312  const doublereal& dp,
313  const doublereal& dT0,
314  const doublereal& dT1,
315  const doublereal& dK0,
316  const doublereal& dK1,
317  const DriveCaller *pTrigger,
318  flag fOut)
319 : Elem(uL, fOut),
320 RotorTrimBase(uL, pDO, pNode1, pNode2, pNode3,
321  pDThrust, pDRollMoment, pDPitchMoment,
322  dG, dp, dT0, dT1, dK0, dK1, pTrigger, fOut),
323 pStrNode(pStrNode),
324 Thrust(pThrust),
325 RollMoment(pRollMoment),
326 PitchMoment(pPitchMoment),
327 pAP(pAP),
328 Omega(pOmega),
329 Mu(pMu)
330 {
331  this->dRadius = dRadius;
332 }
333 
335 {
336  NO_OP;
337 }
338 
339 /* Scrive il contributo dell'elemento al file di restart */
340 std::ostream&
341 RotorTrimGeneric::Restart(std::ostream& out) const
342 {
343  return out << " /* rotor trim not implemented yet */ ";
344 }
345 
346 void
348  doublereal &dRollMoment,
349  doublereal &dPitchMoment,
350  doublereal &dRho,
351  doublereal &dOmega,
352  doublereal &dMu) const
353 {
354  dThrust = Thrust.dGet();
355  dRollMoment = RollMoment.dGet();
356  dPitchMoment = PitchMoment.dGet();
358  dOmega = Omega.dGet();
359  dMu = Mu.dGet();
360 }
361 
DriveOwner PitchMoment
Definition: rottrim.h:190
virtual doublereal dGetAirDensity(const Vec3 &X) const
Definition: aerodyn.cc:736
#define M_PI
Definition: gradienttest.cc:67
virtual std::ostream & Restart(std::ostream &out) const
Definition: rottrim.cc:263
const Vec3 Zero3(0., 0., 0.)
long int flag
Definition: mbdyn.h:43
GradientExpression< BinaryExpr< FuncPow, LhsExpr, RhsExpr > > pow(const GradientExpression< LhsExpr > &u, const GradientExpression< RhsExpr > &v)
Definition: gradient.h:2961
Definition: matvec3.h:98
virtual const doublereal & dGetXPrime(void) const
Definition: node.h:393
virtual ~RotorTrimBase(void)
Definition: rottrim.cc:85
doublereal dC2
Definition: rottrim.h:70
doublereal dKappa1
Definition: rottrim.h:75
virtual unsigned int iGetNumDof(void) const
Definition: rottrim.cc:91
static unsigned iRotorMy
Definition: rottrim.cc:219
virtual unsigned int iGetPrivDataIdx(const char *s) const
Definition: simentity.cc:142
RotorTrimBase(unsigned int uL, const DofOwner *pDO, const ScalarDifferentialNode *pNode1, const ScalarDifferentialNode *pNode2, const ScalarDifferentialNode *pNode3, const DriveCaller *pDThrust, const DriveCaller *pDRollMoment, const DriveCaller *pDPitchMoment, const doublereal &dG, const doublereal &dp, const doublereal &dT0, const doublereal &dT1, const doublereal &dK0, const doublereal &dK1, const DriveCaller *pTrigger, flag fOut)
Definition: rottrim.cc:41
DriveOwner DThrust
Definition: rottrim.h:62
virtual ~RotorTrimGeneric(void)
Definition: rottrim.cc:334
doublereal dC
Definition: rottrim.h:69
#define NO_OP
Definition: myassert.h:74
virtual void GetData(doublereal &dThrust, doublereal &dRollMoment, doublereal &dPitchMoment, doublereal &dRho, doublereal &dOmega, doublereal &dMu) const =0
void Resize(integer iNewRow, integer iNewCol)
Definition: submat.cc:1053
virtual VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &, const VectorHandler &)
Definition: rottrim.cc:106
static unsigned iRotorMx
Definition: rottrim.cc:218
doublereal dRadius
Definition: rottrim.h:60
virtual doublereal dGetMu(void) const
Definition: rotor.h:165
virtual void PutRowIndex(integer iSubRow, integer iRow)=0
virtual std::ostream & Restart(std::ostream &out) const
Definition: rottrim.cc:341
DriveOwner Omega
Definition: rottrim.h:192
virtual void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const
Definition: rottrim.cc:98
virtual void GetData(doublereal &dThrust, doublereal &dRollMoment, doublereal &dPitchMoment, doublereal &dRho, doublereal &dOmega, doublereal &dMu) const
Definition: rottrim.cc:347
virtual void GetConnectedNodes(std::vector< const Node * > &connectedNodes) const
Definition: rotor.h:190
void PutItem(integer iSubIt, integer iRow, integer iCol, const doublereal &dCoef)
Definition: submat.h:997
virtual doublereal dGetRadius(void) const
Definition: rotor.h:158
virtual const Vec3 & GetXCurr(void) const
Definition: rotor.h:146
RotorTrimGeneric(unsigned int uL, const DofOwner *pDO, const StructNode *pStrNode, const DriveCaller *pThrust, const DriveCaller *pRollMoment, const DriveCaller *pPitchMoment, const AirProperties *pAP, doublereal dRadius, const DriveCaller *pOmega, const DriveCaller *pMu, const ScalarDifferentialNode *pNode1, const ScalarDifferentialNode *pNode2, const ScalarDifferentialNode *pNode3, const DriveCaller *pDThrust, const DriveCaller *pDRollMoment, const DriveCaller *pDPitchMoment, const doublereal &dG, const doublereal &dp, const doublereal &dT0, const doublereal &dT1, const doublereal &dK0, const doublereal &dK1, const DriveCaller *pTrigger, flag fOut)
Definition: rottrim.cc:295
DriveOwner Mu
Definition: rottrim.h:192
doublereal dTau1
Definition: rottrim.h:73
DriveOwner DPitchMoment
Definition: rottrim.h:62
DriveOwner Trigger
Definition: rottrim.h:63
virtual SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &, const VectorHandler &)
Definition: rottrim.cc:139
doublereal dTau0
Definition: rottrim.h:72
doublereal dGamma
Definition: rottrim.h:65
#define DEBUGCOUT(msg)
Definition: myassert.h:232
Definition: genel.h:45
virtual integer iGetFirstRowIndex(void) const
Definition: node.cc:82
virtual void GetData(doublereal &dThrust, doublereal &dRollMoment, doublereal &dPitchMoment, doublereal &dRho, doublereal &dOmega, doublereal &dMu) const
Definition: rottrim.cc:269
Vec3 Solve(const Vec3 &v) const
Definition: matvec3.cc:186
#define ASSERT(expression)
Definition: colamd.c:977
DriveOwner RollMoment
Definition: rottrim.h:190
doublereal dP
Definition: rottrim.h:66
virtual doublereal dGetOmega(void) const
Definition: rotor.h:151
virtual void PutCoef(integer iRow, const doublereal &dCoef)=0
virtual const Vec3 & GetXCurr(void) const
Definition: strnode.h:310
virtual void GetConnectedNodes(std::vector< const Node * > &connectedNodes) const
Definition: rottrim.cc:209
virtual doublereal dGetPrivData(unsigned int i) const
Definition: simentity.cc:149
static unsigned iRotorTz
Definition: rottrim.cc:217
doublereal dP2
Definition: rottrim.h:68
Definition: elem.h:75
DriveOwner DRollMoment
Definition: rottrim.h:62
doublereal dGet(const doublereal &dVar) const
Definition: drive.cc:664
virtual doublereal dGetAirDensity(const Vec3 &) const =0
const Rotor * pRotor
Definition: rottrim.h:143
virtual void GetConnectedNodes(std::vector< const Node * > &connectedNodes) const
Definition: rottrim.cc:285
const StructNode * pStrNode
Definition: rottrim.h:189
DriveOwner Thrust
Definition: rottrim.h:190
SparseSubMatrixHandler & SetSparse(void)
Definition: submat.h:1178
RotorTrim(unsigned int uL, const DofOwner *pDO, const Rotor *pRot, const ScalarDifferentialNode *pNode1, const ScalarDifferentialNode *pNode2, const ScalarDifferentialNode *pNode3, const DriveCaller *pDThrust, const DriveCaller *pDRollMoment, const DriveCaller *pDPitchMoment, const doublereal &dG, const doublereal &dp, const doublereal &dT0, const doublereal &dT1, const doublereal &dK0, const doublereal &dK1, const DriveCaller *pTrigger, flag fOut)
Definition: rottrim.cc:221
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
virtual ~RotorTrim(void)
Definition: rottrim.cc:256
const AirProperties * pAP
Definition: rottrim.h:191
virtual void Resize(integer iNewSize)=0
virtual const doublereal & dGetX(void) const
Definition: node.h:386
doublereal dKappa0
Definition: rottrim.h:74
Definition: rotor.h:43
const ScalarDifferentialNode * pvNodes[3]
Definition: rottrim.h:61
virtual integer iGetFirstColIndex(void) const
Definition: node.cc:88