MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
dataman3.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/dataman3.cc,v 1.187 2017/03/02 15:32:36 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 /* Continua il DataManager */
33 
34 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
35 
36 #include <limits>
37 #include <unistd.h>
38 #include <cfloat>
39 
40 #if defined(USE_RUNTIME_LOADING) && defined(HAVE_LTDL_H)
41 #include <ltdl.h>
42 #endif /* USE_RUNTIME_LOADING && HAVE_LTDL_H */
43 
44 #include "dataman.h"
45 #include "dataman_.h"
46 #include "modules.h"
47 #include "readlinsol.h"
48 
49 #include "drive.h"
50 #include "drive_.h"
51 #include "filedrv.h"
52 #include "presnode.h"
53 #include "j2p.h"
54 #include "sah.h"
55 
56 #include "thermalnode.h"
57 
58 #include "aeroelem.h"
59 #include "beam.h"
60 
61 #include "rbk_impl.h"
62 
63 class NotAllowed {};
64 
65 /* Legge i dati di controllo */
66 
67 void
69  const char* sInputFileName)
70 {
71  DEBUGCOUTFNAME("DataManager::ReadControl");
72 
73  /* attach self to parser ... */
74  HP.SetDataManager(this);
75 
76  /* parole chiave del blocco di controllo */
77  const char* sKeyWords[] = {
78  "end",
79  "control" "data",
80 
83  psReadControlNodes[Node::THERMAL],
84  psReadControlNodes[Node::ABSTRACT],
85  psReadControlNodes[Node::PARAMETER],
86  psReadControlNodes[Node::HYDRAULIC],
87 
89  psReadControlElems[Elem::GRAVITY],
90  psReadControlElems[Elem::BODY],
91  psReadControlElems[Elem::JOINT],
92  psReadControlElems[Elem::JOINT_REGULARIZATION],
93  psReadControlElems[Elem::BEAM],
94  psReadControlElems[Elem::PLATE],
95  psReadControlElems[Elem::AIRPROPERTIES],
96  psReadControlElems[Elem::INDUCEDVELOCITY],
97  psReadControlElems[Elem::AEROMODAL],
98  psReadControlElems[Elem::AERODYNAMIC],
99  psReadControlElems[Elem::FORCE],
100  psReadControlElems[Elem::INERTIA],
101  psReadControlElems[Elem::GENEL],
102  psReadControlElems[Elem::ELECTRICBULK],
103  psReadControlElems[Elem::ELECTRIC],
104  psReadControlElems[Elem::THERMAL],
105  psReadControlElems[Elem::HYDRAULIC],
106  psReadControlElems[Elem::BULK],
107  psReadControlElems[Elem::LOADABLE],
108  psReadControlElems[Elem::EXTERNAL],
109  psReadControlElems[Elem::SOCKETSTREAM_OUTPUT],
110  "RTAI" "output", // deprecated
111  "rotors", // deprecated
112 
114 
115  "loadable" "path",
116 
117  "skip" "initial" "joint" "assembly",
118  "use",
119  "in" "assembly",
120  "initial" "stiffness",
121  "stiffness",
122  "omega" "rotates",
123  "initial" "tolerance",
124  "tolerance",
125  "max" "initial" "iterations",
126  "max" "iterations",
127  "epsilon",
128 
129  "solver", /* deprecated */
130  "linear" "solver",
131 
132  "print",
133 
134  "title",
135  "make" "restart" "file",
136  "output" "file" "name",
137  "output" "precision",
138  "output" "frequency", /* deprecated */
139  "output" "meter",
140  "output" "results",
141  "default" "output",
142  "all",
143  "none",
144  "reference" "frames",
145  "accelerations",
146  "drive" "callers",
147 
148  "default" "orientation",
149  "default" "beam" "output",
150  "default" "aerodynamic" "output",
151  "default" "scale",
152 
153  "finite" "difference" "jacobian" "meter",
154 
155  "read" "solution" "array",
156 
157  "select" "timeout",
158  "model",
159 
160  "rigid" "body" "kinematics",
161 
162  0
163  };
164 
165 
166  /* enum delle parole chiave */
167  enum KeyWords {
168  UNKNOWN = -1,
169  END = 0,
170  CONTROLDATA,
171  STRUCTURALNODES,
172  ELECTRICNODES,
173  THERMALNODES,
174  ABSTRACTNODES,
175  PARAMETERNODES,
176  HYDRAULICNODES,
177 
179  GRAVITY,
180  RIGIDBODIES,
181  JOINTS,
182  JOINT_REGULARIZATIONS,
183  BEAMS,
184  PLATES,
186  INDUCEDVELOCITYELEMENTS,
187  AEROMODALS,
188  AERODYNAMICELEMENTS,
189  FORCES,
190  INERTIA,
191  GENELS,
192  ELECTRICBULKELEMENTS,
193  ELECTRICELEMENTS,
194  THERMALELEMENTS,
195  HYDRAULICELEMENTS,
196  BULKELEMENTS,
197  LOADABLEELEMENTS,
198  EXTERNALELEMENTS,
199  SOCKETSTREAMOUTPUTELEMENTS,
200  RTAIOUTPUTELEMENTS, // deprecated
201  ROTORS, // deprecated
202 
203  FILEDRIVERS,
204 
205  LOADABLEPATH,
206 
207  SKIPINITIALJOINTASSEMBLY,
208  USE,
209  INASSEMBLY,
210  INITIALSTIFFNESS,
211  STIFFNESS,
212  OMEGAROTATES,
213  INITIALTOLERANCE,
214  TOLERANCE,
215  MAXINITIALITERATIONS,
216  MAXITERATIONS,
217  EPSILON,
218 
219  SOLVER, /* deprecated */
220  LINEARSOLVER,
221 
222  PRINT,
223 
224  TITLE,
225  MAKERESTARTFILE,
226  OUTPUTFILENAME,
227  OUTPUTPRECISION,
228  OUTPUTFREQUENCY,
229  OUTPUTMETER,
230 
231  OUTPUTRESULTS,
232  DEFAULTOUTPUT,
233  ALL,
234  NONE,
235  REFERENCEFRAMES,
236  ACCELERATIONS,
237  DRIVECALLERS,
238 
239  DEFAULTORIENTATION,
240  DEFAULTBEAMOUTPUT,
241  DEFAULTAERODYNAMICOUTPUT,
242  DEFAULTSCALE,
243 
244  FDJAC_METER,
245 
246  READSOLUTIONARRAY,
247 
248  SELECTTIMEOUT,
249  MODEL,
250  RIGIDBODYKINEMATICS,
251 
253  };
254 
255  /* tabella delle parole chiave */
256  KeyTable K(HP, sKeyWords);
257 
258  KeyWords CurrDesc;
259  while ((CurrDesc = KeyWords(HP.GetDescription())) != END) {
260  switch (CurrDesc) {
261 
262  /******** Nodes *********/
263 
264  /* Numero di nodi strutturali attesi */
265  case STRUCTURALNODES: {
268  DofData[DofOwner::STRUCTURALNODE].iNum = iDmy;
269  DEBUGLCOUT(MYDEBUG_INPUT, "Structural nodes: " << iDmy << std::endl);
270  } break;
271 
272  /* Numero di nodi elettrici attesi */
273  case ELECTRICNODES: {
276  DofData[DofOwner::ELECTRICNODE].iNum = iDmy;
277  DEBUGLCOUT(MYDEBUG_INPUT, "Electric nodes: " << iDmy << std::endl);
278  } break;
279 
280  /* Numero di nodi termici attesi */
281  case THERMALNODES: {
284  DofData[DofOwner::THERMALNODE].iNum = iDmy;
285  DEBUGLCOUT(MYDEBUG_INPUT, "Thermal nodes: " << iDmy << std::endl);
286  } break;
287 
288  /* Numero di nodi astratti attesi */
289  case ABSTRACTNODES: {
292  DofData[DofOwner::ABSTRACTNODE].iNum = iDmy;
293  DEBUGLCOUT(MYDEBUG_INPUT, "Abstract nodes: " << iDmy << std::endl);
294  } break;
295 
296  /* Numero di nodi astratti attesi */
297  case PARAMETERNODES: {
300  DEBUGLCOUT(MYDEBUG_INPUT, "Parameter nodes: " << iDmy << std::endl);
301  } break;
302 
303  /* Numero di nodi idraulici attesi */
304  case HYDRAULICNODES: {
307  DofData[DofOwner::HYDRAULICNODE].iNum = iDmy;
308  DEBUGLCOUT(MYDEBUG_INPUT, "Hydraulic nodes: " << iDmy << std::endl);
309  } break;
310 
311  /******** Elements *********/
312 
313  /* Numero di corpi rigidi attesi */
314  case AUTOMATICSTRUCTURAL: {
315 #ifdef DEBUG
316  int iDmy =
317 #endif // DEBUG
318  HP.GetInt();
319 #ifdef DEBUG
320 #if 0
322 #endif // 0
323  DEBUGLCOUT(MYDEBUG_INPUT, "Automatic structural elements expected: "
324  << iDmy << std::endl);
325 #endif
326  } break;
327 
328  /* Accelerazione di gravita' */
329  case GRAVITY: {
330  if (ElemData[Elem::GRAVITY].iExpectedNum > 0) {
331  silent_cerr("warning: gravity acceleration already defined;" << std::endl
332  << "only one definition will be considered" << std::endl);
333  }
335  DEBUGLCOUT(MYDEBUG_INPUT, "Gravity acceleration expected in elements data" << std::endl);
336  } break;
337 
338  /* Numero di corpi rigidi attesi */
339  case RIGIDBODIES: {
342  DEBUGLCOUT(MYDEBUG_INPUT, "Rigid bodies: " << iDmy << std::endl);
343  } break;
344 
345  /* Numero di inerzie attese */
346  case INERTIA: {
349  DEBUGLCOUT(MYDEBUG_INPUT, "Inertia: " << iDmy << std::endl);
350  } break;
351 
352  /* Numero di vincoli attesi */
353  case JOINTS: {
356  DofData[DofOwner::JOINT].iNum = iDmy;
357  DEBUGLCOUT(MYDEBUG_INPUT, "Joints: " << iDmy << std::endl);
358  if (iDmy > 0 ) {
360  }
361  } break;
362 
363  /* Numero di regolarizzazion vincoli attesi */
364  case JOINT_REGULARIZATIONS: {
367  DEBUGLCOUT(MYDEBUG_INPUT, "Joint regularizations: " << iDmy << std::endl);
368  if (iDmy > 0 ) {
370  }
371  } break;
372 
373  /* Numero di travi attese */
374  case BEAMS: {
377  DEBUGLCOUT(MYDEBUG_INPUT, "Beams: " << iDmy << std::endl);
378  if (iDmy > 0 ) {
380  }
381  } break;
382 
383  /* Numero di piastre attese */
384  case PLATES: {
387  DofData[DofOwner::PLATE].iNum = iDmy;
388  DEBUGLCOUT(MYDEBUG_INPUT, "Plates: " << iDmy << std::endl);
389  if (iDmy > 0 ) {
391  }
392  } break;
393 
394  /* Elementi aerodinamici: proprieta' dell'aria */
395  case AIRPROPERTIES: {
396  if (ElemData[Elem::AIRPROPERTIES].iExpectedNum > 0) {
397  silent_cerr("warning: air properties already defined;" << std::endl
398  << "only one definition will be considered" << std::endl);
399  }
401  DEBUGLCOUT(MYDEBUG_INPUT, "Air properties expected in elements data" << std::endl);
402  } break;
403 
404  /* Elementi aerodinamici: rotori */
405  case ROTORS:
406  silent_cerr("deprecated \"rotors\", use \"induced velocity elements\" instead at line " << HP.GetLineData() << std::endl);
407  // fallthru
408  case INDUCEDVELOCITYELEMENTS: {
411  DofData[DofOwner::INDUCEDVELOCITY].iNum = iDmy;
412  DEBUGLCOUT(MYDEBUG_INPUT, "Rotors: " << iDmy << std::endl);
413  } break;
414 
415  case AEROMODALS: {
418  DofData[DofOwner::AEROMODAL].iNum = iDmy;
419  DEBUGLCOUT(MYDEBUG_INPUT, "Aeromodals: " << iDmy << std::endl);
420  } break;
421 
422  /* Elementi aerodinamici: vari elementi aerodinamici senza dof */
423  case AERODYNAMICELEMENTS: {
426  DofData[DofOwner::AERODYNAMIC].iNum = iDmy;
427  DEBUGLCOUT(MYDEBUG_INPUT, "Aerodynamic Elements: " << iDmy << std::endl);
428  } break;
429 
430  /* Numero di forze e coppie attese */
431  case FORCES: {
434  DEBUGLCOUT(MYDEBUG_INPUT, "Forces: " << iDmy << std::endl);
435  } break;
436 
437  /* Numero di vincoli attesi */
438  case GENELS: {
441  DofData[DofOwner::GENEL].iNum = iDmy;
442  DEBUGLCOUT(MYDEBUG_INPUT, "Genels: " << iDmy << std::endl);
443  } break;
444 
445  /* Numero di elementi elettrici attesi */
446  case ELECTRICELEMENTS: {
449  DofData[DofOwner::ELECTRIC].iNum = iDmy;
450  DEBUGLCOUT(MYDEBUG_INPUT, "Electric elements: " << iDmy << std::endl);
451  } break;
452 
453  /* Numero di elementi termici attesi */
454  case THERMALELEMENTS: {
457  DofData[DofOwner::THERMAL].iNum = iDmy;
458  DEBUGLCOUT(MYDEBUG_INPUT, "Thermal elements: " << iDmy << std::endl);
459  } break;
460 
461  /* Numero di elementi idraulici attesi */
462  case HYDRAULICELEMENTS: {
465  DofData[DofOwner::HYDRAULIC].iNum = iDmy;
466  DEBUGLCOUT(MYDEBUG_INPUT, "Hydraulic elements: " << iDmy << std::endl);
467  } break;
468 
469  /* Numero di elementi elettrici attesi */
470  case BULKELEMENTS: {
473  DEBUGLCOUT(MYDEBUG_INPUT, "Bulk elements: " << iDmy << std::endl);
474  } break;
475 
476  /* Numero di elementi caricabili attesi */
477  case LOADABLEELEMENTS: {
480  DofData[DofOwner::LOADABLE].iNum = iDmy;
481  DEBUGLCOUT(MYDEBUG_INPUT, "Loadable elements: " << iDmy << std::endl);
482  } break;
483 
484  case LOADABLEPATH: {
485 #if defined(USE_RUNTIME_LOADING)
486  bool add(false);
487 
488  if (!moduleInitialized) {
490  moduleInitialized = true;
491  }
492 
493  if (HP.IsKeyWord("set")) {
494  add = false;
495  } else if (HP.IsKeyWord("add")) {
496  add = true;
497  }
498 
499  const char *s = HP.GetFileName();
500  if (s == NULL) {
501  silent_cerr("missing path "
502  "in \"loadable path\" statement "
503  "at line " << HP.GetLineData()
504  << std::endl);
506  }
507 
508  if (add) {
509  if (lt_dladdsearchdir(s) != 0) {
510  silent_cerr("unable to add path "
511  "\"" << s << "\" "
512  "in \"loadable path\" "
513  "statement at line "
514  << HP.GetLineData()
515  << std::endl);
517  }
518  } else {
519  if (lt_dlsetsearchpath(s) != 0) {
520  silent_cerr("unable to set path "
521  "\"" << s << "\" "
522  "in \"loadable path\" "
523  "statement at line "
524  << HP.GetLineData()
525  << std::endl);
527  }
528  }
529 
530 #else // ! USE_RUNTIME_LOADING
531  silent_cerr("loadable path allowed "
532  "only in presence of libltdl (ignored)"
533  << std::endl);
534  (void)HP.GetStringWithDelims();
535 #endif // ! USE_RUNTIME_LOADING
536  } break;
537 
538  case EXTERNALELEMENTS: {
539 #ifdef USE_EXTERNAL
542  DEBUGLCOUT(MYDEBUG_INPUT, "External elements: " << iDmy
543  << std::endl);
544 #else /* USE_EXTERNAL */
545  silent_cerr("cannot use external elements "
546  "when not compiled with -DUSE_EXTERNAL"
547  << std::endl);
548 #endif /* USE_EXTERNAL */
549  } break;
550 
551  case SOCKETSTREAMOUTPUTELEMENTS:
552  case RTAIOUTPUTELEMENTS: {
555  DEBUGLCOUT(MYDEBUG_INPUT, "RTAI output elements: " << iDmy
556  << std::endl);
557 #ifndef USE_RTAI
558  if (CurrDesc == RTAIOUTPUTELEMENTS) {
559  silent_cerr("cannot use "
560  "RTAI output elements "
561  "when not configured "
562  "--with-rtai; "
563  "using \"socket stream output\" "
564  "instead"
565  << std::endl);
566  }
567 #endif /* ! USE_RTAI */
568  } break;
569 
570  /* Numero di drivers attesi */
571  case FILEDRIVERS: {
573  DriveData[Drive::FILEDRIVE].iNum = iDmy;
574  DEBUGLCOUT(MYDEBUG_INPUT, "File drivers: " << iDmy << std::endl);
575  } break;
576 
577  /********* Miscellaneous *********/
578 
579  /* Spegne il flag di assemblaggio iniziale;
580  * di default viene eseguito solo se sono definiti vincoli */
581  case SKIPINITIALJOINTASSEMBLY: {
583  DEBUGLCOUT(MYDEBUG_INPUT, "Skipping initial joint assembly" << std::endl);
584  } break;
585 
586  /* Uso di diversi tipi di elementi nell'assemblaggio iniziale */
587  case USE:
588  while (true) {
589  switch (KeyWords(HP.GetWord())) {
590  /* Esce dal ciclo */
591  case INASSEMBLY:
592  goto EndOfUse;
593 
594  case RIGIDBODIES:
597  "Rigid bodies will be used "
598  "in initial joint assembly"
599  << std::endl);
600  break;
601 
602  case GRAVITY:
605  "Gravity will be used "
606  "in initial joint assembly"
607  << std::endl);
608  break;
609 
610  case FORCES:
613  "Forces will be used "
614  "in initial joint assembly"
615  << std::endl);
616  break;
617 
618  /* Lo lascio per backwards compatibility */
619  case BEAMS:
620 #if 0
622 #endif /* 0 */
624  "Beams are used by default "
625  "in initial joint assembly"
626  << std::endl);
627  break;
628 
629  case PLATES:
632  "Plates will be used "
633  "in initial joint assembly"
634  << std::endl);
635  break;
636 
637  case AERODYNAMICELEMENTS:
640  "Aerodynamic Elements will be used "
641  "in initial joint assembly"
642  << std::endl);
643 
644  if (!ElemData[Elem::AIRPROPERTIES].bToBeUsedInAssembly()) {
646  }
647 
648  break;
649 
650  case LOADABLEELEMENTS:
653  "Loadable Elements will be used "
654  "in initial joint assembly"
655  << std::endl);
656  break;
657 
658  /* Elemento non autorizzato */
659  default:
660  silent_cerr("Element type at line "
661  << HP.GetLineData()
662  << " is not allowed; aborting..."
663  << std::endl);
664 
666 
667  /* Errore */
668  case UNKNOWN:
669  silent_cerr("Unknown element type "
670  "at line " << HP.GetLineData() << "; "
671  "aborting..." << std::endl);
672 
674  }
675  }
676 
677 EndOfUse:
678  break;
679 
680  /* Rigidezza delle molle fittizie usate
681  * nell'assemblaggio iniziale;
682  * se viene fornito un solo valore, viene usato sia per posizione
683  * che per velocita';
684  * se ne vengono forniti due, il primo vale per la posizione ed
685  * il secondo per la velocita'
686  */
687  case INITIALSTIFFNESS:
688  pedantic_cout("\"initial stiffness\" deprecated at line "
689  << HP.GetLineData() << "; use \"stiffness\""
690  << std::endl);
691 
692  case STIFFNESS:
695 
696  if (HP.IsArg()) {
699  } else {
702  }
703 
704  DEBUGLCOUT(MYDEBUG_INPUT, "Initial position stiffness: "
705  << dInitialPositionStiffness << std::endl
706  << "Initial velocity stiffness: "
707  << dInitialVelocityStiffness << std::endl);
708 
709  break;
710 
711  /* Omega solidale con il nodo o con il rif. globale */
712  case OMEGAROTATES:
713  if (!HP.GetYesNo(bOmegaRotates)) {
714  silent_cerr("Invalid option at line "
715  << HP.GetLineData() << std::endl);
717  }
718 
719  break;
720 
721  /* Tolleranza nell'assemblaggio iniziale; viene calcolata come:
722  * sqrt(sum(res^2)/(1.+sum(sol^2)) */
723  case INITIALTOLERANCE:
724  pedantic_cout("\"initial tolerance\" deprecated at line "
725  << HP.GetLineData() << "; use \"tolerance\""
726  << std::endl);
727 
728  case TOLERANCE:
731  DEBUGLCOUT(MYDEBUG_INPUT, "Initial assembly tolerance: "
732  << dInitialAssemblyTol << std::endl);
733  break;
734 
735  /* Numero massimo di iterazioni nell'assemblaggio iniziale;
736  * di default ne e' consentita solo una, indice di condizioni
737  * iniziali corrette */
738  case MAXINITIALITERATIONS:
739  pedantic_cout("\"max initial iterations\" deprecated at line "
740  << HP.GetLineData() << "; use \"max iterations\""
741  << std::endl);
742  case MAXITERATIONS:
745  DEBUGLCOUT(MYDEBUG_INPUT, "Max initial iterations: "
746  << iMaxInitialIterations << std::endl);
747  break;
748 
749  case EPSILON:
750  dEpsilon = HP.GetReal();
751  if (dEpsilon <= 0.) {
752  silent_cerr("illegal \"epsilon\"=" << dEpsilon
753  << " at line " << HP.GetLineData()
754  << std::endl);
756  }
757  break;
758 
759  case PRINT:
760  while (HP.IsArg()) {
761  if (HP.IsKeyWord("dof" "stats")) {
763 
764  } else if (HP.IsKeyWord("dof" "description")) {
766 
767  } else if (HP.IsKeyWord("equation" "description")) {
769 
770  } else if (HP.IsKeyWord("description")) {
772 
773  } else if (HP.IsKeyWord("element" "connection")) {
775 
776  } else if (HP.IsKeyWord("node" "connection")) {
778 
779  } else if (HP.IsKeyWord("connection")) {
781 
782  } else if (HP.IsKeyWord("all")) {
784 
785  } else if (HP.IsKeyWord("none")) {
787 
788  } else if (HP.IsKeyWord("to" "file")) {
790 
791  } else {
792  silent_cerr("unknown print flag at line "
793  << HP.GetLineData() << std::endl);
795  }
796  }
797  break;
798 
799  case SOLVER:
800  silent_cerr("\"solver\" keyword at line "
801  << HP.GetLineData() << " is deprecated; "
802  "use \"linear solver\" instead" << std::endl);
803  case LINEARSOLVER:
804  ReadLinSol(CurrSolver, HP);
805  break;
806 
807  /* Titolo */
808  case TITLE: {
809  ASSERT(sSimulationTitle == NULL);
810  if (sSimulationTitle != NULL) {
812  }
813  const char* sTmp(HP.GetStringWithDelims());
815  DEBUGLCOUT(MYDEBUG_INPUT, "Simulation title: "
816  "\"" << sSimulationTitle << '"' << std::endl);
817  } break;
818 
819  /* Crea il file di restart */
820  case MAKERESTARTFILE:
821  DEBUGLCOUT(MYDEBUG_INPUT, "Restart file will be generated " << std::endl);
822  if (HP.IsArg()) {
823  if (HP.IsKeyWord("iterations")) {
827  "every " << iRestartIterations
828  << " iterations" << std::endl);
829  } else if (HP.IsKeyWord("time")) {
830  RestartEvery = TIME;
831  dRestartTime = HP.GetReal();
833  "every " << dRestartTime
834  << " time units" << std::endl);
835  } else if (HP.IsKeyWord("times")) {
838  if (iNumRestartTimes < 1) {
839  silent_cerr("illegal number of restart times "
840  << iNumRestartTimes << std::endl);
842  }
844  for (integer i = 0; i < iNumRestartTimes; i++) {
845  pdRestartTimes[i] = HP.GetReal();
847  " at time "
848  << pdRestartTimes[0]
849  << std::endl);
850  }
851  } else {
852  silent_cerr("Error: unrecognized restart option at line "
853  << HP.GetLineData() << std::endl);
854 
856  }
857  } else {
859  }
860 
861  if (HP.IsKeyWord("with" "solution" "array")) {
862  saveXSol = true;
863  }
864  break;
865 
866  case OUTPUTFILENAME:
867  silent_cerr("\"output file name\" no longer supported at line "
868  << HP.GetLineData() << std::endl);
870 
871  case OUTPUTPRECISION: {
872  int iPrec = HP.GetInt();
873  OutHdl.SetPrecision(iPrec);
874  } break;
875 
876  case OUTPUTFREQUENCY: {
877  if (pOutputMeter != 0) {
878  silent_cerr("Output meter/frequency already defined" << std::endl);
879  throw DataManager::ErrGeneric(MBDYN_EXCEPT_ARGS);
880  }
881  integer iFreq = HP.GetInt();
882  if (iFreq < 1) {
883  silent_cerr("Illegal output frequency " << iFreq
884  << " at line " << HP.GetLineData() << std::endl);
885  throw DataManager::ErrGeneric(MBDYN_EXCEPT_ARGS);
886  }
890  -std::numeric_limits<double>::max(),
891  std::numeric_limits<double>::max(),
892  iFreq)
893  );
894  } break;
895 
896  case OUTPUTMETER:
897  if (pOutputMeter != 0) {
898  silent_cerr("Output meter/frequency already defined" << std::endl);
899  throw DataManager::ErrGeneric(MBDYN_EXCEPT_ARGS);
900  }
901  pOutputMeter = HP.GetDriveCaller(false);
902  break;
903 
904  case OUTPUTRESULTS:
905  while (HP.IsArg()) {
906  /* require support for ADAMS/View .res output */
907  if (HP.IsKeyWord("adams")) {
908 #if defined USE_ADAMS
909  ResMode |= RES_ADAMS;
910 
911  if (HP.IsArg()) {
912  if (HP.IsKeyWord("model" "name")) {
913  if (sAdamsModelName != 0) {
914  pedantic_cerr("line " << HP.GetLineData()
915  << ": ADAMS output model name "
916  "already defined; replacing..."
917  << std::endl);
918  SAFEDELETEARR(sAdamsModelName);
919  sAdamsModelName = 0;
920  }
921 
922  const char *tmp = HP.GetStringWithDelims();
923  SAFESTRDUP(sAdamsModelName, tmp);
924  }
925 
926  /* default; conservative: output is very verbose */
927  if (HP.IsKeyWord("velocity")) {
928  if (!HP.GetYesNo(bAdamsVelocity)) {
929  silent_cerr("unknown value "
930  "for \"velocity\" flag at line "
931  << HP.GetLineData() << std::endl);
932  throw DataManager::ErrGeneric(MBDYN_EXCEPT_ARGS);
933  }
934  }
935 
936  if (HP.IsKeyWord("acceleration")) {
937  if (!HP.GetYesNo(bAdamsAcceleration)) {
938  silent_cerr("unknown value "
939  "for \"acceleration\" flag at line "
940  << HP.GetLineData() << std::endl);
941  throw DataManager::ErrGeneric(MBDYN_EXCEPT_ARGS);
942  }
943  }
944  }
945 
946  if (sAdamsModelName == 0) {
947  SAFESTRDUP(sAdamsModelName, "mbdyn");
948  }
949 #else /* !USE_ADAMS */
950  silent_cerr("Please rebuild with ADAMS output enabled"
951  << std::endl);
952  throw DataManager::ErrGeneric(MBDYN_EXCEPT_ARGS);
953 #endif /* USE_ADAMS */
954  /* require support for MotionView output */
955  } else if (HP.IsKeyWord("motion" "view")) {
956 #if defined USE_MOTIONVIEW
957  ResMode |= RES_MOTIONVIEW;
958 
959  /*
960  * add output info
961  */
962 #else /* !USE_MOTIONVIEW */
963  silent_cerr("Please rebuild with MotionView output enabled"
964  << std::endl);
965  throw DataManager::ErrGeneric(MBDYN_EXCEPT_ARGS);
966 #endif /* USE_MOTIONVIEW */
967 
968  } else if (HP.IsKeyWord("netcdf")) {
969  ResMode |= RES_NETCDF;
970  if (HP.IsKeyWord("sync")) {
971 #ifdef USE_NETCDF
972  bNetCDFsync = true;
973 #endif // USE_NETCDF
974  }
975  if (HP.IsKeyWord("no" "text")) {
976 #ifdef USE_NETCDF
977  bNetCDFnoText = true;
978 #endif // USE_NETCDF
979  }
980 #ifndef USE_NETCDF
981  silent_cerr("\"netcdf\" ignored; please rebuild with NetCDF output enabled"
982  << std::endl);
983 #endif /* ! USE_NETCDF */
984 
985  } else {
986  silent_cerr("unknown \"output results\" "
987  "mode at line " << HP.GetLineData()
988  << std::endl);
989  throw DataManager::ErrGeneric(MBDYN_EXCEPT_ARGS);
990  }
991  }
992  break;
993 
994  case DEFAULTOUTPUT:
995  while (HP.IsArg()) {
996  KeyWords CurrDefOut(KeyWords(HP.GetWord()));
997  switch (CurrDefOut) {
998  case ALL:
999  for (int iCnt = 0; iCnt < Elem::LASTELEMTYPE; iCnt++) {
1000  ElemData[iCnt].DefaultOut(true);
1001  }
1002  for (int iCnt = 0; iCnt < Node::LASTNODETYPE; iCnt++) {
1003  NodeData[iCnt].DefaultOut(true);
1004  }
1005  break;
1006 
1007  case NONE:
1008  for (int iCnt = 0; iCnt < Elem::LASTELEMTYPE; iCnt++) {
1009  ElemData[iCnt].DefaultOut(false);
1010  }
1011  for (int iCnt = 0; iCnt < Node::LASTNODETYPE; iCnt++) {
1012  NodeData[iCnt].DefaultOut(false);
1013  }
1014  break;
1015 
1016  case REFERENCEFRAMES:
1017  bOutputFrames = true;
1018  break;
1019 
1020  case ACCELERATIONS:
1021  bOutputAccels = true;
1022  break;
1023 
1024  case DRIVECALLERS:
1025  bOutputDriveCaller = true;
1026  break;
1027 
1028  case STRUCTURALNODES:
1030  break;
1031 
1032  case ELECTRICNODES:
1034  break;
1035 
1036  case THERMALNODES:
1038  break;
1039 
1040  case ABSTRACTNODES:
1042  break;
1043 
1044  case HYDRAULICNODES:
1046  break;
1047 
1048  case GRAVITY:
1050  break;
1051 
1052  case RIGIDBODIES:
1054  break;
1055 
1056  case JOINTS:
1058  break;
1059 
1060  case BEAMS:
1062  break;
1063 
1064  case PLATES:
1066  break;
1067 
1068  case AIRPROPERTIES:
1070  break;
1071 
1072  case ROTORS:
1073  case INDUCEDVELOCITYELEMENTS:
1075  break;
1076 
1077  case AEROMODALS:
1079  break;
1080 
1081  case AERODYNAMICELEMENTS:
1083  break;
1084 
1085  case FORCES:
1087  break;
1088 
1089  case GENELS:
1091  break;
1092 
1093  case ELECTRICBULKELEMENTS:
1095  break;
1096 
1097  case ELECTRICELEMENTS:
1099  break;
1100 
1101  case THERMALELEMENTS:
1103  break;
1104 
1105  case HYDRAULICELEMENTS:
1107  break;
1108  case LOADABLEELEMENTS:
1110  break;
1111 #ifdef USE_EXTERNAL
1112  case EXTERNALELEMENTS:
1114  break;
1115 #endif /* USE_EXTERNAL */
1116 
1117  case UNKNOWN:
1118  silent_cerr("warning: unknown output case at line "
1119  << HP.GetLineData() << std::endl);
1120  ASSERT(0);
1121  break;
1122 
1123  default:
1124  silent_cerr("case " << sKeyWords[CurrDesc] << " at line "
1125  << HP.GetLineData() << " is not allowed" << std::endl);
1126  ASSERT(0);
1127  break;
1128  }
1129  }
1130  break;
1131 
1132  case DEFAULTORIENTATION:
1134  break;
1135 
1136  case DEFAULTBEAMOUTPUT:
1137  ReadBeamCustomOutput(this, HP, unsigned(-1), Beam::VISCOELASTIC,
1138  ElemData[Elem::BEAM].uOutputFlags, ElemData[Elem::BEAM].od);
1139  break;
1140 
1141  case DEFAULTAERODYNAMICOUTPUT:
1142  ReadAerodynamicCustomOutput(this, HP, unsigned(-1),
1144  break;
1145 
1146  case DEFAULTSCALE:
1147  while (HP.IsArg()) {
1148  KeyWords CurrDefOut(KeyWords(HP.GetWord()));
1149  doublereal dScale = HP.GetReal(1.);
1150 
1151  switch (CurrDefOut) {
1152  case ALL:
1153  for (int iCnt = 0; iCnt < DofOwner::LASTDOFTYPE; iCnt++) {
1154  DofData[iCnt].dDefScale= dScale;
1155  }
1156  break;
1157 
1158  case STRUCTURALNODES:
1159  DofData[DofOwner::STRUCTURALNODE].dDefScale = dScale;
1160  break;
1161 
1162  case ELECTRICNODES:
1163  DofData[DofOwner::ELECTRICNODE].dDefScale = dScale;
1164  break;
1165 
1166  case THERMALNODES:
1167  DofData[DofOwner::THERMALNODE].dDefScale = dScale;
1168  break;
1169 
1170  case ABSTRACTNODES:
1171  DofData[DofOwner::ABSTRACTNODE].dDefScale = dScale;
1172  break;
1173 
1174  case HYDRAULICNODES:
1175  DofData[DofOwner::HYDRAULICNODE].dDefScale = dScale;
1176  break;
1177 
1178  case JOINTS:
1179  DofData[DofOwner::JOINT].dDefScale = dScale;
1180  break;
1181 
1182  case ROTORS:
1183  case INDUCEDVELOCITYELEMENTS:
1184  DofData[DofOwner::INDUCEDVELOCITY].dDefScale = dScale;
1185  break;
1186 
1187  case AEROMODALS:
1188  DofData[DofOwner::AEROMODAL].dDefScale = dScale;
1189  break;
1190 
1191  case GENELS:
1192  DofData[DofOwner::GENEL].dDefScale = dScale;
1193  break;
1194 
1195  case ELECTRICBULKELEMENTS:
1196  DofData[DofOwner::ELECTRICBULK].dDefScale = dScale;
1197  break;
1198 
1199  case ELECTRICELEMENTS:
1200  DofData[DofOwner::ELECTRIC].dDefScale = dScale;
1201  break;
1202 
1203  case THERMALELEMENTS:
1204  DofData[DofOwner::THERMAL].dDefScale = dScale;
1205  break;
1206 
1207  case HYDRAULICELEMENTS:
1208  DofData[DofOwner::HYDRAULIC].dDefScale = dScale;
1209  break;
1210 
1211  case LOADABLEELEMENTS:
1212  DofData[DofOwner::LOADABLE].dDefScale = dScale;
1213  break;
1214 
1215  case UNKNOWN:
1216  silent_cerr("warning: unknown output case at line "
1217  << HP.GetLineData() << std::endl);
1218  ASSERT(0);
1219  break;
1220 
1221  default:
1222  silent_cerr("case " << sKeyWords[CurrDesc] << " at line "
1223  << HP.GetLineData() << " is not allowed" << std::endl);
1224  ASSERT(0);
1225  break;
1226  }
1227  }
1228  break;
1229 
1230  case FDJAC_METER: {
1231 #ifdef MBDYN_FDJAC
1232  if (pFDJacMeter != 0) {
1233  silent_cerr("\"finite difference jacobian meter\" already defined" << std::endl);
1234  throw DataManager::ErrGeneric(MBDYN_EXCEPT_ARGS);
1235  }
1236 #endif // MBDYN_FDJAC
1237  DriveCaller *pTmp = HP.GetDriveCaller(false);
1238 #ifdef MBDYN_FDJAC
1239  pFDJacMeter = pTmp;
1240 #else // !MBDYN_FDJAC
1241  silent_cerr("warning, \"finite difference jacobian meter\" not supported (ignored)" << std::endl);
1242  SAFEDELETE(pTmp);
1243 #endif // !MBDYN_FDJAC
1244  } break;
1245 
1246  case READSOLUTIONARRAY:{
1247  int len = strlen(sInputFileName) + sizeof(".X");
1248  SAFENEWARR(solArrFileName, char, len);
1249  snprintf(solArrFileName, len, "%s.X", sInputFileName);
1250  } break;
1251 
1252  case SELECTTIMEOUT:
1253 #ifdef USE_SOCKET
1254  if (HP.IsKeyWord("forever")) {
1255  SocketUsersTimeout = 0;
1256 
1257  } else {
1258  int timeout = HP.GetInt();
1259  if (timeout <= 0) {
1260  silent_cerr("warning: illegal select timeout " << timeout
1261  << " (ignored) at line " << HP.GetLineData()
1262  << std::endl);
1263  } else {
1264  SocketUsersTimeout = 60*timeout;
1265  }
1266  }
1267 #else // ! USE_SOCKET
1268  silent_cerr("warning: \"select timeout\" not allowed (ignored) "
1269  "at line " << HP.GetLineData()
1270  << " because the current architecture "
1271  "apparently does not support sockets"
1272  << std::endl);
1273 #endif // ! USE_SOCKET
1274  break;
1275 
1276  case MODEL:
1277  if (HP.IsKeyWord("static")) {
1278  bStaticModel = true;
1279  }
1280  break;
1281 
1282  case RIGIDBODYKINEMATICS: {
1283  if (HP.IsKeyWord("const")) {
1284  Vec3 X(Zero3);
1285  Mat3x3 R(Eye3);
1286  Vec3 V(Zero3);
1287  Vec3 W(Zero3);
1288  Vec3 XPP(Zero3);
1289  Vec3 WP(Zero3);
1290 
1291  bool bGot(false);
1292 
1293  if (HP.IsKeyWord("position")) {
1294  X = HP.GetPosAbs(::AbsRefFrame);
1295  if (!X.IsNull()) {
1296  bGot = true;
1297  }
1298  }
1299 
1300  if (HP.IsKeyWord("orientation")) {
1301  R = HP.GetRotAbs(::AbsRefFrame);
1302  if (!R.IsExactlySame(Eye3)) {
1303  bGot = true;
1304  }
1305  }
1306 
1307  if (HP.IsKeyWord("velocity")) {
1308  V = HP.GetVecAbs(::AbsRefFrame);
1309  if (!V.IsNull()) {
1310  bGot = true;
1311  }
1312  }
1313 
1314  if (HP.IsKeyWord("angular" "velocity")) {
1315  W = HP.GetVecAbs(::AbsRefFrame);
1316  if (!W.IsNull()) {
1317  bGot = true;
1318  }
1319  }
1320 
1321  if (HP.IsKeyWord("acceleration")) {
1322  XPP = HP.GetVecAbs(::AbsRefFrame);
1323  if (!XPP.IsNull()) {
1324  bGot = true;
1325  }
1326  }
1327 
1328  if (HP.IsKeyWord("angular" "acceleration")) {
1329  WP = HP.GetVecAbs(::AbsRefFrame);
1330  if (!WP.IsNull()) {
1331  bGot = true;
1332  }
1333  }
1334 
1335  if (!bGot) {
1336  silent_cerr("null rigid body kinematics "
1337  "at line " << HP.GetLineData()
1338  << std::endl);
1339  break;
1340  }
1341 
1344  ConstRigidBodyKinematics(X, R, V, W, XPP, WP));
1345 
1346  } else if (HP.IsKeyWord("drive")) {
1347  TplDriveCaller<Vec3> *pXDrv(0);
1348  TplDriveCaller<Vec3> *pThetaDrv(0);
1349  TplDriveCaller<Vec3> *pVDrv(0);
1350  TplDriveCaller<Vec3> *pWDrv(0);
1351  TplDriveCaller<Vec3> *pXPPDrv(0);
1352  TplDriveCaller<Vec3> *pWPDrv(0);
1353 
1354  bool bGot(false);
1355 
1356  if (HP.IsKeyWord("position")) {
1357  pXDrv = ReadDCVecRel(this, HP, ::AbsRefFrame);
1358  bGot = true;
1359  }
1360 
1361  if (HP.IsKeyWord("orientation")) {
1362  pThetaDrv = ReadDCVecRel(this, HP, ::AbsRefFrame);
1363  bGot = true;
1364  }
1365 
1366  if (HP.IsKeyWord("velocity")) {
1367  pVDrv = ReadDCVecRel(this, HP, ::AbsRefFrame);
1368  bGot = true;
1369  }
1370 
1371  if (HP.IsKeyWord("angular" "velocity")) {
1372  pWDrv = ReadDCVecRel(this, HP, ::AbsRefFrame);
1373  bGot = true;
1374  }
1375 
1376  if (HP.IsKeyWord("acceleration")) {
1377  pXPPDrv = ReadDC3D(this, HP);
1378  bGot = true;
1379  }
1380 
1381  if (HP.IsKeyWord("angular" "acceleration")) {
1382  pWPDrv = ReadDC3D(this, HP);
1383  bGot = true;
1384  }
1385 
1386  if (!bGot) {
1387  silent_cerr("null rigid body kinematics "
1388  "at line " << HP.GetLineData()
1389  << std::endl);
1390  break;
1391  }
1392 
1396  pThetaDrv, pVDrv, pWDrv,
1397  pXPPDrv, pWPDrv));
1398 
1399  } else {
1400  silent_cerr("unknown rigid body kinematics "
1401  "at line " << HP.GetLineData()
1402  << std::endl);
1403  throw DataManager::ErrGeneric(MBDYN_EXCEPT_ARGS);
1404  }
1405 
1406  if (HP.IsArg()) {
1407  silent_cerr("Semicolon expected at line "
1408  << HP.GetLineData() << std::endl);
1409  throw DataManager::ErrGeneric(MBDYN_EXCEPT_ARGS);
1410  }
1411  } break;
1412 
1413  case UNKNOWN:
1414  /*
1415  * If description is not in key table the parser
1416  * returns UNKNONW, so "default" can be used to
1417  * intercept control cases that are not allowed.
1418  */
1419  DEBUGCERR("");
1420  silent_cerr("unknown description at line "
1421  << HP.GetLineData() << std::endl);
1422  throw DataManager::ErrGeneric(MBDYN_EXCEPT_ARGS);
1423  ASSERT(0);
1424  break;
1425 
1426  default:
1427  silent_cerr("case " << sKeyWords[CurrDesc] << " at line "
1428  << HP.GetLineData() << " is not allowed" << std::endl);
1429  throw DataManager::ErrGeneric(MBDYN_EXCEPT_ARGS);
1430  }
1431  }
1432 
1433  if (KeyWords(HP.GetWord()) != CONTROLDATA) {
1434  DEBUGCERR("");
1435  silent_cerr("\"end: control data;\" expected at line "
1436  << HP.GetLineData() << std::endl);
1438  }
1439 
1440  /* Se non c'e' il punto e virgola finale */
1441  if (HP.IsArg()) {
1442  DEBUGCERR("");
1443  silent_cerr("semicolon expected at line "
1444  << HP.GetLineData() << std::endl);
1446  }
1447 
1448 #ifdef USE_NETCDF
1449  /* FIXME: from now on, NetCDF is enabled */
1450  if (bNetCDFnoText) {
1451  // enables or disables text output
1452  OutHdl.ClearText();
1453  }
1454 #endif // USE_NETCDF
1455 
1456  if (bOutput(RES_NETCDF)) {
1465  // OutHdl.SetNetCDF(OutputHandler::PLATES);
1466  }
1467 
1468  integer iOutputFrequency = 0;
1469  if (pOutputMeter == 0) {
1471  iOutputFrequency = 1;
1472 
1473  } else {
1474  MeterDriveCaller *pMDC = dynamic_cast<MeterDriveCaller *>(pOutputMeter);
1475  if (pMDC != 0) {
1476  iOutputFrequency = pMDC->iGetSteps();
1477  }
1478  }
1479 
1480  if (iOutputFrequency == 0) {
1481  OutHdl.Log() << "output frequency: custom" << std::endl;
1482 
1483  } else {
1484  OutHdl.Log() << "output frequency: " << iOutputFrequency << std::endl;
1485  }
1486 
1487  DEBUGLCOUT(MYDEBUG_INPUT, "End of control data" << std::endl);
1488 } /* End of DataManager::ReadControl() */
1489 
1490 doublereal
1492 {
1494 
1495  if (!HP.IsKeyWord("scale")) {
1496  return d;
1497  }
1498 
1499  if (!HP.IsKeyWord("default")) {
1500  d = HP.GetReal(d);
1501  }
1502 
1503  return d;
1504 }
1505 
1506 
1507 /* legge i nodi e li costruisce */
1508 
1509 int
1511  unsigned int uLabel, Node::Type type,
1512  doublereal& dX) const
1513 {
1514  /* verifica di esistenza del nodo */
1515  if (pFindNode(type, uLabel) != NULL) {
1516  silent_cerr("line " << HP.GetLineData()
1517  << ": " << psNodeNames[type] << "(" << uLabel
1518  << ") already defined" << std::endl);
1520  }
1521 
1522  if (HP.IsArg()) {
1523  /* eat keyword "value" */
1524  if (!HP.IsKeyWord("value")) {
1525  pedantic_cerr(psNodeNames[type] << "(" << uLabel
1526  << "): initial value specified without "
1527  "\"value\" keyword (deprecated)" << std::endl);
1528  }
1529  dX = HP.GetReal();
1530  DEBUGLCOUT(MYDEBUG_INPUT, "Initial value x = " << dX
1531  << " is supplied" << std::endl);
1532  return 1;
1533  }
1534 
1535  return 0;
1536 }
1537 
1538 int
1540  unsigned int uLabel, Node::Type type,
1541  doublereal& dX, doublereal& dXP) const
1542 {
1543  if (ReadScalarAlgebraicNode(HP, uLabel, type, dX) == 1) {
1544  if (HP.IsKeyWord("derivative")) {
1545  dXP = HP.GetReal();
1547  "Initial derivative value xp = "
1548  << dXP << " is supplied" << std::endl);
1549  return 1;
1550  }
1551  }
1552 
1553  return 0;
1554 }
1555 
1556 void
1558 {
1559  DEBUGCOUTFNAME("DataManager::ReadNodes");
1560 
1561  /* parole chiave del blocco di controllo */
1562  const char* sKeyWords[] = {
1563  "end",
1564  "nodes",
1565 
1568  psReadNodesNodes[Node::THERMAL],
1569  psReadNodesNodes[Node::ABSTRACT],
1570  psReadNodesNodes[Node::PARAMETER],
1571  psReadNodesNodes[Node::HYDRAULIC],
1572 
1573  "output",
1574  NULL
1575  };
1576 
1577  /* enum delle parole chiave */
1578  enum KeyWords {
1579  UNKNOWN = -1,
1580 
1581  END = 0,
1582  NODES,
1583 
1584  STRUCTURAL,
1585  ELECTRIC,
1586  THERMAL,
1587  ABSTRACT,
1588  PARAMETER,
1589  HYDRAULIC,
1590 
1591  OUTPUT,
1592 
1593  LASTKEYWORD
1594  };
1595 
1596  /* tabella delle parole chiave */
1597  KeyTable K(HP, sKeyWords);
1598 
1599  /* struttura di servizio che conta i nodi tipo per tipo */
1601  for (int i = 0; i < Node::LASTNODETYPE; i++) {
1602  iNumTypes[i] = NodeData[i].iExpectedNum;
1603  }
1604 
1605  int iMissingNodes = iTotNodes;
1606  DEBUGLCOUT(MYDEBUG_INPUT, "Expected nodes: " << iMissingNodes << std::endl);
1607 
1608  NodeVecType::iterator ni = Nodes.begin();
1609 
1610  KeyWords CurrDesc;
1611  while ((CurrDesc = KeyWords(HP.GetDescription())) != END) {
1612  if (CurrDesc == OUTPUT) {
1613  DEBUGLCOUT(MYDEBUG_INPUT, "nodes to be output: ");
1614 
1615  Node::Type Typ;
1616  flag fOutput = 1;
1617  switch (KeyWords(HP.GetWord())) {
1618 
1619  case STRUCTURAL:
1620  DEBUGLCOUT(MYDEBUG_INPUT, "structural" << std::endl);
1621  Typ = Node::STRUCTURAL;
1622  if (HP.IsKeyWord("accelerations")) {
1623  fOutput |= 2;
1624  }
1625  break;
1626 
1627  case ELECTRIC:
1628  DEBUGLCOUT(MYDEBUG_INPUT, "electric" << std::endl);
1629  Typ = Node::ELECTRIC;
1630  break;
1631 
1632  case THERMAL:
1633  DEBUGLCOUT(MYDEBUG_INPUT, "thermal" << std::endl);
1634  Typ = Node::THERMAL;
1635  break;
1636 
1637  case ABSTRACT:
1638  DEBUGLCOUT(MYDEBUG_INPUT, "abstract" << std::endl);
1639  Typ = Node::ABSTRACT;
1640  break;
1641 
1642  case PARAMETER:
1643  DEBUGLCOUT(MYDEBUG_INPUT, "parameter" << std::endl);
1644  Typ = Node::PARAMETER;
1645  break;
1646 
1647  case HYDRAULIC:
1648  DEBUGLCOUT(MYDEBUG_INPUT, "hydraulic" << std::endl);
1649  Typ = Node::HYDRAULIC;
1650  break;
1651 
1652  default:
1653  silent_cerr("Error: unknown node type, cannot modify output"
1654  << std::endl);
1655 
1657  }
1658 
1659  while (HP.IsArg()) {
1660  if (HP.IsKeyWord("range")) {
1661  unsigned int uL = (unsigned int)HP.GetInt();
1662  unsigned int uEndL = (unsigned int)HP.GetInt();
1663 
1664  if (uEndL < uL) {
1665  silent_cerr("End label " << uEndL
1666  << " must be larger "
1667  "than or equal to start label " << uL
1668  << std::endl);
1670  }
1671 
1672  for (; uL <= uEndL; uL++) {
1673  Node* pN = pFindNode(Typ, uL);
1674  if (pN != NULL) {
1676  "node " << uL << std::endl);
1677  pN->SetOutputFlag(fOutput);
1678  }
1679  }
1680 
1681  } else {
1682  unsigned int uL = (unsigned int)HP.GetInt();
1683 
1684  Node* pN = pFindNode(Typ, uL);
1685  if (pN == 0) {
1686  silent_cerr(psNodeNames[Typ]
1687  << "(" << uL << ") "
1688  "is not defined (ignored); "
1689  "output cannot be modified "
1690  "at line " << HP.GetLineData()
1691  << std::endl);
1692 
1693  } else {
1694  DEBUGLCOUT(MYDEBUG_INPUT, "node " << uL << std::endl);
1695  pN->SetOutputFlag(fOutput);
1696  }
1697  }
1698  }
1699  } else {
1700  /* puntatore al puntatore al nodo */
1701  Node** ppN = NULL;
1702 
1703  /* legge la label */
1704  unsigned int uLabel = 0;
1705  if (CurrDesc >= 0) {
1706  uLabel = unsigned(HP.GetInt());
1707  }
1708 
1709  /* Nome del nodo */
1710  std::string sName;
1711  if (HP.IsKeyWord("name")) {
1712  const char *sTmp = HP.GetStringWithDelims();
1713  sName = sTmp;
1714  }
1715 
1716  /* in base al tipo, avviene l'allocazione */
1717  switch (CurrDesc) {
1718  /* Struttura del blocco di lettura dei nodi:
1719  *
1720  * - test sul numero di nodi letti rispetto a quelli dichiarati
1721  * nel blocco di controllo:
1722  * if(iNumTypes[Node::??]-- <= 0)
1723  * < gestione dell'errore >
1724  *
1725  * - verifica di esistenza del nodo
1726  * if(pFindNode(Node::??, uLabel) != NULL)
1727  * < gestione dell'errore >
1728  *
1729  * - lettura dati specifici
1730  *
1731  * - allocazione e costruzione del nodo:
1732  * - assegnazione del puntatore:
1733  * ppN = NodeData[Node::??].ppFirstNode+
1734  * iNumTypes[Node::??];
1735  *
1736  * - allocazione e costruzione:
1737  * SAFENEW((??Node*)*ppN, ??Node(uLabel));
1738  *
1739  * - correzione del DofOwner relativo al nodo:
1740  * (DofData[DofOwner::??].pFirstDofOwner+
1741  * iNumTypes[Node::??])->iNumDofs =
1742  * DofData[DofOwner::??].iSize;
1743  *
1744  * - scrittura dei dati specifici dell'oggetto creato.
1745  * In alternativa i dati possono essere passato tutti
1746  * attraverso il costruttore.
1747  */
1748 
1749 
1750  /* Nodi strutturali */
1751  case STRUCTURAL: {
1752  silent_cout("Reading "
1753  << psNodeNames[Node::STRUCTURAL] << "(" << uLabel << ( sName.empty() ? "" : ( std::string(", \"") + sName + "\"" ) ) << ")"
1754  << std::endl);
1755 
1756  /* verifica che non siano gia' stati letti tutti
1757  * quelli previsti */
1758  if (iNumTypes[Node::STRUCTURAL]-- <= 0) {
1759  DEBUGCERR("");
1760  silent_cerr("line " << HP.GetLineData() << ": "
1761  << psNodeNames[Node::STRUCTURAL] << "(" << uLabel << ") "
1762  "exceeds structural nodes number"
1763  << std::endl);
1764 
1766  }
1767 
1768  /* verifica di esistenza del nodo */
1769  if (pFindNode(Node::STRUCTURAL, uLabel) != NULL) {
1770  DEBUGCERR("");
1771  silent_cerr("line " << HP.GetLineData() << ": "
1772  << psNodeNames[Node::STRUCTURAL] << "(" << uLabel << ") "
1773  "already defined" << std::endl);
1774 
1776  }
1777 
1778 
1779  /* lettura dei dati specifici */
1780 
1781  /* allocazione e creazione */
1783  - iNumTypes[Node::STRUCTURAL] - 1;
1784  DofOwner* pDO = DofData[DofOwner::STRUCTURALNODE].pFirstDofOwner + i;
1785 
1786  Node *pN = ReadStructNode(this, HP, pDO, uLabel);
1787  if (pN != 0) {
1788  ppN = InsertNode(NodeData[Node::STRUCTURAL], uLabel, pN);
1789  }
1790  } break;
1791 
1792  /* nodi elettrici */
1793  case ELECTRIC: {
1794  silent_cout("Reading "
1795  << psNodeNames[Node::ELECTRIC] << "(" << uLabel << ( sName.empty() ? "" : ( std::string(", \"") + sName + "\"" ) ) << ")"
1796  << std::endl);
1797 
1798  /*
1799  * verifica che non siano gia' stati letti tutti
1800  * quelli previsti
1801  */
1802  if (iNumTypes[Node::ELECTRIC]-- <= 0) {
1803  silent_cerr("line " << HP.GetLineData() << ": "
1804  << psNodeNames[Node::ELECTRIC] << "(" << uLabel << ") "
1805  "exceeds declared number" << std::endl);
1807  }
1808 
1809  /* Initial values */
1810  doublereal dx(0.);
1811  doublereal dxp(0.);
1812 
1813  ReadScalarDifferentialNode(HP, uLabel, Node::ELECTRIC, dx, dxp);
1815  flag fOut = fReadOutput(HP, Node::ELECTRIC);
1816 
1817  /* allocazione e creazione */
1819  - iNumTypes[Node::ELECTRIC] - 1;
1820  DofOwner* pDO = DofData[DofOwner::ELECTRICNODE].pFirstDofOwner + i;
1821  pDO->SetScale(dScale);
1822 
1823  Node *pN = 0;
1825  ElectricNode,
1826  ElectricNode(uLabel, pDO, dx, dxp, fOut));
1827  if (pN != 0) {
1828  ppN = InsertNode(NodeData[Node::ELECTRIC], uLabel, pN);
1829  }
1830 
1831  } break;
1832 
1833  case THERMAL: {
1834  silent_cout("Reading "
1835  << psNodeNames[Node::THERMAL] << "(" << uLabel << ( sName.empty() ? "" : ( std::string(", \"") + sName + "\"" ) ) << ")"
1836  << std::endl);
1837 
1838  /*
1839  * verifica che non siano gia' stati letti tutti
1840  * quelli previsti
1841  */
1842  if (iNumTypes[Node::THERMAL]-- <= 0) {
1843  silent_cerr("line " << HP.GetLineData() << ": "
1844  << psNodeNames[Node::THERMAL] << "(" << uLabel << ") "
1845  "exceeds declared number" << std::endl);
1847  }
1848 
1849  /* Initial values */
1850  doublereal dx(0.);
1851  doublereal dxp(0.);
1852 
1853  ReadScalarDifferentialNode(HP, uLabel, Node::THERMAL, dx, dxp);
1855  flag fOut = fReadOutput(HP, Node::THERMAL);
1856 
1857  /* allocazione e creazione */
1859  - iNumTypes[Node::THERMAL] - 1;
1860  DofOwner* pDO = DofData[DofOwner::THERMALNODE].pFirstDofOwner + i;
1861  pDO->SetScale(dScale);
1862 
1863  Node *pN = 0;
1865  ThermalNode,
1866  ThermalNode(uLabel, pDO, dx, dxp, fOut));
1867  if (pN != 0) {
1868  ppN = InsertNode(NodeData[Node::THERMAL], uLabel, pN);
1869  }
1870 
1871  } break;
1872 
1873  /* nodi astratti */
1874  case ABSTRACT: {
1875  silent_cout("Reading "
1876  << psNodeNames[Node::ABSTRACT] << "(" << uLabel << ( sName.empty() ? "" : ( std::string(", \"") + sName + "\"" ) ) << ")"
1877  << std::endl);
1878 
1879  bool bAlgebraic(false);
1880 
1881  /*
1882  * verifica che non siano gia' stati letti tutti
1883  * quelli previsti
1884  */
1885  if (iNumTypes[Node::ABSTRACT]-- <= 0) {
1886  silent_cerr("line " << HP.GetLineData() << ": "
1887  << psNodeNames[Node::ABSTRACT] << "(" << uLabel << ") "
1888  "exceeds declared number" << std::endl);
1890  }
1891 
1892  if (HP.IsKeyWord("algebraic")) {
1893  bAlgebraic = true;
1894 
1895  } else if (!HP.IsKeyWord("differential")) {
1896  pedantic_cout("unspecified "
1897  << psNodeNames[Node::ABSTRACT] << "(" << uLabel << ") "
1898  "at line " << HP.GetLineData() << "; "
1899  "assuming \"differential\"" << std::endl);
1900  }
1901 
1902  /* lettura dei dati specifici */
1903  doublereal dx(0.);
1904  doublereal dxp(0.);
1905 
1906  if (bAlgebraic) {
1907  ReadScalarAlgebraicNode(HP, uLabel, Node::ABSTRACT, dx);
1908 
1909  } else {
1910  ReadScalarDifferentialNode(HP, uLabel, Node::ABSTRACT, dx, dxp);
1911  }
1913  flag fOut = fReadOutput(HP, Node::ABSTRACT);
1914 
1915  /* allocazione e creazione */
1917  - iNumTypes[Node::ABSTRACT] - 1;
1918  DofOwner* pDO = DofData[DofOwner::ABSTRACTNODE].pFirstDofOwner + i;
1919  pDO->SetScale(dScale);
1920 
1921  Node *pN = 0;
1922  if (bAlgebraic) {
1925  ScalarAlgebraicNode(uLabel, pDO, dx, fOut));
1926 
1927  } else {
1930  ScalarDifferentialNode(uLabel, pDO, dx, dxp, fOut));
1931  }
1932 
1933  if (pN != 0) {
1934  ppN = InsertNode(NodeData[Node::ABSTRACT], uLabel, pN);
1935  }
1936  } break;
1937 
1938  /* parametri */
1939  case PARAMETER: {
1940  silent_cout("Reading "
1941  << psNodeNames[Node::PARAMETER] << "(" << uLabel << ( sName.empty() ? "" : ( std::string(", \"") + sName + "\"" ) ) << ")"
1942  << std::endl);
1943 
1944  /* verifica che non siano gia' stati letti tutti
1945  * quelli previsti */
1946  if (iNumTypes[Node::PARAMETER]-- <= 0) {
1947  DEBUGCERR("");
1948  silent_cerr("line " << HP.GetLineData() << ": "
1949  << psNodeNames[Node::PARAMETER] << "(" << uLabel << ") "
1950  "exceeds parameters number" << std::endl);
1951 
1953  }
1954 
1955  /* verifica di esistenza del nodo */
1956  if (pFindNode(Node::PARAMETER, uLabel) != NULL) {
1957  DEBUGCERR("");
1958  silent_cerr("line " << HP.GetLineData() << ": "
1959  << psNodeNames[Node::PARAMETER] << "(" << uLabel << ") "
1960  "already defined" << std::endl);
1961 
1963  }
1964 
1965  Node *pN = 0;
1966 
1967  /* bound a elemento */
1968  if (HP.IsKeyWord("element")) {
1970  psNodeNames[Node::PARAMETER] << "(" << uLabel << ") "
1971  "will be linked to an element" << std::endl);
1972  flag fOut = fReadOutput(HP, Node::PARAMETER);
1973 
1974  /* allocazione e creazione */
1976  Elem2Param,
1977  Elem2Param(uLabel, &DummyDofOwner, fOut));
1978 
1979  } else if (HP.IsKeyWord("sample" "and" "hold") ||
1980  HP.IsKeyWord("sample'n'hold"))
1981  {
1982 
1984  psNodeNames[Node::PARAMETER] << "(" << uLabel << ") "
1985  "is a sample-and-hold" << std::endl);
1986 
1987  ScalarDof SD(ReadScalarDof(this, HP, false, false));
1988 
1989  DriveCaller *pDC = NULL;
1992 
1993  doublereal dSP = HP.GetReal();
1994  if (dSP <= 0.) {
1995  silent_cerr("illegal sample period "
1996  "for SampleAndHold(" << uLabel << ") "
1997  "at line " << HP.GetLineData()
1998  << std::endl);
2000  }
2001 
2002  flag fOut = fReadOutput(HP, Node::PARAMETER);
2003 
2004  /* allocazione e creazione */
2006  SampleAndHold,
2007  SampleAndHold(uLabel, &DummyDofOwner,
2008  SD.pNode, pDC, dSP, fOut));
2009 
2010  /* strain gage */
2011  } else if (HP.IsKeyWord("strain" "gage") /* deprecated */
2012  || HP.IsKeyWord("beam" "strain" "gage"))
2013  {
2015  psNodeNames[Node::PARAMETER] << "(" << uLabel << ") "
2016  "is a strain gage" << std::endl);
2017 
2018  doublereal dY = HP.GetReal();
2019  doublereal dZ = HP.GetReal();
2020 
2021  flag fOut = fReadOutput(HP, Node::PARAMETER);
2022 
2023  /* allocazione e creazione */
2026  StrainGageParam(uLabel, &DummyDofOwner,
2027  dY, dZ, fOut));
2028 
2029  /* parametro generico */
2030  } else {
2031 
2032  /* lettura dei dati specifici */
2033  doublereal dX(0.);
2034  if (HP.IsArg()) {
2035  /* eat keyword "value" */
2036  if (!HP.IsKeyWord("value")) {
2037  pedantic_cerr("ParameterNode(" << uLabel << "): "
2038  "initial value specified without "
2039  "\"value\" keyword (deprecated)" << std::endl);
2040  }
2041  dX = HP.GetReal();
2043  "Initial value x = " << dX
2044  << " is supplied" << std::endl);
2045  }
2046 
2047  flag fOut = fReadOutput(HP, Node::PARAMETER);
2048 
2049  /* allocazione e creazione */
2051  ParameterNode,
2052  ParameterNode(uLabel, &DummyDofOwner,
2053  dX, fOut));
2054  }
2055 
2056  if (pN != 0) {
2057  ppN = InsertNode(NodeData[Node::PARAMETER], uLabel, pN);
2058  }
2059  } break;
2060 
2061  /* nodi idraulici */
2062  case HYDRAULIC: {
2063  silent_cout("Reading "
2064  << psNodeNames[Node::HYDRAULIC] << "(" << uLabel << ( sName.empty() ? "" : ( std::string(", \"") + sName + "\"" ) ) << ")"
2065  << std::endl);
2066 
2067  /*
2068  * verifica che non siano gia' stati letti tutti
2069  * quelli previsti
2070  */
2071  if (iNumTypes[Node::HYDRAULIC]-- <= 0) {
2072  silent_cerr("line " << HP.GetLineData() << ": "
2073  << psNodeNames[Node::HYDRAULIC] << "(" << uLabel << ") "
2074  "exceeds declared number" << std::endl);
2076  }
2077 
2078  /* lettura dei dati specifici */
2079  doublereal dx(0.);
2080  ReadScalarAlgebraicNode(HP, uLabel, Node::ABSTRACT, dx);
2082  flag fOut = fReadOutput(HP, Node::HYDRAULIC);
2083 
2084  /* allocazione e creazione */
2086  - iNumTypes[Node::HYDRAULIC] - 1;
2087  DofOwner* pDO = DofData[DofOwner::HYDRAULICNODE].pFirstDofOwner + i;
2088  pDO->SetScale(dScale);
2089 
2090  Node *pN = 0;
2092  PressureNode,
2093  PressureNode(uLabel, pDO, dx, fOut));
2094 
2095  if (pN != 0) {
2096  ppN = InsertNode(NodeData[Node::HYDRAULIC], uLabel, pN);
2097  }
2098  } break;
2099 
2100 
2101  /* aggiungere eventuali nuovi tipi di nodo */
2102 
2103 
2104  /* in caso di tipo errato */
2105  case UNKNOWN:
2106  DEBUGCERR("");
2107  silent_cerr("unknown node type at line "
2108  << HP.GetLineData() << std::endl);
2110 
2111  default:
2112  DEBUGCERR("");
2113  silent_cerr("node type " << sKeyWords[CurrDesc]
2114  << " at line " << HP.GetLineData()
2115  << " is not allowed" << std::endl);
2116 
2117  throw DataManager::ErrGeneric(MBDYN_EXCEPT_ARGS);
2118  }
2119 
2120  /* verifica dell'allocazione - comune a tutti i casi */
2121  if (*ppN == NULL) {
2122  DEBUGCERR("");
2123  silent_cerr("error in allocation "
2124  "of " << psNodeNames[CurrDesc] << "(" << uLabel << ")"
2125  << std::endl);
2126 
2128  }
2129 
2130  if (!sName.empty()) {
2131  (*ppN)->PutName(sName);
2132  }
2133 
2134  *ni = *ppN;
2135  ++ni;
2136 
2137  /* Decrementa i nodi attesi */
2138  iMissingNodes--;
2139  }
2140  }
2141 
2142  if (KeyWords(HP.GetWord()) != NODES) {
2143  DEBUGCERR("");
2144  silent_cerr("\"end: nodes;\" expected at line "
2145  << HP.GetLineData() << std::endl);
2146 
2148  }
2149 
2150  /* Se non c'e' il punto e virgola finale */
2151  if (HP.IsArg()) {
2152  DEBUGCERR("");
2153  silent_cerr("semicolon expected at line "
2154  << HP.GetLineData() << std::endl);
2155 
2157  }
2158 
2159  if (iMissingNodes > 0) {
2160  DEBUGCERR("");
2161  silent_cerr("warning: " << iMissingNodes
2162  << " nodes are missing;" << std::endl);
2163  for (int iCnt = 0; iCnt < Node::LASTNODETYPE; iCnt++) {
2164  if (iNumTypes[iCnt] > 0) {
2165  silent_cerr(" " << iNumTypes[iCnt]
2166  << ' ' << psNodeNames[iCnt] << std::endl);
2167  }
2168  }
2169 
2171  }
2172 
2173  /* count & initialize node array */
2174  unsigned iNumNodes = 0;
2175  for (int iCnt = 0; iCnt < Node::LASTNODETYPE; iCnt++) {
2176  iNumNodes += NodeData[iCnt].NodeContainer.size();
2177  }
2178 
2179  ASSERT(ni == Nodes.end());
2180  ASSERT(iNumNodes == Nodes.size());
2181 
2182  DEBUGLCOUT(MYDEBUG_INPUT, "End of nodes data" << std::endl);
2183 } /* End of DataManager::ReadNodes() */
2184 
2185 
2186 void
2188 {
2189  DEBUGCOUTFNAME("DataManager::ReadDrivers");
2190 
2191  /* parole chiave del blocco di controllo */
2192  const char* sKeyWords[] = {
2193  "end",
2194  "drivers",
2195  "file",
2196  NULL
2197  };
2198 
2199  /* enum delle parole chiave */
2200  enum KeyWords {
2201  UNKNOWN = -1,
2202 
2203  END = 0,
2204  DRIVERS,
2205  FILEDRIVE,
2206 
2207  LASTKEYWORD
2208  };
2209 
2210  /* tabella delle parole chiave */
2211  KeyTable K(HP, sKeyWords);
2212 
2213  /* strutture di conteggio dei drivers letti */
2215  for (int i = 0; i < Drive::LASTDRIVETYPE; i++) {
2216  iNumTypes[i] = DriveData[i].iNum;
2217  }
2218 
2219  int iMissingDrivers = iTotDrive;
2220  DEBUGLCOUT(MYDEBUG_INPUT, "Expected drivers: " << iMissingDrivers
2221  << std::endl);
2222 
2223  KeyWords CurrDesc;
2224  while ((CurrDesc = KeyWords(HP.GetDescription())) != END) {
2225  /* puntatore al puntatore al driver */
2226  Drive** ppD = NULL;
2227 
2228  /* legge la label */
2229  unsigned int uLabel = 0;
2230  if (CurrDesc >= 0) {
2231  uLabel = unsigned(HP.GetInt());
2232  }
2233 
2234  /* in base al tipo, avviene l'allocazione */
2235  switch (CurrDesc) {
2236  /* drivers */
2237  case FILEDRIVE: {
2238  silent_cout("Reading "
2239  << psDriveNames[Drive::FILEDRIVE] << "(" << uLabel << ")"
2240  << std::endl);
2241 
2242  if (iNumTypes[Drive::FILEDRIVE]-- <= 0) {
2243  DEBUGCERR("");
2244  silent_cerr("line " << HP.GetLineData() << ": "
2245  << psDriveNames[Drive::FILEDRIVE] << "(" << uLabel << ") "
2246  "exceeds file drivers number" << std::endl);
2248  }
2249 
2250  /* allocazione e creazione */
2251  int i = DriveData[Drive::FILEDRIVE].iNum
2252  - iNumTypes[Drive::FILEDRIVE] - 1;
2253  ppD = DriveData[Drive::FILEDRIVE].ppFirstDrive + i;
2254 
2255  *ppD = ReadDriveData(uLabel, this, HP);
2256  } break;
2257 
2258  /* aggiungere qui i nuovi tipi */
2259 
2260  /* in caso di tipo sconosciuto */
2261  default:
2262  DEBUGCERR("");
2263  silent_cerr("unknown drive type at line "
2264  << HP.GetLineData() << std::endl);
2266 
2267  }
2268 
2269  /* verifica dell'allocazione */
2270  if (*ppD == NULL) {
2271  DEBUGCERR("");
2272  silent_cerr("error in allocation "
2273  "of " << psDriveNames[Drive::FILEDRIVE] << "(" << uLabel << ")"
2274  << std::endl);
2276  }
2277 
2278  /* decrementa il totale degli elementi mancanti */
2279  iMissingDrivers--;
2280  }
2281 
2282  if (KeyWords(HP.GetWord()) != DRIVERS) {
2283  DEBUGCERR("");
2284  silent_cerr("\"end: drivers;\" expected at line "
2285  << HP.GetLineData() << std::endl);
2287  }
2288 
2289  /* Se non c'e' il punto e virgola finale */
2290  if (HP.IsArg()) {
2291  DEBUGCERR("");
2292  silent_cerr("semicolon expected at line "
2293  << HP.GetLineData() << std::endl);
2295  }
2296 
2297  if (iMissingDrivers > 0) {
2298  silent_cerr("warning, " << iMissingDrivers
2299  << " drivers are missing" << std::endl);
2301  }
2302 
2303  DEBUGLCOUT(MYDEBUG_INPUT, "End of drivers data" << std::endl);
2304 } /* End of ReadDrivers */
2305 
2306 /* DataManager - end */
2307 
2308 Node*
2310 {
2311  integer iNode = HP.GetInt();
2312  if (iNode < 0) {
2313  silent_cerr("DataManager::ReadNode: invalid node label " << iNode
2314  << " at line " << HP.GetLineData() << std::endl);
2316  }
2317  unsigned int uNode = (unsigned int)iNode;
2318 
2319  DEBUGLCOUT(MYDEBUG_INPUT, "DataManager::ReadNode: " << psNodeNames[type] << "(" << uNode << ")" << std::endl);
2320 
2321  /* verifica di esistenza del nodo */
2322  Node* pNode = pFindNode(type, uNode);
2323  if (pNode == 0) {
2324  silent_cerr("DataManager::ReadNode: " << psNodeNames[type] << "(" << uNode << ")"
2325  " not defined at line "
2326  << HP.GetLineData() << std::endl);
2328  }
2329 
2330  return pNode;
2331 }
2332 
2333 Elem*
2335 {
2336  integer iElem = HP.GetInt();
2337  if (iElem < 0) {
2338  silent_cerr("DataManager::ReadElem: invalid node label " << iElem
2339  << " at line " << HP.GetLineData() << std::endl);
2341  }
2342  unsigned int uElem = (unsigned int)iElem;
2343 
2344  DEBUGLCOUT(MYDEBUG_INPUT, "DataManager::ReadElem: " << psNodeNames[type] << "(" << uElem << ")" << std::endl);
2345 
2346  /* verifica di esistenza dell'elemento */
2347  Elem* pElem = dynamic_cast<Elem *>(pFindElem(type, uElem));
2348  if (pElem == 0) {
2349  silent_cerr("DataManager::ReadElem: " << psElemNames[type] << "(" << uElem << ")"
2350  " not defined at line "
2351  << HP.GetLineData() << std::endl);
2353  }
2354 
2355  return pElem;
2356 }
2357 
2358 
2359 static int
2360 GetDofOrder(MBDynParser& HP, Node* pNode, int iIndex)
2361 {
2362  /*
2363  * Ordine del grado di liberta' da considerare
2364  * (stato, oppure derivata se esiste)
2365  */
2366  int iOrder = 0;
2367 
2368  if (HP.IsKeyWord("differential")) {
2369  iOrder = 1;
2370 
2371  } else if (HP.IsKeyWord("order")) {
2372  iOrder = HP.GetInt();
2373  if (iOrder < 0 || iOrder > 2) {
2374  silent_cerr(psNodeNames[pNode->GetNodeType()]
2375  << "(" << pNode->GetLabel() << "): "
2376  "illegal order " << iOrder
2377  << " at line " << HP.GetLineData()
2378  << std::endl);
2380 
2381  } else if (iOrder == 2) {
2382  DynamicStructNode *pStrNode = dynamic_cast<DynamicStructNode *>(pNode);
2383  if (pStrNode == 0) {
2384  silent_cerr(psNodeNames[pNode->GetNodeType()]
2385  << "(" << pNode->GetLabel() << "): "
2386  "order " << iOrder << " not allowed "
2387  "at line " << HP.GetLineData()
2388  << std::endl);
2390  }
2391  pStrNode->ComputeAccelerations(true);
2392  }
2393  }
2394 
2395  if (iOrder > 0) {
2396  if (pNode->GetDofType(iIndex-1) != DofOrder::DIFFERENTIAL) {
2397  silent_cerr(psNodeNames[pNode->GetNodeType()]
2398  << "(" << pNode->GetLabel()
2399  << "): invalid order for index " << iIndex
2400  << " variable at line " << HP.GetLineData()
2401  << std::endl);
2403  }
2404  return iOrder;
2405  }
2406 
2407  if (HP.IsKeyWord("algebraic")) {
2408  return 0;
2409  } /* else */
2410 
2411  silent_cerr(psNodeNames[pNode->GetNodeType()]
2412  << "(" << pNode->GetLabel()
2413  << "): unknown or illegal order for index " << iIndex << std::endl
2414  << "(hint: you may need to specify "
2415  "\"differential\" or \"algebraic\" or \"order <n>\" when referencing " << std::endl
2416  << "a generic degree of freedom at line "
2417  << HP.GetLineData() << ")" << std::endl);
2418 
2420 }
2421 
2422 ScalarDof
2423 ReadScalarDof(const DataManager* pDM, MBDynParser& HP, bool bDof, bool bOrder)
2424 {
2425  /* tabella delle parole chiave */
2426  KeyTable KDof(HP, psReadNodesNodes);
2427 
2428  /* Label del nodo */
2429  int iNode = HP.GetInt();
2430  if (iNode < 0) {
2431  silent_cerr("ReadScalarDof: invalid node label " << iNode
2432  << " at line " << HP.GetLineData() << std::endl);
2434  }
2435 
2436  unsigned uNode = unsigned(iNode);
2437  DEBUGLCOUT(MYDEBUG_INPUT, "Linked to Node " << uNode << std::endl);
2438 
2439  /* Tipo del nodo */
2440  Node::Type Type = Node::Type(HP.GetWord());
2441  if (Type == Node::UNKNOWN) {
2442  silent_cerr("ReadScalarDof: unknown node type "
2443  "at line " << HP.GetLineData() << std::endl);
2445  }
2446  DEBUGLCOUT(MYDEBUG_INPUT, "Node type: " << psNodeNames[Type] << std::endl);
2447 
2448  /* verifica di esistenza del nodo */
2449  Node* pNode = pDM->pFindNode(Type, uNode);
2450  if (pNode == 0) {
2451  silent_cerr(psNodeNames[Type] << "(" << uNode << ") not defined"
2452  " at line " << HP.GetLineData() << std::endl);
2454  }
2455 
2456  /* si procura il numero di dof del nodo */
2457  unsigned int iMaxIndex = pNode->iGetNumDof();
2458  DEBUGLCOUT(MYDEBUG_INPUT, "max index: " << iMaxIndex << std::endl);
2459 
2460  if (bDof && iMaxIndex == 0) {
2461  silent_cerr(psNodeNames[Type] << "(" << uNode << ") must have dofs "
2462  "at line " << HP.GetLineData() << std::endl);
2464  }
2465 
2466  /* se il nodo ha piu' di un dof, chiede quale dof si desidera */
2467  unsigned int iIndex = 1;
2468  if (iMaxIndex > 1) {
2469  iIndex = HP.GetInt();
2470  if (iIndex < 1 || iIndex > iMaxIndex) {
2471  silent_cerr("Illegal index " << iIndex << ", "
2472  << psNodeNames[Type] << "(" << uNode << ") "
2473  "has only " << iMaxIndex << " dofs "
2474  "at line " << HP.GetLineData() << std::endl);
2476  }
2477  DEBUGLCOUT(MYDEBUG_INPUT, "index: " << iIndex << std::endl);
2478  }
2479 
2480  /* se e' richiesto l'order del dof e se il dof e' differenziale ... */
2481  int iOrder = 0;
2482  if (bOrder && pNode->iGetNumDof() > 0
2483  && pNode->GetDofType(iIndex-1) == DofOrder::DIFFERENTIAL)
2484  {
2485  iOrder = GetDofOrder(HP, pNode, iIndex);
2486  }
2487  DEBUGLCOUT(MYDEBUG_INPUT, "order: " << iOrder << std::endl);
2488 
2489  /* se il nodo non e' scalare, alloca un Node2Scalar che lo wrappa */
2490  if (iMaxIndex > 1) {
2491  NodeDof nd(iIndex - 1, pNode);
2492 
2493  pNode = 0;
2494  /* Chi dealloca questa memoria? ci vorrebbe l'handle */
2496  }
2497 
2498  return ScalarDof(dynamic_cast<ScalarNode *>(pNode), iOrder, iIndex);
2499 }
2500 
2503 {
2505 
2506  if (HP.IsKeyWord("euler" "123")) {
2507  dod = EULER_123;
2508 
2509  } else if (HP.IsKeyWord("euler" "313")) {
2510  dod = EULER_313;
2511 
2512  } else if (HP.IsKeyWord("euler" "321")) {
2513  dod = EULER_321;
2514 
2515  } else if (HP.IsKeyWord("orientation" "vector")) {
2516  dod = ORIENTATION_VECTOR;
2517 
2518  } else if (HP.IsKeyWord("orientation" "matrix")) {
2519  dod = ORIENTATION_MATRIX;
2520 
2521  } else {
2522  silent_cerr("Unknown orientation description "
2523  "at line " << HP.GetLineData() << std::endl);
2525  }
2526 
2527  return dod;
2528 }
2529 
2532 {
2534 
2535  if (HP.IsKeyWord("orientation" "description")) {
2536  dod = ReadOrientationDescription(HP);
2537 
2538  } else if (pDM != 0) {
2539  /* get a sane default */
2540  dod = pDM->GetOrientationDescription();
2541 
2542  } else {
2543  dod = EULER_123;
2544  silent_cerr("Warning, data manager not defined yet, "
2545  "using default orientation (\"euler 123\") "
2546  "at line " << HP.GetLineData() << std::endl);
2547  }
2548 
2549  return dod;
2550 }
2551 
2552 
flag fReadOutput(MBDynParser &HP, const T &t) const
Definition: dataman.h:1064
ScalarNode * pNode
Definition: node.h:708
eRestart RestartEvery
Definition: dataman.h:164
void ReadLinSol(LinSol &cs, HighParser &HP, bool bAllowEmpty)
Definition: readlinsol.cc:39
void SetNetCDF(const OutputHandler::OutFiles out)
Definition: output.cc:500
void module_initialize(void)
Definition: modules.cc:44
const Vec3 Zero3(0., 0., 0.)
static int timeout
doublereal dEpsilon
Definition: dataman.h:126
long int flag
Definition: mbdyn.h:43
char * sSimulationTitle
Definition: dataman.h:158
const char * psReadNodesNodes[]
Definition: enums.cc:398
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
integer iGetSteps(void) const
Definition: drive_.h:1305
Definition: matvec3.h:98
Definition: node.h:67
#define DEBUGCOUTFNAME(fname)
Definition: myassert.h:256
virtual integer GetInt(integer iDefval=0)
Definition: parser.cc:1050
Mat3x3 GetRotAbs(const ReferenceFrame &rf)
Definition: mbpar.cc:1857
Elem * ReadElem(MBDynParser &HP, Elem::Type type) const
Definition: dataman3.cc:2334
Definition: drive.h:89
struct DataManager::@29 DriveData[Drive::LASTDRIVETYPE]
void ReadControl(MBDynParser &HP, const char *sInputFileName)
Definition: dataman3.cc:68
NodeVecType Nodes
Definition: dataman.h:743
OrientationDescription ReadOrientationDescription(MBDynParser &HP)
Definition: dataman3.cc:2502
doublereal dInitialPositionStiffness
Definition: dataman.h:121
bool bOmegaRotates
Definition: dataman.h:123
DofOwner DummyDofOwner
Definition: dataman.h:815
OutputHandler OutHdl
Definition: dataman.h:105
unsigned int iTotNodes
Definition: dataman.h:748
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
const Mat3x3 Eye3(1., 0., 0., 0., 1., 0., 0., 0., 1.)
virtual const char * GetFileName(enum Delims Del=DEFAULTDELIM)
Definition: parsinc.cc:673
void ReadNodes(MBDynParser &HP)
Definition: dataman3.cc:1557
OrientationDescription
Definition: matvec3.h:1597
doublereal dGetDefaultScale(DofOwner::Type t) const
Definition: dofman.cc:64
#define DEBUGCERR(msg)
Definition: myassert.h:235
unsigned int iTotDrive
Definition: dataman.h:622
integer iMaxInitialIterations
Definition: dataman.h:125
Definition: dataman4.cc:96
Drive * ReadDriveData(unsigned uLabel, const DataManager *pDM, MBDynParser &HP)
Definition: drive_.cc:1283
const char * psReadControlDrivers[]
Definition: enums.cc:357
NodeContainerType NodeContainer
Definition: dataman.h:731
int ReadScalarDifferentialNode(MBDynParser &HP, unsigned int uLabel, Node::Type type, doublereal &dX, doublereal &dXP) const
Definition: dataman3.cc:1539
void ReadBeamCustomOutput(DataManager *pDM, MBDynParser &HP, unsigned int uLabel, Beam::Type BT, unsigned &uFlags, OrientationDescription &od)
Definition: beam.cc:1776
int ReadScalarAlgebraicNode(MBDynParser &HP, unsigned int uLabel, Node::Type type, doublereal &dX) const
Definition: dataman3.cc:1510
bool bSkipInitialJointAssembly
Definition: dataman.h:117
bool saveXSol
Definition: dataman.h:175
Elem * pFindElem(Elem::Type Typ, unsigned int uElem, unsigned int iDeriv) const
Definition: elman.cc:650
void ReadDrivers(MBDynParser &HP)
Definition: dataman3.cc:2187
doublereal dReadScale(MBDynParser &HP, enum DofOwner::Type t) const
Definition: dataman3.cc:1491
void SetScale(const doublereal &d)
Definition: dofown.cc:44
void ReadAerodynamicCustomOutput(DataManager *pDM, MBDynParser &HP, unsigned int uLabel, unsigned &uFlags, OrientationDescription &od)
Definition: aeroelem.cc:1295
const ReferenceFrame AbsRefFrame(0, Vec3(0., 0., 0), Mat3x3(1., 0., 0., 0., 1., 0., 0., 0., 1.), Vec3(0., 0., 0), Vec3(0., 0., 0), EULER_123)
TplDriveCaller< Vec3 > * ReadDC3D(const DataManager *pDM, MBDynParser &HP)
doublereal dRestartTime
Definition: dataman.h:166
bool IsNull(void) const
Definition: matvec3.h:472
void SetPrecision(int iNewPrecision)
Definition: output.cc:663
#define SAFENEW(pnt, item)
Definition: mynewmem.h:695
int ResMode
Definition: dataman.h:201
DriveCaller * pOutputMeter
Definition: dataman.h:179
bool IsExactlySame(const Mat3x3 &m) const
Definition: matvec3.h:1237
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
RigidBodyKinematics * pRBK
Definition: dataman.h:129
int GetDescription(void)
Definition: parser.cc:730
struct DataManager::NodeDataStructure NodeData[Node::LASTNODETYPE]
Type
Definition: node.h:71
Vec3 GetPosAbs(const ReferenceFrame &rf)
Definition: mbpar.cc:1401
virtual const char * GetStringWithDelims(enum Delims Del=DEFAULTDELIM, bool escape=true)
Definition: parser.cc:1228
virtual DofOrder::Order GetDofType(unsigned int i) const =0
void ClearText(void)
Definition: output.cc:465
bool bOutputFrames
Definition: dataman.h:118
doublereal dInitialAssemblyTol
Definition: dataman.h:124
integer iRestartIterations
Definition: dataman.h:165
#define ASSERT(expression)
Definition: colamd.c:977
OrientationDescription od
Definition: dataman.h:229
OrientationDescription ReadOptionalOrientationDescription(DataManager *pDM, MBDynParser &HP)
Definition: dataman3.cc:2531
OrientationDescription GetOrientationDescription(void) const
Definition: dataman.cc:857
bool bInitialJointAssemblyToBeDone
Definition: dataman.h:116
KeyWords
Definition: dataman4.cc:94
const char * psReadControlNodes[]
Definition: enums.cc:387
doublereal dInitialVelocityStiffness
Definition: dataman.h:122
const doublereal dDefaultInitialStiffness
Definition: dataman.cc:80
bool bOutput(ResType t) const
Definition: dataman.cc:694
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
static int iNumTypes[Elem::LASTELEMTYPE]
Definition: dataman4.cc:91
const integer iDefaultMaxInitialIterations
Definition: dataman.cc:83
bool bOutputDriveCaller
Definition: dataman.h:120
char * solArrFileName
Definition: dataman.h:176
virtual bool ComputeAccelerations(bool b)
Definition: strnode.cc:194
static int GetDofOrder(MBDynParser &HP, Node *pNode, int iIndex)
Definition: dataman3.cc:2360
Vec3 GetVecAbs(const ReferenceFrame &rf)
Definition: mbpar.cc:1641
virtual unsigned int iGetNumDof(void) const =0
const char * psNodeNames[]
Definition: enums.cc:372
virtual bool GetYesNo(bool &bRet)
Definition: parser.cc:1022
Definition: j2p.h:40
virtual bool IsArg(void)
Definition: parser.cc:807
Definition: elem.h:75
virtual Node::Type GetNodeType(void) const =0
ScalarDof ReadScalarDof(const DataManager *pDM, MBDynParser &HP, bool bDof, bool bOrder)
Definition: dataman3.cc:2423
Type
Definition: elem.h:91
doublereal * pdRestartTimes
Definition: dataman.h:168
const char * psElemNames[]
Definition: enums.cc:39
virtual int GetWord(void)
Definition: parser.cc:1083
void ToBeUsedInAssembly(bool b)
Definition: dataman.h:578
Node * ReadStructNode(DataManager *pDM, MBDynParser &HP, DofOwner *pDO, unsigned int uLabel)
Definition: strnode.cc:3978
#define SAFESTRDUP(pnt, src)
Definition: mynewmem.h:707
bool bStaticModel
Definition: dataman.h:130
const char * psReadControlElems[]
Definition: enums.cc:122
LinSol CurrSolver
Definition: dataman.h:127
Node ** InsertNode(NodeDataStructure &nodedata, unsigned int uLabel, Node *pN)
Definition: dataman.h:735
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
void SetDataManager(DataManager *pdm)
Definition: mbpar.cc:296
integer iNumRestartTimes
Definition: dataman.h:169
std::ostream & Log(void) const
Definition: output.h:541
Definition: node.h:578
DriveCaller * GetDriveCaller(bool bDeferred=false)
Definition: mbpar.cc:2033
const doublereal dDefaultInitialAssemblyTol
Definition: dataman.cc:82
DriveHandler DrvHdl
Definition: dataman.h:104
virtual void SetOutputFlag(flag f=flag(1))
Definition: output.cc:896
struct DataManager::@30 DofData[DofOwner::LASTDOFTYPE]
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
unsigned int GetLabel(void) const
Definition: withlab.cc:62
struct DataManager::ElemDataStructure ElemData[Elem::LASTELEMTYPE]
Node * pFindNode(Node::Type Typ, unsigned int uNode) const
Definition: nodeman.cc:179
Node * ReadNode(MBDynParser &HP, Node::Type type) const
Definition: dataman3.cc:2309
#define DEBUGLCOUT(level, msg)
Definition: myassert.h:244
unsigned uPrintFlags
Definition: dataman.h:156
Mat3x3 R
bool bOutputAccels
Definition: dataman.h:119
TplDriveCaller< Vec3 > * ReadDCVecRel(const DataManager *pDM, MBDynParser &HP, const ReferenceFrame &rf)
#define SAFEDELETE(pnt)
Definition: mynewmem.h:710
virtual doublereal GetReal(const doublereal &dDefval=0.0)
Definition: parser.cc:1056
const char * psDriveNames[]
Definition: enums.cc:351