MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
swashpl.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/elec/swashpl.cc,v 1.35 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 /* Swash plate */
33 
34 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
35 
36 #include <cmath>
37 
38 #include "swashpl.h"
39 
40 
41 /* SwashPlate - begin */
42 
43 SwashPlate::SwashPlate(unsigned int uL, const DofOwner* pDO,
44  const ScalarDifferentialNode* pCollIn, // const DriveCaller* pColl,
45  const ScalarDifferentialNode* pLongIn, // const DriveCaller* pLong,
46  const ScalarDifferentialNode* pLatIn, // const DriveCaller* pLat,
47  const ScalarDifferentialNode* pN1,
48  const ScalarDifferentialNode* pN2,
49  const ScalarDifferentialNode* pN3,
50  doublereal dDynCoef,
51  doublereal dCyclFact,
52  doublereal dCollFact,
53  flag fCL,
54  doublereal dCMin,
55  doublereal dCMax,
56  flag fFL,
57  doublereal dFMin,
58  doublereal dFMax,
59  flag fLL,
60  doublereal dLMin,
61  doublereal dLMax,
62  flag fOut)
63 : Elem(uL, fOut),
64 Genel(uL, pDO, fOut),
65 pCollectiveIn(pCollIn), // Collective(pColl),
66 pLongitudinalIn(pLongIn), // Longitudinal(pLong),
67 pLateralIn(pLatIn), // Lateral(pLat),
68 pNode1(pN1), pNode2(pN2), pNode3(pN3),
69 dDynamicCoef(dDynCoef),
70 dCyclicFactor(dCyclFact),
71 dCollectiveFactor(dCollFact),
72 fCollLimits(fCL), dCollMax(dCMax), dCollMin(dCMin),
73 fForeAftLimits(fFL), dForeAftMax(dFMax), dForeAftMin(dFMin),
74 fLatLimits(fLL), dLatMax(dLMax), dLatMin(dLMin)
75 {
76  ASSERT(pCollectiveIn != NULL);
78  ASSERT(pLongitudinalIn != NULL);
80  ASSERT(pLateralIn != NULL);
82 
83  ASSERT(pNode1 != NULL);
85  ASSERT(pNode2 != NULL);
87  ASSERT(pNode3 != NULL);
89 
90  ASSERT(dCyclicFactor != 0.);
92  ASSERT(dDynamicCoef >= 0.);
93 }
94 
95 
97 {
98  NO_OP;
99 }
100 
101 
102 /* Scrive il contributo dell'elemento al file di restart */
103 std::ostream&
104 SwashPlate::Restart(std::ostream& out) const
105 {
106  Genel::Restart(out) << ", swash plate, "
107  << pCollectiveIn->GetLabel() << ", ";
108  // Collective.pGetDriveCaller()->Restart(out) << ", ";
109  if (fCollLimits) {
110  out << "limits, " << dCollMin << ", " << dCollMax << ", ";
111  }
112  out << pLongitudinalIn->GetLabel() << ", ";
113  // Longitudinal.pGetDriveCaller()->Restart(out) << ", ";
114  if (fForeAftLimits) {
115  out << "limits, " << dForeAftMin << ", " << dForeAftMax << ", ";
116  }
117  out << pLateralIn->GetLabel() << ", ";
118  // Lateral.pGetDriveCaller()->Restart(out) << ", ";
119  if (fLatLimits) {
120  out << "limits, " << dLatMin << ", " << dLatMax << ", ";
121  }
122  out << pNode1->GetLabel() << ", "
123  << pNode2->GetLabel() << ", "
124  << pNode3->GetLabel() << ", "
125  << dDynamicCoef << ", "
126  << dCyclicFactor << ", " << dCollectiveFactor << ';' << std::endl;
127 
128  return out;
129 }
130 
131 /* assemblaggio jacobiano */
134  doublereal dCoef,
135  const VectorHandler& /* XCurr */ ,
136  const VectorHandler& /* XPrimeCurr */ )
137 {
138  DEBUGCOUT("Entering SwashPlate::AssJac()" << std::endl);
139 
140  /* Casting di WorkMat */
141  SparseSubMatrixHandler& WM = WorkMat.SetSparse();
142  WM.ResizeReset(14, 0);
143 
144  integer iCollFirstIndex = pCollectiveIn->iGetFirstIndex() + 1;
145  integer iLongFirstIndex = pLongitudinalIn->iGetFirstIndex() + 1;
146  integer iLatFirstIndex = pLateralIn->iGetFirstIndex() + 1;
147 
148  integer iNode1FirstIndex = pNode1->iGetFirstIndex() + 1;
149  integer iNode2FirstIndex = pNode2->iGetFirstIndex() + 1;
150  integer iNode3FirstIndex = pNode3->iGetFirstIndex() + 1;
151 
152  WM.PutItem(1, iCollFirstIndex, iCollFirstIndex, dCoef);
153  WM.PutItem(2, iLongFirstIndex, iLongFirstIndex, dCoef);
154  WM.PutItem(3, iLatFirstIndex, iLatFirstIndex, dCoef);
155 
156  doublereal d = dDynamicCoef + dCoef;
157 
158  WM.PutItem(4, iNode1FirstIndex, iNode1FirstIndex, d);
159  WM.PutItem(5, iNode2FirstIndex, iNode2FirstIndex, d);
160  WM.PutItem(6, iNode3FirstIndex, iNode3FirstIndex, d);
161 
162  d = dCollectiveFactor;
163 
164  WM.PutItem(7, iNode1FirstIndex, iCollFirstIndex, -d);
165  WM.PutItem(8, iNode2FirstIndex, iCollFirstIndex, -d);
166  WM.PutItem(9, iNode3FirstIndex, iCollFirstIndex, -d);
167 
169 
170  WM.PutItem(10, iNode1FirstIndex, iLongFirstIndex, d);
171 
172  d /= 2.;
173 
174  WM.PutItem(11, iNode2FirstIndex, iLongFirstIndex, -d);
175  WM.PutItem(12, iNode3FirstIndex, iLongFirstIndex, -d);
176 
177  d *= sqrt(3.);
178 
179  WM.PutItem(13, iNode2FirstIndex, iLongFirstIndex, d);
180  WM.PutItem(14, iNode3FirstIndex, iLongFirstIndex, -d);
181 
182  return WorkMat;
183 }
184 
185 
186 /* assemblaggio residuo */
189  doublereal /* dCoef */ ,
190  const VectorHandler& XCurr,
191  const VectorHandler& XPrimeCurr)
192 {
193  DEBUGCOUT("Entering SwashPlate::AssRes()" << std::endl);
194 
195  /* Dimensiona e resetta la matrice di lavoro */
196  WorkVec.ResizeReset(6);
197 
198  integer iCollFirstIndex = pCollectiveIn->iGetFirstIndex() + 1;
199  integer iLongFirstIndex = pLongitudinalIn->iGetFirstIndex() + 1;
200  integer iLatFirstIndex = pLateralIn->iGetFirstIndex() + 1;
201 
202  integer iNode1FirstIndex = pNode1->iGetFirstIndex() + 1;
203  integer iNode2FirstIndex = pNode2->iGetFirstIndex() + 1;
204  integer iNode3FirstIndex = pNode3->iGetFirstIndex() + 1;
205 
206  WorkVec.PutRowIndex(1, iCollFirstIndex);
207  WorkVec.PutRowIndex(2, iLongFirstIndex);
208  WorkVec.PutRowIndex(3, iLatFirstIndex);
209 
210  WorkVec.PutRowIndex(4, iNode1FirstIndex);
211  WorkVec.PutRowIndex(5, iNode2FirstIndex);
212  WorkVec.PutRowIndex(6, iNode3FirstIndex);
213 
214  doublereal dXColl = XCurr(iCollFirstIndex);
215  doublereal dXLong = XCurr(iLongFirstIndex);
216  doublereal dXLat = XCurr(iLatFirstIndex);
217 
218  WorkVec.PutCoef(1, -dXColl);
219  WorkVec.PutCoef(2, -dXLong);
220  WorkVec.PutCoef(3, -dXLat);
221 
222  /* Limits on pitch angles */
223  if (fCollLimits) {
224  if (dXColl > dCollMax) {
225  dXColl = dCollMax;
226  } else if (dXColl < dCollMin) {
227  dXColl = dCollMin;
228  }
229  }
230 
231  if (fForeAftLimits) {
232  if (dXLong > dForeAftMax) {
233  dXLong = dForeAftMax;
234  } else if (dXLong < dForeAftMin) {
235  dXLong = dForeAftMin;
236  }
237  }
238 
239  if (fLatLimits) {
240  if (dXLat > dLatMax) {
241  dXLat = dLatMax;
242  } else if (dXLat < dLatMin) {
243  dXLat = dLatMin;
244  }
245  }
246 
247  WorkVec.PutCoef(4, dCollectiveFactor*(dXColl - dCyclicFactor*dXLong)
248  - XCurr(iNode1FirstIndex) - dDynamicCoef*XPrimeCurr(iNode1FirstIndex));
249  WorkVec.PutCoef(5, dCollectiveFactor*(dXColl + dCyclicFactor*(.5*dXLong - sqrt(3.)/2.*dXLat))
250  - XCurr(iNode2FirstIndex) - dDynamicCoef*XPrimeCurr(iNode2FirstIndex));
251  WorkVec.PutCoef(6, dCollectiveFactor*(dXColl + dCyclicFactor*(.5*dXLong + sqrt(3.)/2.*dXLat))
252  - XCurr(iNode3FirstIndex) - dDynamicCoef*XPrimeCurr(iNode3FirstIndex));
253 
254  return WorkVec;
255 }
256 
257 void
259 {
260  NO_OP;
261 }
262 
263 /* SwashPlate - end */
264 
doublereal dLatMax
Definition: swashpl.h:69
doublereal dDynamicCoef
Definition: swashpl.h:56
virtual std::ostream & Restart(std::ostream &out) const
Definition: genel.cc:60
long int flag
Definition: mbdyn.h:43
virtual ~SwashPlate(void)
Definition: swashpl.cc:96
virtual void ResizeReset(integer)
Definition: vh.cc:55
doublereal dCollMin
Definition: swashpl.h:62
flag fCollLimits
Definition: swashpl.h:60
doublereal dCollMax
Definition: swashpl.h:61
const ScalarDifferentialNode * pLateralIn
Definition: swashpl.h:49
doublereal dForeAftMax
Definition: swashpl.h:65
const ScalarDifferentialNode * pNode3
Definition: swashpl.h:54
virtual std::ostream & Restart(std::ostream &out) const
Definition: swashpl.cc:104
const ScalarDifferentialNode * pCollectiveIn
Definition: swashpl.h:45
flag fForeAftLimits
Definition: swashpl.h:64
void ResizeReset(integer iNewRow, integer iNewCol)
Definition: submat.cc:1084
#define NO_OP
Definition: myassert.h:74
doublereal dCyclicFactor
Definition: swashpl.h:57
doublereal dForeAftMin
Definition: swashpl.h:66
virtual void PutRowIndex(integer iSubRow, integer iRow)=0
void PutItem(integer iSubIt, integer iRow, integer iCol, const doublereal &dCoef)
Definition: submat.h:997
doublereal dCollectiveFactor
Definition: swashpl.h:58
const ScalarDifferentialNode * pNode2
Definition: swashpl.h:53
virtual VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: swashpl.cc:133
doublereal dLatMin
Definition: swashpl.h:70
SwashPlate(unsigned int uL, const DofOwner *pDO, const ScalarDifferentialNode *pCollIn, const ScalarDifferentialNode *pLongIn, const ScalarDifferentialNode *pLatIn, const ScalarDifferentialNode *pN1, const ScalarDifferentialNode *pN2, const ScalarDifferentialNode *pN3, doublereal dDynCoef, doublereal dCyclFact, doublereal dCollFact, flag fCL, doublereal dCMin, doublereal dCMax, flag fFL, doublereal dFMin, doublereal dFMax, flag fLL, doublereal dLMin, doublereal dLMax, flag fOut)
Definition: swashpl.cc:43
#define DEBUGCOUT(msg)
Definition: myassert.h:232
Definition: genel.h:45
#define ASSERT(expression)
Definition: colamd.c:977
GradientExpression< UnaryExpr< FuncSqrt, Expr > > sqrt(const GradientExpression< Expr > &u)
Definition: gradient.h:2974
virtual void PutCoef(integer iRow, const doublereal &dCoef)=0
flag fLatLimits
Definition: swashpl.h:68
Definition: elem.h:75
const ScalarDifferentialNode * pNode1
Definition: swashpl.h:52
virtual SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: swashpl.cc:188
SparseSubMatrixHandler & SetSparse(void)
Definition: submat.h:1178
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
virtual Node::Type GetNodeType(void) const
Definition: node.cc:169
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
unsigned int GetLabel(void) const
Definition: withlab.cc:62
const ScalarDifferentialNode * pLongitudinalIn
Definition: swashpl.h:47
virtual void SetInitialValue(VectorHandler &X)
Definition: swashpl.cc:258