MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
genel.h File Reference
#include "elem.h"
#include "node.h"
Include dependency graph for genel.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Genel
 

Functions

ElemReadGenel (DataManager *pDM, MBDynParser &HP, const DofOwner *pDO, unsigned int uLabel)
 

Variables

const char * psGenelNames []
 

Function Documentation

Elem* ReadGenel ( DataManager pDM,
MBDynParser HP,
const DofOwner pDO,
unsigned int  uLabel 
)

Definition at line 71 of file genel.cc.

References Node::ABSTRACT, Elem::AIRPROPERTIES, ASSERT, DEBUGCOUT, DEBUGCOUTFNAME, Rotor::dGetRadius(), ScalarNode::dGetX(), DofOrder::DIFFERENTIAL, ConstLawType::ELASTIC, DataManager::fReadOutput(), Elem::GENEL, MBDynParser::GetConstLaw1D(), SimulationEntity::GetDofType(), MBDynParser::GetDriveCaller(), HighParser::GetInt(), WithLabel::GetLabel(), IncludeParser::GetLineData(), HighParser::GetLineNumber(), Node::GetNodeType(), HighParser::GetReal(), HighParser::GetWord(), HighParser::GetYesNo(), ConstitutiveLaw< T, Tder >::iGetNumDof(), Elem::INDUCEDVELOCITY, ScalarDof::iOrder, HighParser::IsArg(), HighParser::IsKeyWord(), LASTKEYWORD, MBDYN_EXCEPT_ARGS, Node::PARAMETER, DataManager::pFindElem(), ScalarDof::pNode, DataManager::ReadElem(), DataManager::ReadNode(), ReadScalarDof(), ReadScalarValue(), ReadScalarValues(), SAFEDELETEARR, SAFENEW, SAFENEWARR, SAFENEWARRNOFILL, SAFENEWWITHCONSTRUCTOR, Node::STRUCTURAL, ConstLawType::UNKNOWN, ConstLawType::VISCOELASTIC, and ConstLawType::VISCOUS.

Referenced by DataManager::ReadOneElem().

75 {
76  DEBUGCOUTFNAME("ReadGenel()");
77 
78  const char* sKeyWords[] = {
79  "swashplate",
80  "rotor" "trim",
81  "clamp",
82  "distance",
83  "spring",
84  "spring" "support",
85  "cross" "spring" "support",
86  "mass",
87  "scalar" "filter",
88  "state" "space" "SISO",
89  "state" "space" "MIMO",
90 
91  NULL
92  };
93 
94  /* enum delle parole chiave */
95  enum KeyWords {
96  UNKNOWN = -1,
97 
98  SWASHPLATE = 0,
99  ROTORTRIM,
100  CLAMP,
101  DISTANCE,
102  SPRING,
103  SPRINGSUPPORT,
104  CROSSSPRINGSUPPORT,
105  MASS,
106  SCALARFILTER,
107  STATESPACESISO,
108  STATESPACEMIMO,
109 
111  };
112 
113  /* tabella delle parole chiave */
114  KeyTable K(HP, sKeyWords);
115 
116  /* lettura del tipo di vincolo */
117  KeyWords CurrKeyWord = KeyWords(HP.GetWord());
118 
119  Elem* pEl = 0;
120 
121  switch (CurrKeyWord) {
122  /* genel piatto oscillante */
123  case SWASHPLATE: {
124  /* nodo Collettivo */
125  const ScalarDifferentialNode* pCollIn = pDM->ReadNode<const ScalarDifferentialNode, Node::ABSTRACT>(HP);
126  ASSERT(pCollIn != 0);
127 
128  flag fCollLimits(0);
129  doublereal dCollMax(0.);
130  doublereal dCollMin(0.);
131  if (HP.IsKeyWord("limits")) {
132  fCollLimits = flag(1);
133  dCollMin = HP.GetReal();
134  dCollMax = HP.GetReal();
135  }
136 
137  /* nodo Longitudinale */
138  const ScalarDifferentialNode* pLongIn = pDM->ReadNode<const ScalarDifferentialNode, Node::ABSTRACT>(HP);
139  ASSERT(pLongIn != 0);
140 
141  flag fForeAftLimits(0);
142  doublereal dForeAftMax(0.);
143  doublereal dForeAftMin(0.);
144  if (HP.IsKeyWord("limits")) {
145  fForeAftLimits = flag(1);
146  dForeAftMin = HP.GetReal();
147  dForeAftMax = HP.GetReal();
148  }
149 
150  /* nodo Laterale */
151  const ScalarDifferentialNode* pLatIn = pDM->ReadNode<const ScalarDifferentialNode, Node::ABSTRACT>(HP);
152  ASSERT(pLatIn != 0);
153 
154  flag fLatLimits(0);
155  doublereal dLatMax(0.);
156  doublereal dLatMin(0.);
157  if (HP.IsKeyWord("limits")) {
158  fLatLimits = flag(1);
159  dLatMin = HP.GetReal();
160  dLatMax = HP.GetReal();
161  }
162 
163  /* nodo collegato 1 */
164  const ScalarDifferentialNode* pNode1 = pDM->ReadNode<const ScalarDifferentialNode, Node::ABSTRACT>(HP);
165  ASSERT(pNode1 != 0);
166 
167  /* nodo collegato 2 */
168  const ScalarDifferentialNode* pNode2 = pDM->ReadNode<const ScalarDifferentialNode, Node::ABSTRACT>(HP);
169  ASSERT(pNode2 != 0);
170 
171  /* nodo collegato 3 */
172  const ScalarDifferentialNode* pNode3 = pDM->ReadNode<const ScalarDifferentialNode, Node::ABSTRACT>(HP);
173  ASSERT(pNode3 != 0);
174 
175  doublereal dDynCoef = 0.;
176  if (HP.IsArg()) {
177  dDynCoef = HP.GetReal(dDynCoef);
178  }
179 
180  doublereal dCyclFact = 1.;
181  if (HP.IsArg()) {
182  dCyclFact = HP.GetReal(dCyclFact);
183  }
184 
185  doublereal dCollFact = 1.;
186  if (HP.IsArg()) {
187  dCollFact = HP.GetReal(dCollFact);
188  }
189 
190  flag fOut = pDM->fReadOutput(HP, Elem::GENEL);
191 
193  SwashPlate,
194  SwashPlate(uLabel, pDO,
195  pCollIn,
196  pLongIn,
197  pLatIn,
198  pNode1, pNode2, pNode3,
199  dDynCoef,
200  dCyclFact,
201  dCollFact,
202  fCollLimits,
203  dCollMin,
204  dCollMax,
205  fForeAftLimits,
206  dForeAftMin,
207  dForeAftMax,
208  fLatLimits,
209  dLatMin,
210  dLatMax,
211  fOut));
212  } break;
213 
214  case ROTORTRIM: {
215  // "rotor" (traditional)
216  const Rotor* pRot = 0;
217 
218  // "generic"
219  const StructNode *pStrNode = 0;
220  const DriveCaller *pThrust = 0;
221  const DriveCaller *pRollMoment = 0;
222  const DriveCaller *pPitchMoment = 0;
223  const AirProperties *pAP = 0;
224  doublereal dRadius = -1.;
225  const DriveCaller *pOmega = 0;
226  const DriveCaller *pMu = 0;
227 
228  if (HP.IsKeyWord("generic")) {
229  if (HP.IsKeyWord("reference" "node")) {
230  pStrNode = dynamic_cast<StructNode *>(pDM->ReadNode(HP, Node::STRUCTURAL));
231  }
232 
233  pThrust = HP.GetDriveCaller();
234  pRollMoment = HP.GetDriveCaller();
235  pPitchMoment = HP.GetDriveCaller();
236 
237  pAP = pDM->pFindElem<const AirProperties, Elem::AIRPROPERTIES>();
238 
239  dRadius = HP.GetReal();
240  if (dRadius < std::numeric_limits<doublereal>::epsilon()) {
241  silent_cerr("RotorTrim(" << uLabel << "): "
242  "invalid rotor radius at line " << HP.GetLineData() << std::endl);
244  }
245 
246  pOmega = HP.GetDriveCaller();
247  pMu = HP.GetDriveCaller();
248 
249  } else {
250  if (!HP.IsKeyWord("rotor")) {
251  silent_cout("RotorTrim(" << uLabel << "): "
252  "keyword \"rotor\" expected at line " << HP.GetLineData() << std::endl);
253  }
254 
255  pRot = pDM->ReadElem<const Rotor, const InducedVelocity, Elem::INDUCEDVELOCITY>(HP);
256 
257  dRadius = pRot->dGetRadius();
258  if (dRadius < std::numeric_limits<doublereal>::epsilon()) {
259  silent_cerr("RotorTrim(" << uLabel << "): "
260  "invalid rotor radius for Rotor(" << pRot->GetLabel() << ") "
261  "at line " << HP.GetLineData() << std::endl);
263  }
264  }
265 
266  const ScalarDifferentialNode* pvNodes[3];
267  pvNodes[0] = pDM->ReadNode<const ScalarDifferentialNode, Node::ABSTRACT>(HP);
268  pvNodes[1] = pDM->ReadNode<const ScalarDifferentialNode, Node::ABSTRACT>(HP);
269  pvNodes[2] = pDM->ReadNode<const ScalarDifferentialNode, Node::ABSTRACT>(HP);
270 
271  DEBUGCOUT("Rotor trim " << uLabel
272  << " linked to rotor " << pRot->GetLabel() << std::endl
273  << "abstract nodes: "
274  << pvNodes[0]->GetLabel() << ", "
275  << pvNodes[1]->GetLabel() << ", "
276  << pvNodes[2]->GetLabel() << std::endl);
277 
278  DriveCaller* pvDrives[3];
279  pvDrives[0] = HP.GetDriveCaller();
280  pvDrives[1] = HP.GetDriveCaller();
281  pvDrives[2] = HP.GetDriveCaller();
282 
283  doublereal dGamma = HP.GetReal();
284  DEBUGCOUT("Gamma: " << dGamma << std::endl);
285 
286  doublereal dP = HP.GetReal();
287  DEBUGCOUT("P: " << dP << std::endl);
288 
289  doublereal dTau0 = HP.GetReal();
290  DEBUGCOUT("Tau0: " << dTau0 << std::endl);
291 
292  doublereal dTau1 = HP.GetReal();
293  DEBUGCOUT("Tau1: " << dTau1 << std::endl);
294 
295  doublereal dKappa0 = HP.GetReal();
296  DEBUGCOUT("Kappa0: " << dKappa0 << std::endl);
297 
298  doublereal dKappa1 = HP.GetReal();
299  DEBUGCOUT("Kappa1: " << dKappa1 << std::endl);
300 
301  DriveCaller *pTrigger = 0;
302  if (HP.IsKeyWord("trigger")) {
303  pTrigger = HP.GetDriveCaller();
304 
305  } else {
306  SAFENEW(pTrigger, OneDriveCaller);
307  }
308 
309  flag fOut = pDM->fReadOutput(HP, Elem::GENEL);
310 
311  if (pRot) {
313  RotorTrim,
314  RotorTrim(uLabel, pDO, pRot,
315  pvNodes[0], pvNodes[1], pvNodes[2],
316  pvDrives[0], pvDrives[1], pvDrives[2],
317  dGamma, dP,
318  dTau0, dTau1, dKappa0, dKappa1,
319  pTrigger, fOut));
320 
321  } else {
324  RotorTrimGeneric(uLabel, pDO,
325  pStrNode,
326  pThrust, pRollMoment, pPitchMoment,
327  pAP, dRadius, pOmega, pMu,
328  pvNodes[0], pvNodes[1], pvNodes[2],
329  pvDrives[0], pvDrives[1], pvDrives[2],
330  dGamma, dP,
331  dTau0, dTau1, dKappa0, dKappa1,
332  pTrigger, fOut));
333  }
334  } break;
335 
336  case CLAMP: {
337  ScalarDof SD = ReadScalarDof(pDM, HP, true, true);
338  if (SD.pNode->GetNodeType() == Node::PARAMETER) {
339  silent_cerr("GenelClamp(" << uLabel << "): "
340  "parameter nodes are not allowed "
341  "at line " << HP.GetLineData()
342  << std::endl);
344  }
345 
346  if (SD.iOrder > 1) {
347  silent_cerr("GenelClamp(" << uLabel << "): "
348  "illegal order " << SD.iOrder
349  << " for ScalarDof "
350  "at line " << HP.GetLineData()
351  << std::endl);
353  }
354 
355  DriveCaller* pDC = HP.GetDriveCaller();
356 
357  flag fOut = pDM->fReadOutput(HP, Elem::GENEL);
358 
360  GenelClamp,
361  GenelClamp(uLabel, pDO, pDC, SD, fOut));
362  } break;
363 
364  case DISTANCE: {
365  ScalarDof SD1 = ReadScalarDof(pDM, HP, true, true);
366  if (SD1.pNode->GetNodeType() == Node::PARAMETER) {
367  silent_cerr("GenelDistance(" << uLabel << "): "
368  "parameter nodes not allowed "
369  "for ScalarDof 1 "
370  "at line " << HP.GetLineData()
371  << std::endl);
373  }
374 
375  if (SD1.iOrder > 1) {
376  silent_cerr("GenelDistance(" << uLabel << "): "
377  "illegal order " << SD1.iOrder
378  << " for ScalarDof 1 "
379  "at line " << HP.GetLineData()
380  << std::endl);
382  }
383 
384  ScalarDof SD2 = ReadScalarDof(pDM, HP, true, true);
385  if (SD2.pNode->GetNodeType() == Node::PARAMETER) {
386  silent_cerr("GenelDistance(" << uLabel << "): "
387  "parameter nodes not allowed "
388  "for ScalarDof 2 "
389  "at line " << HP.GetLineData()
390  << std::endl);
392  }
393 
394  if (SD2.iOrder > 1) {
395  silent_cerr("GenelDistance(" << uLabel << "): "
396  "illegal order " << SD2.iOrder
397  << " for ScalarDof 2 "
398  "at line " << HP.GetLineData()
399  << std::endl);
401  }
402 
403  DriveCaller* pDC = HP.GetDriveCaller();
404 
405  flag fOut = pDM->fReadOutput(HP, Elem::GENEL);
406 
409  GenelDistance(uLabel, pDO, pDC, SD1, SD2, fOut));
410 
411  } break;
412 
413  case SPRING: {
414  ScalarDof SD1 = ReadScalarDof(pDM, HP, true, true);
415  if (SD1.pNode->GetNodeType() == Node::PARAMETER) {
416  silent_cerr("GenelSpring(" << uLabel << "): "
417  "parameter nodes not allowed for ScalarDof 1 "
418  "at line " << HP.GetLineData()
419  << std::endl);
421  }
422 
423  if (SD1.iOrder > 1) {
424  silent_cerr("GenelSpring(" << uLabel << "): "
425  "illegal order " << SD1.iOrder
426  << " for ScalarDof 1 "
427  "at line " << HP.GetLineData()
428  << std::endl);
430  }
431 
432  ScalarDof SD2 = ReadScalarDof(pDM, HP, true, true);
433  if (SD2.pNode->GetNodeType() == Node::PARAMETER) {
434  silent_cerr("GenelSpring(" << uLabel << "): "
435  "parameter nodes not allowed for ScalarDof 2 "
436  "at line " << HP.GetLineData()
437  << std::endl);
439  }
440 
441  if (SD2.iOrder > 1) {
442  silent_cerr("GenelSpring(" << uLabel << "): "
443  "illegal order " << SD2.iOrder
444  << " for ScalarDof 2 "
445  "at line " << HP.GetLineData()
446  << std::endl);
448  }
449 
451  ConstitutiveLaw1D* pCL = HP.GetConstLaw1D(CLType);
452 
453  if (pCL->iGetNumDof() != 0) {
454  silent_cerr("GenelSpring(" << uLabel << "): "
455  "support dynamic constitutive laws "
456  "not supported "
457  "at line " << HP.GetLineData()
458  << std::endl);
460  }
461 
462  if (CLType != ConstLawType::ELASTIC) {
463  silent_cerr("GenelSpring(" << uLabel << "): "
464  "only elastic constitutive laws allowed "
465  "at line " << HP.GetLineData()
466  << std::endl);
468  }
469 
470  flag fOut = pDM->fReadOutput(HP, Elem::GENEL);
471 
473  GenelSpring,
474  GenelSpring(uLabel, pDO, pCL, SD1, SD2, fOut));
475 
476  } break;
477 
478  case SPRINGSUPPORT: {
479  ScalarDof SD = ReadScalarDof(pDM, HP, true, true);
480  if (SD.pNode->GetNodeType() == Node::PARAMETER) {
481  silent_cerr("GenelSpringSupport(" << uLabel << "): "
482  "parameter nodes not allowed for ScalarDof "
483  "at line " << HP.GetLineData()
484  << std::endl);
486  }
487 
488  if (SD.iOrder != 0 ||
490  {
491  silent_cerr("GenelSpringSupport(" << uLabel << "): "
492  "illegal order " << SD.iOrder
493  << " for ScalarDof; the algebraic value "
494  "of a differential node is required "
495  "at line " << HP.GetLineData()
496  << std::endl);
498  }
499 
501  ConstitutiveLaw1D* pCL = HP.GetConstLaw1D(CLType);
502  if (pCL->iGetNumDof() != 0) {
503  silent_cerr("GenelSpringSupport(" << uLabel << "): "
504  "only elastic constitutive laws allowed "
505  "at line " << HP.GetLineData()
506  << std::endl);
508  }
509 
510  doublereal X0 = 0.;
511 
512  if (HP.IsKeyWord("position")) {
513  if (HP.IsKeyWord("from" "node")) {
514  X0 = SD.pNode->dGetX();
515  } else {
516  X0 = HP.GetReal();
517  }
518  }
519 
520  flag fOut = pDM->fReadOutput(HP, Elem::GENEL);
521 
522  switch (CLType) {
526  GenelSpringSupport(uLabel, pDO, pCL,
527  SD, X0, fOut));
528  break;
529 
534  GenelSpringDamperSupport(uLabel, pDO, pCL,
535  SD, X0, fOut));
536  break;
537 
538  default:
539  silent_cerr("You shouldn't be here!" << std::endl);
541  }
542 
543  } break;
544 
545  case CROSSSPRINGSUPPORT: {
546  ScalarDof SDRow = ReadScalarDof(pDM, HP, true, true);
547  if (SDRow.pNode->GetNodeType() == Node::PARAMETER) {
548  silent_cerr(
549  "GenelCrossSpringSupport(" << uLabel << "): "
550  "parameter nodes not allowed for ScalarDof 1 "
551  "at line " << HP.GetLineData()
552  << std::endl);
554  }
555 
556  if (SDRow.iOrder > 1) {
557  silent_cerr(
558  "GenelCrossSpringSupport(" << uLabel << "): "
559  "illegal order " << SDRow.iOrder
560  << " for ScalarDof 1 "
561  "at line " << HP.GetLineData()
562  << std::endl);
564  }
565 
566  ScalarDof SDCol = ReadScalarDof(pDM, HP, true, true);
567  if (SDCol.iOrder != 0 ||
569  {
570  silent_cerr(
571  "GenelCrossSpringSupport(" << uLabel << "): "
572  "parameter nodes not allowed for ScalarDof "
573  "at line " << HP.GetLineData()
574  << std::endl);
576  }
577 
578  if (SDCol.iOrder != 0 ||
580  {
581  silent_cerr(
582  "GenelCrossSpringSupport(" << uLabel << "): "
583  "illegal order " << SDCol.iOrder
584  << " for ScalarDof; the algebraic value "
585  "of a differential node is required "
586  "at line " << HP.GetLineData()
587  << std::endl);
589  }
590 
592  ConstitutiveLaw1D* pCL = HP.GetConstLaw1D(CLType);
593 
594  if (pCL->iGetNumDof() != 0) {
595  silent_cerr(
596  "GenelCrossSpringSupport(" << uLabel << "): "
597  "dynamic constitutive laws not supported "
598  "at line " << HP.GetLineData()
599  << std::endl);
601  }
602 
603  flag fOut = pDM->fReadOutput(HP, Elem::GENEL);
604 
605  switch (CLType) {
609  GenelCrossSpringSupport(uLabel, pDO, pCL,
610  SDRow, SDCol, fOut));
611  break;
612 
617  GenelCrossSpringDamperSupport(uLabel, pDO, pCL,
618  SDRow, SDCol, fOut));
619  break;
620 
621  default:
622  silent_cerr("You shouldn't be here!" << std::endl);
624  }
625 
626  } break;
627 
628  case MASS: {
629  ScalarDof SD = ReadScalarDof(pDM, HP, true, true);
630  if (SD.pNode->GetNodeType() == Node::PARAMETER) {
631  silent_cerr("GenelMass(" << uLabel << "): "
632  "parameter nodes not allowed for ScalarDof "
633  "at line " << HP.GetLineData()
634  << std::endl);
636  }
637 
638  if (SD.iOrder > 1) {
639  silent_cerr("GenelMass(" << uLabel << "): "
640  "illegal order " << SD.iOrder
641  << " for ScalarDof 1 "
642  "at line " << HP.GetLineData()
643  << std::endl);
645  }
646 
647  if (SD.pNode->GetDofType(0) != DofOrder::DIFFERENTIAL) {
648  silent_cerr("GenelMass(" << uLabel << "): "
649  "only differential dofs allowed for ScalarDof "
650  "at line " << HP.GetLineData()
651  << std::endl);
653  }
654 
655  DriveCaller* pDC = HP.GetDriveCaller();
656 
657  flag fOut = pDM->fReadOutput(HP, Elem::GENEL);
658 
660  GenelMass,
661  GenelMass(uLabel, pDO, pDC, SD, fOut));
662 
663  } break;
664 
665  case STATESPACESISO: {
666  ScalarDof SD_y = ReadScalarDof(pDM, HP, true, true);
667  if (SD_y.pNode->GetNodeType() == Node::PARAMETER) {
668  silent_cerr("GenelStateSpaceSISO(" << uLabel << "): "
669  "parameter nodes not allowed "
670  "for output ScalarDof (y) "
671  "at line " << HP.GetLineData()
672  << std::endl);
674  }
675 
676  if (SD_y.iOrder > 1) {
677  silent_cerr("GenelStateSpaceSISO(" << uLabel << "): "
678  "illegal order " << SD_y.iOrder
679  << " for output ScalarDof (y) "
680  "at line " << HP.GetLineData()
681  << std::endl);
683  }
684 
685  ScalarValue *SV_u = ReadScalarValue(pDM, HP);
686 
687  unsigned int Order = HP.GetInt();
688  DEBUGCOUT("State Space SISO " << uLabel
689  << " is of order " << Order << std::endl);
690 
691  doublereal* pd = 0;
692 
693  doublereal* pdE = 0;
694  if (HP.IsKeyWord("matrix" "E")) {
695  SAFENEWARR(pdE, doublereal, Order*Order);
696  pd = pdE;
697  for (unsigned int i = 0; i < Order*Order; i++) {
698  *pd++ = HP.GetReal();
699  }
700  }
701 
702  if (!HP.IsKeyWord("matrix" "A")) {
703  silent_cerr("GenelStateSpaceSISO(" << uLabel << "): "
704  "matrix A expected "
705  "at line " << HP.GetLineNumber()
706  << std::endl);
708  }
709 
710  doublereal* pdA = 0;
711  SAFENEWARR(pdA, doublereal, Order*Order);
712  pd = pdA;
713  for (unsigned int i = 0; i < Order*Order; i++) {
714  *pd++ = HP.GetReal();
715  }
716 
717  if (!HP.IsKeyWord("matrix" "B")) {
718  silent_cerr("GenelStateSpaceSISO(" << uLabel << "): "
719  "matrix B expected "
720  "at line " << HP.GetLineNumber()
721  << std::endl);
723  }
724 
725  doublereal* pdB = 0;
726  SAFENEWARR(pdB, doublereal, Order);
727  pd = pdB;
728  for (unsigned int i = 0; i < Order; i++) {
729  *pd++ = HP.GetReal();
730  }
731 
732  if (!HP.IsKeyWord("matrix" "C")) {
733  silent_cerr("GenelStateSpaceSISO(" << uLabel << "): "
734  "matrix C expected "
735  "at line " << HP.GetLineNumber()
736  << std::endl);
738  }
739 
740  doublereal* pdC = 0;
741  SAFENEWARR(pdC, doublereal, Order);
742  pd = pdC;
743  for (unsigned int i = 0; i < Order; i++) {
744  *pd++ = HP.GetReal();
745  }
746 
747  doublereal dD = 0.;
748  if (HP.IsKeyWord("matrix" "D")) {
749  if (pdE) {
750  silent_cerr("GenelStateSpaceSISO(" << uLabel << "): "
751  "warning, matrix D provided "
752  "while in descriptor form "
753  "at line " << HP.GetLineData()
754  << std::endl);
755  }
756  dD = HP.GetReal();
757  }
758 
759  if (HP.IsKeyWord("gain")) {
760  doublereal dGain = HP.GetReal();
761 
762  pd = pdC;
763  for (unsigned int i = 0; i < Order; i++) {
764  *pd++ *= dGain;
765  }
766 
767  dD *= dGain;
768  }
769 
770  bool bBalance(true);
771  if (HP.IsKeyWord("balance")) {
772  if (!HP.GetYesNo(bBalance)) {
773  silent_cerr("GenelStateSpaceSISO(" << uLabel << "): "
774  "unknown balance mode at line "
775  << HP.GetLineData()
776  << std::endl);
778  }
779  }
780 
781  doublereal *pdX0 = 0;
782  std::vector<doublereal> dX0;
783  doublereal *pdXP0 = 0;
784  std::vector<doublereal> dXP0;
785 
786  if (HP.IsKeyWord("value")) {
787  dX0.resize(Order);
788  pdX0 = &dX0[0];
789 
790  for (unsigned i = 0; i < Order; i++) {
791  dX0[i] = HP.GetReal();
792  }
793 
794  if (pdE != 0 && HP.IsKeyWord("derivative")) {
795  dXP0.resize(Order);
796  pdXP0 = &dXP0[0];
797 
798  for (unsigned i = 0; i < Order; i++) {
799  dXP0[i] = HP.GetReal();
800  }
801  }
802  }
803 
804  flag fOut = pDM->fReadOutput(HP, Elem::GENEL);
805 
808  GenelStateSpaceSISO(uLabel, pDO, SD_y, SV_u,
809  Order,
810  pdE, pdA, pdB, pdC, dD, bBalance,
811  pdX0, pdXP0, fOut));
812 
813  } break;
814 
815  case SCALARFILTER: {
816  ScalarDof SD_y = ReadScalarDof(pDM, HP, true, true);
817  if (SD_y.pNode->GetNodeType() == Node::PARAMETER) {
818  silent_cerr("ScalarFilter(" << uLabel << "): "
819  "parameter nodes not allowed "
820  "for output ScalarDof (y) "
821  "at line " << HP.GetLineData()
822  << std::endl);
824  }
825 
826  if (SD_y.iOrder > 1) {
827  silent_cerr("ScalarFilter(" << uLabel << "): "
828  "illegal order " << SD_y.iOrder
829  << " for output ScalarDof (y) "
830  "at line " << HP.GetLineData()
831  << std::endl);
833  }
834 
835  ScalarValue *SV_u = ReadScalarValue(pDM, HP);
836 
837 /*
838  * if nn < nd (strictly proper):
839  *
840  * n_0 s^nn + n_1 s^(nn-1) + ... + n_nn
841  * ------------------------------------
842  * s^nd + d_1 s^(nd-1) + ... + d_nd
843  *
844  * d_0 == 1
845  *
846  * if nn == nd (proper, not strictly proper):
847  *
848  * n_0 s^n + n_1 s^(n-1) + ... + n_n
849  * ------------------------------------
850  * s^n + d_1 s^(n-1) + ... + d_n
851  *
852  * (n_1 - d_1*n_0) s^(n-1) + ... (n_n - d_n *n_0)
853  * n_0 + ----------------------------------------------
854  * s^n + d_1 s^(n-1) + ... + d_n
855  *
856  * d_0 == 1
857  *
858  */
859 
860  bool bControllable(true);
861  if (HP.IsKeyWord("canonical" "form")) {
862  if (HP.IsKeyWord("controllable")) {
863  bControllable = true;
864 
865  } else if (HP.IsKeyWord("observable")) {
866  bControllable = false;
867 
868  } else {
869  silent_cerr("ScalarFilter(" << uLabel << "):"
870  "unknown canonical form "
871  "at line " << HP.GetLineData()
872  << std::endl);
874  }
875  }
876 
877  int nd = HP.GetInt();
878  if (nd < 1) {
879  silent_cerr("ScalarFilter(" << uLabel << "):"
880  "invalid denominator order " << nd << " "
881  "at line " << HP.GetLineData()
882  << std::endl);
884  }
885 
886  std::vector<doublereal> den(nd + 1);
887  den[0] = 1.;
888  for (int i = 1; i <= nd; i++) {
889  den[i] = HP.GetReal();
890  }
891 
892  int nn = HP.GetInt();
893  if (nn < 0 || nn > nd) {
894  silent_cerr("ScalarFilter(" << uLabel << "):"
895  "invalid numerator order " << nn << " "
896  "at line " << HP.GetLineData()
897  << std::endl);
899  }
900 
901  std::vector<doublereal> num(nd + 1);
902  for (int i = 0; i < nd - nn; i++) {
903  num[i] = 0.;
904  }
905 
906  for (int i = nd - nn; i <= nd; i++) {
907  num[i] = HP.GetReal();
908  }
909 
910  if (HP.IsKeyWord("gain")) {
911  doublereal dGain = HP.GetReal();
912 
913  for (int i = 0; i <= nd; i++) {
914  num[i] *= dGain;
915  }
916  }
917 
918  // turn into strictly proper plus direct feedthrough
919  if (nn == nd) {
920  for (int i = 1; i <= nd; i++) {
921  num[i] -= den[i]*num[0];
922  }
923  }
924 
925  int Order = nd;
926 
927  doublereal* pd = 0;
928 
929  doublereal* pdE = 0;
930  doublereal* pdA = 0;
931  SAFENEWARR(pdA, doublereal, Order*Order);
932  doublereal* pdB = 0;
933  SAFENEWARR(pdB, doublereal, Order);
934  doublereal* pdC = 0;
935  SAFENEWARR(pdC, doublereal, Order);
936  doublereal dD = num[0];
937 
938  if (bControllable) {
939  // matrix A
940  pd = pdA;
941  for (int i = 1; i <= Order; i++) {
942  *pd++ = -den[i];
943  }
944  for (int i = 0; i < Order - 2; i++) {
945  *pd++ = 1.;
946  for (int j = 0; j < Order; j++) {
947  *pd++ = 0.;
948  }
949  }
950 
951  if (Order > 1) {
952  *pd++ = 1.;
953  *pd++ = 0.;
954  }
955 
956  ASSERT(pd == pdA + Order*Order);
957 
958  // matrix B
959  pd = pdB;
960  *pd++ = 1.;
961  for (int i = 0; i < Order - 1; i++) {
962  *pd++ = 0.;
963  }
964 
965  // matrix C
966  pd = pdC;
967  for (int i = 1; i <= Order; i++) {
968  *pd++ = num[i];
969  }
970 
971  } else {
972  // matrix A
973  pd = pdA;
974  for (int i = 1; i <= Order; i++) {
975  *pd++ = -den[i];
976  for (int j = 1; j < Order; j++) {
977  if (j == i) {
978  *pd++ = 1.;
979 
980  } else {
981  *pd++ = 0.;
982  }
983  }
984  }
985 
986  ASSERT(pd == pdA + Order*Order);
987 
988  // matrix B
989  pd = pdB;
990  for (int i = 1; i <= Order; i++) {
991  *pd++ = num[i];
992  }
993 
994  // matrix C
995  pd = pdC;
996  *pd++ = 1.;
997  for (int i = 0; i < Order - 1; i++) {
998  *pd++ = 0.;
999  }
1000  }
1001 
1002  bool bBalance(true);
1003  if (HP.IsKeyWord("balance")) {
1004  if (!HP.GetYesNo(bBalance)) {
1005  silent_cerr("ScalarFilter(" << uLabel << "): "
1006  "unknown balance mode at line "
1007  << HP.GetLineData()
1008  << std::endl);
1010  }
1011  }
1012 
1013  flag fOut = pDM->fReadOutput(HP, Elem::GENEL);
1014 
1017  GenelStateSpaceSISO(uLabel, pDO, SD_y, SV_u,
1018  Order,
1019  pdE, pdA, pdB, pdC, dD, bBalance,
1020  0, 0, fOut));
1021 
1022  } break;
1023 
1024  case STATESPACEMIMO: {
1025  int iNumOutputs = HP.GetInt();
1026  if (iNumOutputs <= 0) {
1027  silent_cerr("GenelStateSpaceMIMO(" << uLabel << "): "
1028  "illegal number of outputs "
1029  "at line " << HP.GetLineData()
1030  << std::endl);
1032  }
1033 
1034  ScalarDof* pvSD_y = 0;
1035  SAFENEWARRNOFILL(pvSD_y, ScalarDof, iNumOutputs);
1036  for (int i = 0; i < iNumOutputs; i++) {
1037  pvSD_y[i] = ReadScalarDof(pDM, HP, true, true);
1038  if (pvSD_y[i].pNode->GetNodeType() == Node::PARAMETER)
1039  {
1040  silent_cerr("GenelStateSpaceMIMO(" << uLabel << "): "
1041  "parameter nodes not allowed "
1042  "for output ScalarDof "
1043  "(y[" << i << "]) "
1044  "at line " << HP.GetLineData()
1045  << std::endl);
1046  SAFEDELETEARR(pvSD_y);
1048  }
1049 
1050  if (pvSD_y[i].iOrder > 1) {
1051  silent_cerr("GenelStateSpaceMIMO(" << uLabel << "): "
1052  "illegal order " << pvSD_y[i].iOrder
1053  << " for output ScalarDof "
1054  "(y[" << i << "]) "
1055  "at line " << HP.GetLineData()
1056  << std::endl);
1057  SAFEDELETEARR(pvSD_y);
1059  }
1060  }
1061 
1062  int iNumInputs = HP.GetInt();
1063  if (iNumInputs <= 0) {
1064  silent_cerr("GenelStateSpaceMIMO(" << uLabel << "): "
1065  "illegal number of inputs "
1066  "at line " << HP.GetLineData()
1067  << std::endl);
1068  SAFEDELETEARR(pvSD_y);
1070  }
1071 
1072  std::vector<ScalarValue *> SV_u(iNumInputs);
1073  ReadScalarValues(pDM, HP, SV_u);
1074 
1075  unsigned int Order = HP.GetInt();
1076  DEBUGCOUT("State Space MIMO " << uLabel
1077  << " is of order " << Order << std::endl);
1078 
1079  doublereal* pd = 0;
1080  doublereal* pdE = 0;
1081  if (HP.IsKeyWord("matrix" "E")) {
1082  SAFENEWARR(pdE, doublereal, Order*Order);
1083  pd = pdE;
1084  for (unsigned int i = 0; i < Order*Order; i++) {
1085  *pd++ = HP.GetReal();
1086  }
1087  }
1088 
1089  if (!HP.IsKeyWord("matrix" "A")) {
1090  silent_cerr("GenelStateSpaceMIMO(" << uLabel << "): "
1091  "matrix A expected "
1092  "at line " << HP.GetLineNumber()
1093  << std::endl);
1094  SAFEDELETEARR(pvSD_y);
1096  }
1097 
1098  doublereal* pdA = 0;
1099  SAFENEWARR(pdA, doublereal, Order*Order);
1100  pd = pdA;
1101  for (unsigned int i = 0; i < Order*Order; i++) {
1102  *pd++ = HP.GetReal();
1103  }
1104 
1105  if (!HP.IsKeyWord("matrix" "B")) {
1106  silent_cerr("GenelStateSpaceMIMO(" << uLabel << "): "
1107  "matrix B expected "
1108  "at line " << HP.GetLineNumber()
1109  << std::endl);
1110  SAFEDELETEARR(pvSD_y);
1112  }
1113 
1114  doublereal* pdB = 0;
1115  SAFENEWARR(pdB, doublereal, Order*iNumInputs);
1116  pd = pdB;
1117  for (unsigned int i = 0; i < Order*iNumInputs; i++) {
1118  *pd++ = HP.GetReal();
1119  }
1120 
1121  if (!HP.IsKeyWord("matrix" "C")) {
1122  silent_cerr("GenelStateSpaceMIMO(" << uLabel << "): "
1123  "matrix C expected "
1124  "at line " << HP.GetLineNumber()
1125  << std::endl);
1126  SAFEDELETEARR(pvSD_y);
1128  }
1129 
1130  doublereal* pdC = 0;
1131  SAFENEWARR(pdC, doublereal, iNumOutputs*Order);
1132  pd = pdC;
1133  for (unsigned int i = 0; i < iNumOutputs*Order; i++) {
1134  *pd++ = HP.GetReal();
1135  }
1136 
1137  doublereal* pdD = 0;
1138  if (HP.IsKeyWord("matrix" "D")) {
1139  if (pdE) {
1140  silent_cerr("GenelStateSpaceMIMO(" << uLabel << "): "
1141  "warning, matrix D provided "
1142  "while in descriptor form "
1143  "at line " << HP.GetLineData()
1144  << std::endl);
1145  SAFEDELETEARR(pvSD_y);
1146  }
1147  SAFENEWARR(pdD, doublereal, iNumOutputs*iNumInputs);
1148  pd = pdD;
1149  for (int i = 0; i < iNumOutputs*iNumInputs; i++) {
1150  *pd++ = HP.GetReal();
1151  }
1152  }
1153 
1154  if (HP.IsKeyWord("gain")) {
1155  doublereal dGain = HP.GetReal();
1156 
1157  pd = pdC;
1158  for (unsigned int i = 0; i < iNumOutputs*Order; i++) {
1159  *pd++ *= dGain;
1160  }
1161 
1162  pd = pdD;
1163  for (int i = 0; i < iNumOutputs*iNumInputs; i++) {
1164  *pd++ *= dGain;
1165  }
1166  }
1167 
1168  bool bBalance(true);
1169  if (HP.IsKeyWord("balance")) {
1170  if (!HP.GetYesNo(bBalance)) {
1171  silent_cerr("GenelStateSpaceMIMO(" << uLabel << "): "
1172  "unknown balance mode at line "
1173  << HP.GetLineData()
1174  << std::endl);
1175  SAFEDELETEARR(pvSD_y);
1177  }
1178  }
1179 
1180  doublereal *pdX0 = 0;
1181  std::vector<doublereal> dX0;
1182  doublereal *pdXP0 = 0;
1183  std::vector<doublereal> dXP0;
1184 
1185  if (HP.IsKeyWord("value")) {
1186  dX0.resize(Order);
1187  pdX0 = &dX0[0];
1188 
1189  for (unsigned i = 0; i < Order; i++) {
1190  dX0[i] = HP.GetReal();
1191  }
1192 
1193  if (pdE != 0 && HP.IsKeyWord("derivative")) {
1194  dXP0.resize(Order);
1195  pdXP0 = &dXP0[0];
1196 
1197  for (unsigned i = 0; i < Order; i++) {
1198  dXP0[i] = HP.GetReal();
1199  }
1200  }
1201  }
1202 
1203  flag fOut = pDM->fReadOutput(HP, Elem::GENEL);
1204 
1207  GenelStateSpaceMIMO(uLabel, pDO,
1208  iNumOutputs, pvSD_y,
1209  SV_u,
1210  Order,
1211  pdE, pdA, pdB, pdC, pdD, bBalance,
1212  pdX0, pdXP0, fOut));
1213 
1214  } break;
1215 
1216  /* Aggiungere altri genel */
1217  default:
1218  silent_cerr("Genel(" << uLabel << "): "
1219  "unknown type at line " << HP.GetLineData()
1220  << std::endl);
1222  }
1223 
1224  /* Se non c'e' il punto e virgola finale */
1225  if (HP.IsArg()) {
1226  silent_cerr("semicolon expected "
1227  "at line " << HP.GetLineData() << std::endl);
1229  }
1230 
1231  return pEl;
1232 } /* ReadGenel() */
flag fReadOutput(MBDynParser &HP, const T &t) const
Definition: dataman.h:1064
ScalarNode * pNode
Definition: node.h:708
long int flag
Definition: mbdyn.h:43
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
#define DEBUGCOUTFNAME(fname)
Definition: myassert.h:256
virtual integer GetInt(integer iDefval=0)
Definition: parser.cc:1050
Elem * ReadElem(MBDynParser &HP, Elem::Type type) const
Definition: dataman3.cc:2334
int iOrder
Definition: node.h:710
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
virtual const doublereal & dGetX(void) const =0
Elem * pFindElem(Elem::Type Typ, unsigned int uElem, unsigned int iDeriv) const
Definition: elman.cc:650
virtual doublereal dGetRadius(void) const
Definition: rotor.h:158
#define SAFENEW(pnt, item)
Definition: mynewmem.h:695
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
ScalarValue * ReadScalarValue(DataManager *pDM, MBDynParser &HP)
Definition: scalarvalue.cc:80
#define DEBUGCOUT(msg)
Definition: myassert.h:232
virtual DofOrder::Order GetDofType(unsigned int i) const =0
#define ASSERT(expression)
Definition: colamd.c:977
Order
Definition: shapefnc.h:42
KeyWords
Definition: dataman4.cc:94
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
virtual unsigned int iGetNumDof(void) const
Definition: constltp.h:138
virtual bool GetYesNo(bool &bRet)
Definition: parser.cc:1022
virtual bool IsArg(void)
Definition: parser.cc:807
Definition: elem.h:75
virtual Node::Type GetNodeType(void) const =0
#define SAFENEWARRNOFILL(pnt, item, sz)
Definition: mynewmem.h:704
virtual int GetWord(void)
Definition: parser.cc:1083
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
virtual int GetLineNumber(void) const
Definition: parser.cc:674
DriveCaller * GetDriveCaller(bool bDeferred=false)
Definition: mbpar.cc:2033
void ReadScalarValues(DataManager *pDM, MBDynParser &HP, std::vector< ScalarValue * > &Values)
Definition: scalarvalue.cc:101
double doublereal
Definition: colamd.c:52
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
unsigned int GetLabel(void) const
Definition: withlab.cc:62
Node * ReadNode(MBDynParser &HP, Node::Type type) const
Definition: dataman3.cc:2309
ConstitutiveLaw1D * GetConstLaw1D(ConstLawType::Type &clt)
Definition: mbpar.cc:1941
ScalarDof ReadScalarDof(const DataManager *pDM, MBDynParser &HP, bool bDof, bool bOrder)
Definition: dataman3.cc:2423
Definition: rotor.h:43
virtual doublereal GetReal(const doublereal &dDefval=0.0)
Definition: parser.cc:1056

Here is the call graph for this function:

Variable Documentation

const char* psGenelNames[]

Definition at line 235 of file enums.cc.