MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
dataman.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/dataman.cc,v 1.157 2017/05/29 17:50:43 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 
32 /* datamanager */
33 
34 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
35 
36 extern "C" {
37 #include <strings.h>
38 #include <time.h>
39 }
40 
41 #include "dataman.h"
42 #include "friction.h"
43 
44 #if defined(USE_RUNTIME_LOADING) && defined(HAVE_LTDL_H)
45 #include <ltdl.h>
46 #endif // USE_RUNTIME_LOADING && HAVE_LTDL_H
47 
48 #include "solver.h"
49 #include "invsolver.h"
50 #include "constltp.h"
51 #include "dataman_.h"
52 /* add-ons for math parser */
53 #include "dofpgin.h"
54 #include "privpgin.h"
55 #include "dummypgin.h"
56 #include "modelns.h"
57 
58 /* To allow direct loading of modules */
59 #include "modules.h"
60 
61 /* To handle Elem2Param */
62 #include "j2p.h"
63 
64 // To handle user-defined elements
65 #include "userelem.h"
66 
67 // To handle gusts
68 #include "gust.h"
69 
70 // To handle cleanups
71 #include "cleanup.h"
72 
73 /* DataManager - begin */
74 
75 /* linka i singoli DriveCaller al DriveHandler posseduto dal DataManager */
76 extern void SetDrvHdl(DriveHandler*);
77 
78 const bool bDefaultInitialJointAssemblyToBeMade(false);
79 const bool bDefaultSkipInitialJointAssembly(false);
81 const bool bDefaultOmegaRotates(false);
84 
85 /*
86  * costruttore: inizializza l'oggetto, legge i dati e crea le strutture di
87  * gestione di Dof, nodi, elementi e drivers.
88  */
89 
91  unsigned OF,
92  Solver* pS,
93  doublereal dInitialTime,
94  const char* sOutputFileName,
95  const char* sInputFileName,
96  bool bAbortAfterInput)
97 :
99 #ifdef USE_MULTITHREAD
100 nThreads(0),
101 #endif /* USE_MULTITHREAD */
102 MBPar(HP),
103 MathPar(HP.GetMathParser()),
104 pSolver(pS),
105 DrvHdl(HP.GetMathParser()),
106 OutHdl(sOutputFileName, 0),
107 pXCurr(0), pXPrimeCurr(0),
108 /* Inverse Dynamics: */
109 pXPrimePrimeCurr(0),
110 pLambdaCurr(0),
111 bInitialJointAssemblyToBeDone(bDefaultInitialJointAssemblyToBeMade),
112 bSkipInitialJointAssembly(bDefaultSkipInitialJointAssembly),
113 bOutputFrames(false),
114 bOutputAccels(false),
115 bOutputDriveCaller(false),
116 dInitialPositionStiffness(dDefaultInitialStiffness),
117 dInitialVelocityStiffness(dDefaultInitialStiffness),
118 bOmegaRotates(bDefaultOmegaRotates),
119 dInitialAssemblyTol(dDefaultInitialAssemblyTol),
120 iMaxInitialIterations(iDefaultMaxInitialIterations),
121 dEpsilon(1.),
122 CurrSolver(pS->GetLinearSolver()),
123 pRBK(0),
124 bStaticModel(false),
125 /* auto-detect if running inverse dynamics */
126 bInverseDynamics(dynamic_cast<InverseSolver *>(pS) != 0),
127 iIDNodeTotNumDofs(0),
128 iIDJointTotNumDofs(0),
129 #if defined(USE_RUNTIME_LOADING)
130 moduleInitialized(false),
131 #endif // USE_RUNTIME_LOADING
132 uPrintFlags(PRINT_NONE), /* Morandini, 2003-11-17 */
133 sSimulationTitle(0),
134 RestartEvery(NEVER),
135 iRestartIterations(0),
136 dRestartTime(0.),
137 pdRestartTimes(0),
138 iNumRestartTimes(0),
139 iCurrRestartTime(0),
140 iCurrRestartIter(0),
141 dLastRestartTime(dInitialTime),
142 saveXSol(false),
143 solArrFileName(0),
144 pOutputMeter(0),
145 iOutputCount(0),
146 #ifdef MBDYN_FDJAC
147 pFDJacMeter(0),
148 #endif // MBDYN_FDJAC
149 ResMode(RES_TEXT),
150 #ifdef USE_NETCDF
151 // NetCDF stuff
152 bNetCDFsync(false),
153 bNetCDFnoText(false),
154 Var_Step(0),
155 Var_Time(0),
156 Var_TimeStep(0),
157 Var_Eig_lStep(0),
158 Var_Eig_dTime(0),
159 Var_Eig_dCoef(0),
160 Var_Eig_dAplus(0),
161 Var_Eig_dAminus(0),
162 Var_Eig_dAlpha(0),
163 Var_Eig_Idx(0),
164 Var_Eig_dVR(0),
165 Var_Eig_dVL(0),
166 #endif // USE_NETCDF
167 od(EULER_123),
168 
169 #ifdef USE_SOCKET
170 SocketUsersTimeout(0),
171 #endif // USE_SOCKET
172 
173 /* ElemManager */
174 ElemIter(),
175 ppDrive(0),
176 iTotDrive(0),
177 iMaxWorkNumRowsRes(1), // Allocating a work space size >= 1 will be safe in any case
178 iMaxWorkNumRowsJac(1),
179 iMaxWorkNumColsJac(1),
180 iMaxWorkNumItemsJac(1),
181 pWorkMatA(0),
182 pWorkMatB(0),
183 pWorkMat(0),
184 pWorkVec(0),
185 
186 /* NodeManager */
187 iTotNodes(0),
188 
189 /* DofManager */
190 iTotDofOwners(0),
191 DofOwners(),
192 iTotDofs(0),
193 Dofs()
194 {
195  DEBUGCOUTFNAME("DataManager::DataManager");
196 
198  *ppCleanupData = (void *)this;
199 
200  OutHdl.SetExceptions(std::ios::badbit); // terminate if disk is full
201 
202  /* pseudocostruttori */
203  ElemManager();
204  NodeManager();
205  DofManager();
206 
207  InitDriveData();
208  InitUDE();
209  InitGustData();
210 
211  /* registra il plugin per i dofs */
212  HP.GetMathParser().RegisterPlugIn("dof", dof_plugin, this);
213 
214  /* registra il plugin per i dati privati dei nodi */
215  HP.GetMathParser().RegisterPlugIn("node", node_priv_plugin, this);
216 
217  /* registra il plugin per i dati privati degli elementi */
218  HP.GetMathParser().RegisterPlugIn("element", elem_priv_plugin, this);
219 
220  /* registra il namespace del modello */
221 
223 
224  /* Setta il tempo al valore iniziale */
225  SetTime(dInitialTime, 0., 0, false);
226 
227  DEBUGLCOUT(MYDEBUG_INIT, "Global symbol table:"
228  << MathPar.GetSymbolTable() << std::endl);
229 
230  /*
231  * Possiede MathParser, con relativa SymbolTable.
232  * Crea ExternKeyTable, MBDynParser,
233  * e legge i dati esterni. Quindi, quando trova
234  * i dati di controllo, chiama la relativa
235  * funzione di lettura (distinta per comodita')
236  */
237 
238  /* parole chiave */
239  const char* sKeyWords[] = {
240  "begin",
241  "control" "data",
242  "scalar" "function",
243  "nodes",
244  "elements",
245  "drivers",
246  "output",
247  0
248  };
249 
250  /* enum delle parole chiave */
251  enum KeyWords {
252  BEGIN = 0,
253  CONTROLDATA,
254  SCALARFUNCTION,
255  NODES,
256  ELEMENTS,
257  DRIVERS,
258  OUTPUT,
260  };
261 
262  /* tabella delle parole chiave */
263  KeyTable K(HP, sKeyWords);
264 
265  KeyWords CurrDesc = KeyWords(HP.GetDescription());
266  /* legge i dati di controllo */
267  if (CurrDesc != BEGIN) {
268  DEBUGCERR("");
269  silent_cerr("<begin> expected at line "
270  << HP.GetLineData() << std::endl);
271 
273  }
274 
275  if (KeyWords(HP.GetWord()) != CONTROLDATA) {
276  DEBUGCERR("");
277  silent_cerr("<begin: control data;> expected at line "
278  << HP.GetLineData() << std::endl);
279 
281  }
282 
283  ReadControl(HP, sInputFileName);
284  try {
285  CurrDesc = KeyWords(HP.GetDescription());
286  } catch (EndOfFile) {
287  NO_OP;
288  }
289 
290  /* fine lettura dati di controllo */
291 
292 
293 
294  /*
295  * a questo punto ElemManager contiene i numeri totali di elementi;
296  * NodeManager contiene i numeri totali di nodi;
297  * DofManager contiene i numeri totali di potenziali possessori di gradi
298  * di liberta'; quindi si puo' cominciare ad allocare matrici
299  */
300 
301 
302 
303  /* Costruzione struttura DofData e creazione array DofOwner */
304  DofDataInit();
305 
306  /* Costruzione struttura NodeData e creazione array Node* */
307  NodeDataInit();
308 
309  /*
310  * legge i nodi, crea gli item della struttura ppNodes
311  * e contemporaneamente aggiorna i dof
312  */
313  if (iTotNodes > 0) {
314  if (CurrDesc != BEGIN) {
315  DEBUGCERR("");
316  silent_cerr("<begin> expected at line "
317  << HP.GetLineData() << std::endl);
318 
320  }
321 
322  if (KeyWords(HP.GetWord()) != NODES) {
323  DEBUGCERR("");
324  silent_cerr("<begin: nodes;> expected at line "
325  << HP.GetLineData() << std::endl);
326 
328  }
329 
330  ReadNodes(HP);
331  try {
332  CurrDesc = KeyWords(HP.GetDescription());
333  } catch (EndOfFile) {}
334  } else {
335  DEBUGCERR("");
336  silent_cerr("warning, no nodes are defined" << std::endl);
337  }
338  /* fine lettura nodi */
339 
340  /*
341  * Costruzione struttura ElemData, DriveData
342  * e creazione array Elem* e Drive*
343  */
344  ElemDataInit();
345 
346  /* legge i drivers, crea la struttura ppDrive */
347  bool bGotDrivers = false;
348  if (iTotDrive > 0) {
349  if (CurrDesc != BEGIN) {
350  DEBUGCERR("");
351  silent_cerr("\"begin\" expected at line "
352  << HP.GetLineData() << std::endl);
353 
355  }
356 
357  if (KeyWords(HP.GetWord()) != DRIVERS) {
358  DEBUGCERR("");
359  silent_cerr("\"begin: drivers;\" expected at line "
360  << HP.GetLineData() << std::endl);
361 
363  }
364 
365  bGotDrivers = true;
366 
367  ReadDrivers(HP);
368  try {
369  CurrDesc = KeyWords(HP.GetDescription());
370  } catch (EndOfFile) {}
371 
372  } else {
373  DEBUGCERR("warning, no drivers are defined" << std::endl);
374  }
375 
376  /* fine lettura drivers */
377 
378 
379  /*
380  * legge gli elementi, crea la struttura ppElems
381  * e contemporaneamente aggiorna i dof
382  */
383  if (!Elems.empty()) {
384  if (CurrDesc != BEGIN) {
385  DEBUGCERR("");
386  silent_cerr("\"begin\" expected at line "
387  << HP.GetLineData() << std::endl);
388 
390  }
391 
392  switch (KeyWords(HP.GetWord())) {
393  case ELEMENTS:
394  break;
395 
396  case DRIVERS:
397  if (!bGotDrivers) {
398  silent_cerr("got unexpected \"begin: drivers;\" "
399  "at line " << HP.GetLineData() << std::endl
400  << "(hint: define \"file drivers\" in \"control data\" block)"
401  << std::endl);
402  }
403  // fallthru
404 
405  default:
406  DEBUGCERR("");
407  silent_cerr("\"begin: elements;\" expected at line "
408  << HP.GetLineData() << std::endl);
409 
411  }
412 
413  ReadElems(HP);
414 #if 0
415  /* FIXME: we don't check extra statements after "end: elements;"
416  * because there might be more... */
417  try {
418  CurrDesc = KeyWords(HP.GetDescription());
419  } catch (EndOfFile) {}
420 #endif
421  } else {
422  DEBUGCERR("");
423  silent_cerr("warning, no elements are defined" << std::endl);
424  }
425 
426  if (bOutputFrames) {
429  }
430 
431  /* fine lettura elementi */
432 
433  // if output is defined and at least one node wants to output,
434  // open file
435  for (int i = 0; i < Node::LASTNODETYPE; i++) {
436  if (NodeData[i].OutFile != OutputHandler::UNKNOWN)
437  {
438  for (NodeContainerType::const_iterator n = NodeData[i].NodeContainer.begin();
439  n != NodeData[i].NodeContainer.end(); ++n)
440  {
441  if (n->second->bToBeOutput()) {
442  OutHdl.Open(NodeData[i].OutFile);
443  break;
444  }
445  }
446  }
447  }
448 
449  // if output is defined and at least one element wants to output,
450  // open file
451  for (int i = 0; i < Elem::LASTELEMTYPE; i++) {
452  if (ElemData[i].OutFile != OutputHandler::UNKNOWN)
453  {
454  for (ElemContainerType::const_iterator e = ElemData[i].ElemContainer.begin();
455  e != ElemData[i].ElemContainer.end(); ++e)
456  {
457  if (e->second->bToBeOutput()) {
458  OutHdl.Open(ElemData[i].OutFile);
459  break;
460  }
461  }
462  }
463  }
464 
465  // open drive output & trave files only if needed
467  for (MBDynParser::DCType::const_iterator i = DC.begin(); i != DC.end(); ++i) {
468  if (i->second->fToBeTraced()) {
470  break;
471  }
472  }
473 
474  for (MBDynParser::DCType::const_iterator i = DC.begin(); i != DC.end(); ++i) {
475  if (i->second->bToBeOutput()) {
477  break;
478  }
479  }
480 
481  /* Verifica dei dati di controllo */
482 #ifdef DEBUG
484  /* mostra in modo succinto il numero di DofOwner per tipo */
485  for (int i = 0; i < DofOwner::LASTDOFTYPE; i++) {
486  std::cout << "DofType " << i << " "
487  "(" << psDofOwnerNames[i] << "), "
488  "n. of owners: " << DofData[i].iNum
489  << std::endl;
490  }
491 
492  /* mostra in modo succinto il numero di nodi per tipo */
493  for (int i = 0; i < Node::LASTNODETYPE; i++) {
494  std::cout << "NodeType " << i << " "
495  "(" << psNodeNames[i] << "), "
496  "n. of nodes: " << NodeData[i].NodeContainer.size()
497  << std::endl;
498  }
499 
500  /* mostra in modo succinto il numero di elementi per tipo */
501  for (int i = 0; i < Elem::LASTELEMTYPE; i++) {
502  std::cout << "Element Type " << i << " "
503  "(" << psElemNames[i] << "), "
504  "n. of elems: " << ElemData[i].ElemContainer.size()
505  << std::endl;
506  }
507 
508  /* mostra in modo succinto il numero di drivers per tipo */
509  for (int i = 0; i < Drive::LASTDRIVETYPE; i++) {
510  std::cout << "DriveType " << i << " "
511  "(" << psDriveNames[i] << "), "
512  "n. of drivers: " << DriveData[i].iNum
513  << std::endl;
514  }
515  }
516 #endif /* DEBUG */
517 
518  if (bAbortAfterInput) {
519  silent_cout("Only input is required" << std::endl);
520  return;
521  }
522 
523 #ifdef USE_SOCKET
524  /* waits for all pending sockets to connect */
525  WaitSocketUsers();
526 #endif // USE_SOCKET
527 
528  /* Qui intercetto la struttura dei Dof prima che venga costruita e modifico
529  * in modo che sia adatta all'assemblaggio dei vincoli; quindi la resetto
530  * e la lascio generare correttamente.
531  * L'assemblaggio iniziale viene gestito dal DataManager perche'
532  * concettualmente la consistenza dei dati deve essere assicurata da lui,
533  * che conosce gli aspetti fisici del problema
534  */
535 
537  for (int i = 0; i < Elem::LASTELEMTYPE; ++i) {
538  if (ElemData[i].bToBeUsedInAssembly() && !ElemData[i].ElemContainer.empty()) {
540  break;
541  }
542  }
543  }
544 
548 
549  } else {
550  silent_cout("Skipping initial joints assembly" << std::endl);
551  }
552 
553  } else {
554  silent_cout("No initial assembly is required since no joints are defined"
555  << std::endl);
556  }
557 
558  /* Costruzione dei dati dei Dof definitivi da usare nella simulazione */
559 
560  /* Aggiornamento DofOwner degli elementi (e dei nodi) */
561  if (bInverseDynamics) {
562  IDDofOwnerSet();
563  } else {
564  DofOwnerSet();
565  }
566 
567  /* Verifica dei dati di controllo */
568 #ifdef DEBUG
570  /* mostra in modo succinto i DofOwners */
571  int k = 0;
572  for (int i = 0; i < DofOwner::LASTDOFTYPE; i++) {
573  std::cout << "DofType " << i << ':' << std::endl;
574  for (int j = 0; j < DofData[i].iNum; j++) {
575  std::cout << "DofOwner " << j << ", n. of dofs: "
576  << DofOwners[k++].iNumDofs << std::endl;
577  }
578  }
579  }
580 #endif /* DEBUG */
581 
582  /* a questo punto i dof sono completamente scritti in quanto a numero.
583  * Rimane da sistemare il vettore con gli indici "interni" ed il tipo */
584 
585  /* Costruzione array DofOwner e Dof */
586  if(bInverseDynamics) {
587  IDDofInit();
588  } else {
589  DofInit();
590  }
591 
592  /* Aggiornamento Dof di proprieta' degli elementi e dei nodi */
593 // if(bInverseDynamics) {
594 // InverseDofOwnerInit();
595 // } else {
596  DofOwnerInit();
597 // }
598 
599  /* Creazione strutture di lavoro per assemblaggio e residuo */
600  ElemAssInit();
601 
602 #ifdef DEBUG
604  for (int iCnt = 0; iCnt < iTotDofs; iCnt++) {
605  std::cout << "Dof " << std::setw(4) << iCnt+1 << ": order "
606  << Dofs[iCnt].Order << std::endl;
607  }
608  }
609 #endif /* DEBUG */
610 
611 
612 } /* End of DataManager::DataManager() */
613 
614 
615 /* Distruttore: se richiesto, crea il file di restart; quindi
616  * chiama i distruttori degli oggetti propri e libera la memoria di lavoro */
617 
619 {
620  *ppCleanupData = 0;
621 
622  /* Se e' richiesto il file di restart, il distruttore del DataManager
623  * crea il file e forza gli oggetti a scrivere il loro contributo nel modo
624  * opportuno
625  */
626  if (RestartEvery == ATEND) {
627  MakeRestart();
628  }
629 
630  if (sSimulationTitle != 0) {
632  sSimulationTitle = 0;
633  }
634 
635  if (pOutputMeter) {
637  pOutputMeter = 0;
638  }
639 
640 #ifdef MBDYN_FDJAC
641  if (pFDJacMeter) {
642  SAFEDELETE(pFDJacMeter);
643  pFDJacMeter = 0;
644  }
645 #endif // MBDYN_FDJAC
646 
647  if (pRBK) {
648  SAFEDELETE(pRBK);
649  pRBK = 0;
650  }
651 
655 
657  DestroyUDE();
658  DestroyGustData();
659 
660 #if defined(USE_RUNTIME_LOADING)
661  if (moduleInitialized) {
662  module_finalize();
663  }
664 #endif // USE_RUNTIME_LOADING
665 } /* End of DataManager::DataManager() */
666 
667 int
669 {
670 #ifdef USE_SOCKET
671  DeleteSocketUsers();
672 #endif // USE_SOCKET
673  return 0;
674 }
675 
676 void
678 {
679  if (!OutHdl.IsOpen(o)) {
680  OutHdl.Open(o);
681  }
682 }
683 
684 void
685 DataManager::OutputEigOpen(const std::string& postfix)
686 {
690  }
691 }
692 
693 bool
695 {
696  return (ResMode & t) ? true : false;
697 }
698 
700 {
701  silent_cout("Making restart file ..." << std::endl);
703  /* Inizializzazione del file di restart */
704  time_t tCurrTime(time(0));
705  OutHdl.Restart() << "# Restart file prepared by Mbdyn, "
706  << ctime(&tCurrTime) << std::endl << std::endl;
707  /* Dati iniziali */
708  OutHdl.Restart() << "begin: data;" << std::endl
709  << "# uncomment this line to use the default integrator" << std::endl
710  << " integrator: multistep;" << std::endl
711  << "end: data;" << std::endl << std::endl
712  << "# the following block contains data for the multistep integrator"
713  << std::endl;
715 
716  /* Dati di controllo */
717  OutHdl.Restart() << "begin: control data;" << std::endl;
718 
719  /* Nodi */
720  for (int iCnt = 0; iCnt < Node::LASTNODETYPE; iCnt++) {
721  if (!NodeData[iCnt].NodeContainer.empty()) {
722  OutHdl.Restart() << " " << psReadControlNodes[iCnt] << ": "
723  << NodeData[iCnt].NodeContainer.size() << ';' << std::endl;
724  }
725  }
726 
727  /* Drivers */
728  for (int iCnt = 0; iCnt < Drive::LASTDRIVETYPE; iCnt++) {
729  if (DriveData[iCnt].iNum > 0) {
730  OutHdl.Restart() << " "
731  << psReadControlDrivers[iCnt] << ": "
732  << DriveData[iCnt].iNum << ';' << std::endl;
733  }
734  }
735 
736  /* Elementi */
737  for (int iCnt = 0; iCnt < Elem::LASTELEMTYPE; iCnt++) {
738  if (!ElemData[iCnt].ElemContainer.empty()) {
739  if (ElemData[iCnt].bIsUnique()) {
740  OutHdl.Restart() << " " << psReadControlElems[iCnt]
741  << ';' << std::endl;
742  } else {
743  OutHdl.Restart() << " " << psReadControlElems[iCnt] << ": "
744  << ElemData[iCnt].ElemContainer.size() << ';' << std::endl;
745  }
746  }
747  }
748 
749  if (sSimulationTitle != 0) {
750  OutHdl.Restart() << " title: \""
751  << sSimulationTitle << "\";" << std::endl;
752  }
753 
754  OutHdl.Restart() << std::endl
755  << "# comment this line if the model is to be modified!" << std::endl
756  << " skip initial joint assembly;" << std::endl
757  << "# uncomment the following lines to improve the satisfaction of constraints"
758  << std::endl
759  << " # initial stiffness: " << dInitialPositionStiffness << ", "
760  << dInitialVelocityStiffness << ';' << std::endl
761  << " # initial tolerance: " << dInitialAssemblyTol << ';' << std::endl
762  << " # max initial iterations: " << iMaxInitialIterations
763  << ';' << std::endl;
764  OutHdl.Restart() << "# uncomment this line if restart file is to be made again"
765  << std::endl
766  << " # make restart file;" << std::endl
767  << "# remember: it will replace the present file if you don't change its name"
768  << std::endl
769  << " default output: none";
770  for (int iCnt = 0; iCnt < Node::LASTNODETYPE; iCnt++) {
771  if (NodeData[iCnt].bDefaultOut()) {
772  OutHdl.Restart() << ", " << psReadControlNodes[iCnt];
773  }
774  }
775  for (int iCnt = 0; iCnt < Elem::LASTELEMTYPE; iCnt++) {
776  if (ElemData[iCnt].bDefaultOut()) {
777  OutHdl.Restart() << ", " << psReadControlElems[iCnt];
778  }
779  }
780  OutHdl.Restart() << "; " << std::endl;
781  if (saveXSol) {
782  OutHdl.Restart() << " read solution array;" << std::endl;
783  }
784  OutHdl.Restart() << "end: control data;" << std::endl << std::endl;
785 
786  /* Dati dei nodi */
787  OutHdl.Restart() << "begin: nodes;" << std::endl;
788  for (NodeVecType::const_iterator n = Nodes.begin(); n != Nodes.end(); ++n) {
789  (*n)->Restart(OutHdl.Restart());
790  }
791  OutHdl.Restart() << "end: nodes;" << std::endl << std::endl;
792 
793  /* Dati dei driver */
794  if (iTotDrive > 0) {
795  OutHdl.Restart() << "begin: drivers;" << std::endl;
796  for (Drive** ppTmpDrv = ppDrive;
797  ppTmpDrv < ppDrive+iTotDrive;
798  ppTmpDrv++)
799  {
800  (*ppTmpDrv)->Restart(OutHdl.Restart());
801 #if 0
802  OutHdl.Restart()
803  << " # file driver " << (*ppTmpDrv)->GetLabel()
804  << " is required" << std::endl;
805 #endif
806  }
807  OutHdl.Restart() << "end: drivers;" << std::endl << std::endl;
808  }
809 
810  /* Dati degli elementi */
811  OutHdl.Restart() << "begin: elements;" << std::endl;
812  for (ElemVecType::const_iterator e = Elems.begin();
813  e != Elems.end(); ++e)
814  {
815  (*e)->Restart(OutHdl.Restart());
816  }
817 
818  for (NodeContainerType::const_iterator n = NodeData[Node::PARAMETER].NodeContainer.begin();
819  n != NodeData[Node::PARAMETER].NodeContainer.end(); ++n)
820  {
821  dynamic_cast<const Elem2Param *>(n->second)->RestartBind(OutHdl.Restart());
822  }
823 
824  OutHdl.Restart() << "end: elements;" << std::endl;
825 
826  if (saveXSol) {
827  OutHdl.RestartXSol().write((char*)(pXCurr->pdGetVec()),
828  (pXCurr->iGetSize())*sizeof(double));
829  OutHdl.RestartXSol().write((char*)(pXPrimeCurr->pdGetVec()),
830  (pXPrimeCurr->iGetSize())*sizeof(double));
832  }
833 
835 }
836 
837 NamedValue *
838 DataManager::InsertSym(const char* const s, const Real& v, int redefine)
839 {
840  return MathPar.InsertSym(s, v, redefine);
841 }
842 
843 NamedValue *
844 DataManager::InsertSym(const char* const s, const Int& v, int redefine)
845 {
846  return MathPar.InsertSym(s, v, redefine);
847 }
848 
849 /* default orientation description */
850 void
852 {
853  this->od = od;
854 }
855 
858 {
859  return this->od;
860 }
861 
862 /* default output */
863 void
865 {
866  ElemData[t].uOutputFlags = flags;
867  ElemData[t].od = od;
868 }
869 
870 void
872 {
873  flags = ElemData[t].uOutputFlags;
874  od = ElemData[t].od;
875 }
876 
877 bool
879 {
880  return bOutputAccels;
881 }
882 
883 bool
885 {
886  return bOutputDriveCaller;
887 }
888 
889 DataManager::NodeContainerType::const_iterator
891 {
892  return NodeData[t].NodeContainer.begin();
893 }
894 
895 DataManager::NodeContainerType::const_iterator
897 {
898  return NodeData[t].NodeContainer.end();
899 }
900 
901 DataManager::ElemContainerType::const_iterator
903 {
904  return ElemData[t].ElemContainer.begin();
905 }
906 
907 DataManager::ElemContainerType::const_iterator
909 {
910  return ElemData[t].ElemContainer.end();
911 }
912 
913 extern "C" int
915 {
916  int rc = 0;
917 
918  if (data != 0) {
919  DataManager *pDM = (DataManager *)data;
920 
921  silent_cerr("DataManager cleanup" << std::endl);
922 
923  rc = pDM->Cleanup();
924  }
925 
926  return rc;
927 }
928 
929 bool
930 DataManager::PushCurrData(const std::string& name, const TypedValue& value)
931 {
932  ModelNameSpace *pMNS = dynamic_cast<ModelNameSpace *>(MathPar.GetNameSpace("model"));
933  if (pMNS == 0) {
934  return false;
935  }
936 
937  return pMNS->PushCurrData(name, value);
938 }
939 
940 bool
941 DataManager::PopCurrData(const std::string& name)
942 {
943  ModelNameSpace *pMNS = dynamic_cast<ModelNameSpace *>(MathPar.GetNameSpace("model"));
944  if (pMNS == 0) {
945  return false;
946  }
947 
948  return pMNS->PopCurrData(name);
949 }
std::ostream & ReferenceFrames(void) const
Definition: output.h:534
eRestart RestartEvery
Definition: dataman.h:164
DataManager(MBDynParser &HP, unsigned OF, Solver *pS, doublereal dInitialTime, const char *sOutputFileName, const char *sInputFileName, bool bAbortAfterInput)
Definition: dataman.cc:90
bool PopCurrData(const std::string &name)
Definition: modelns.cc:2944
bool bOutputDriveCallers(void) const
Definition: dataman.cc:884
#define DEBUG_LEVEL_MATCH(level)
Definition: myassert.h:241
ElemVecType Elems
Definition: dataman.h:609
MathParser::PlugIn * node_priv_plugin(MathParser &mp, void *arg)
Definition: privpgin.cc:299
ElemContainerType ElemContainer
Definition: dataman.h:591
const bool bDefaultSkipInitialJointAssembly(false)
char * sSimulationTitle
Definition: dataman.h:158
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
MathParser & MathPar
Definition: dataman.h:98
#define DEBUGCOUTFNAME(fname)
Definition: myassert.h:256
virtual doublereal * pdGetVec(void) const =0
void module_finalize(void)
Definition: modules.cc:67
NamedValue * InsertSym(const char *const s, const Real &v, int redefine=0)
Definition: mathp.cc:4315
int mbdyn_cleanup_register(mbdyn_cleanup_f handler, void ***datapp)
Definition: cleanup.cc:62
const DCType & GetDriveCallerContainer(void) const
Definition: mbpar.cc:854
OrientationDescription od
Definition: dataman.h:573
DofVecType Dofs
Definition: dataman.h:813
Definition: drive.h:89
void SetDrvHdl(DriveHandler *)
struct DataManager::@29 DriveData[Drive::LASTDRIVETYPE]
void ElemManager(void)
Definition: elman.cc:51
void ReadControl(MBDynParser &HP, const char *sInputFileName)
Definition: dataman3.cc:68
void OutputEigOpen(const std::string &postfix)
Definition: dataman.cc:685
int RegisterNameSpace(NameSpace *ns)
Definition: mathp.cc:4602
NodeVecType Nodes
Definition: dataman.h:743
doublereal dInitialPositionStiffness
Definition: dataman.h:121
OutputHandler OutHdl
Definition: dataman.h:105
unsigned int iTotNodes
Definition: dataman.h:748
bool Close(const OutputHandler::OutFiles out)
Definition: output.cc:536
void DofManagerDestructor(void)
Definition: dofman.cc:56
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
void ReadNodes(MBDynParser &HP)
Definition: dataman3.cc:1557
OrientationDescription
Definition: matvec3.h:1597
void DofOwnerSet(void)
Definition: dataman2.cc:1368
void NodeDataInit(void)
Definition: nodeman.cc:98
#define DEBUGCERR(msg)
Definition: myassert.h:235
void GetOutput(Elem::Type t, unsigned &, OrientationDescription &) const
Definition: dataman.cc:871
unsigned int iTotDrive
Definition: dataman.h:622
void SetOrientationDescription(OrientationDescription)
Definition: dataman.cc:851
#define NO_OP
Definition: myassert.h:74
integer iMaxInitialIterations
Definition: dataman.h:125
std::vector< DofOwner > DofOwners
Definition: dataman.h:796
void DofOwnerInit(void)
Definition: dataman2.cc:182
void InitialJointAssembly(void)
Definition: dataman2.cc:679
virtual integer iGetSize(void) const =0
std::ostream & Restart(std::ostream &out, DataManager::eRestart type) const
Definition: solver.cc:1717
const char * psReadControlDrivers[]
Definition: enums.cc:357
bool bInverseDynamics
Definition: dataman.h:133
NodeContainerType NodeContainer
Definition: dataman.h:731
void DofDataInit(void)
Definition: dofman.cc:69
integer iTotDofs
Definition: dataman.h:809
bool Open(const OutputHandler::OutFiles out)
Definition: output.cc:298
bool bSkipInitialJointAssembly
Definition: dataman.h:117
bool saveXSol
Definition: dataman.h:175
void ReadDrivers(MBDynParser &HP)
Definition: dataman3.cc:2187
void IDDofOwnerSet(void)
Definition: invdataman.cc:852
void DofInit(void)
Definition: dofman.cc:111
const bool bDefaultInitialJointAssemblyToBeMade(false)
void SetOutput(Elem::Type t, unsigned, OrientationDescription)
Definition: dataman.cc:864
std::map< unsigned, const DriveCaller * > DCType
Definition: mbpar.h:207
void ** ppCleanupData
Definition: dataman.h:89
DataManager::ElemContainerType::const_iterator begin(Elem::Type t) const
Definition: dataman.cc:902
void IDDofInit(void)
Definition: invdataman.cc:895
void ElemManagerDestructor(void)
Definition: elman.cc:196
Solver * pSolver
Definition: dataman.h:99
int ResMode
Definition: dataman.h:201
DriveCaller * pOutputMeter
Definition: dataman.h:179
Definition: mbdyn.h:76
void NodeManagerDestructor(void)
Definition: nodeman.cc:84
virtual void MakeRestart(void)
Definition: dataman.cc:699
RigidBodyKinematics * pRBK
Definition: dataman.h:129
int GetDescription(void)
Definition: parser.cc:730
void NodeManager(void)
Definition: nodeman.cc:44
struct DataManager::NodeDataStructure NodeData[Node::LASTNODETYPE]
void SetExceptions(std::ios::iostate flags)
Definition: output.cc:678
Type
Definition: node.h:71
const char * psDofOwnerNames[]
Definition: enums.cc:423
void DestroyGustData(void)
Definition: gust.cc:233
void ReadElems(MBDynParser &HP)
Definition: dataman4.cc:157
int datamanager_cleanup(void *data)
Definition: dataman.cc:914
VectorHandler * pXPrimeCurr
Definition: dataman.h:109
bool PushCurrData(const std::string &name, const TypedValue &value)
Definition: dataman.cc:930
if(nargin< 1)
NamedValue * InsertSym(const char *const s, const Real &v, int redefine=0)
Definition: dataman.cc:838
bool bOutputFrames
Definition: dataman.h:118
virtual MathParser & GetMathParser(void)
Definition: parser.cc:668
doublereal dInitialAssemblyTol
Definition: dataman.h:124
bool IsOpen(int out) const
Definition: output.cc:395
#define ASSERT(expression)
Definition: colamd.c:977
OrientationDescription od
Definition: dataman.h:229
std::ostream & RestartXSol(void) const
Definition: output.h:478
OrientationDescription GetOrientationDescription(void) const
Definition: dataman.cc:857
bool PopCurrData(const std::string &name)
Definition: dataman.cc:941
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
const bool bDefaultOmegaRotates(false)
void SetTime(const doublereal &dTime, const doublereal &dTimeStep=-1., const integer &iStep=-1, bool bServePending=true)
Definition: dataman2.cc:139
const integer iDefaultMaxInitialIterations
Definition: dataman.cc:83
bool bOutputDriveCaller
Definition: dataman.h:120
unsigned int iNum
Definition: dataman.h:618
Definition: solver.h:78
std::ostream & Restart(void) const
Definition: output.h:471
Drive ** ppDrive
Definition: dataman.h:621
NameSpace * GetNameSpace(const std::string &name) const
Definition: mathp.cc:4620
const char * psNodeNames[]
Definition: enums.cc:372
void DofManager(void)
Definition: dofman.cc:40
Definition: j2p.h:40
MathParser::PlugIn * elem_priv_plugin(MathParser &mp, void *arg)
Definition: privpgin.cc:308
Type
Definition: elem.h:91
int Cleanup(void)
Definition: dataman.cc:668
bool PushCurrData(const std::string &name, const TypedValue &value)
Definition: modelns.cc:2938
const char * psElemNames[]
Definition: enums.cc:39
virtual int GetWord(void)
Definition: parser.cc:1083
MathParser::PlugIn * dof_plugin(MathParser &mp, void *arg)
Definition: dofpgin.cc:278
MBDynParser & MBPar
Definition: dataman.h:97
const char * psReadControlElems[]
Definition: enums.cc:122
void DestroyDriveData(void)
Definition: drive_.cc:3028
void InitUDE(void)
Definition: userelem.cc:107
void InitDriveData(void)
Definition: drive_.cc:3002
const doublereal dDefaultInitialAssemblyTol
Definition: dataman.cc:82
void OutputOpen(const OutputHandler::OutFiles out)
Definition: dataman.cc:677
struct DataManager::@30 DofData[DofOwner::LASTDOFTYPE]
double doublereal
Definition: colamd.c:52
int RegisterPlugIn(const char *name, MathParser::PlugIn *(*)(MathParser &, void *), void *arg)
Definition: mathp.cc:4584
void ElemDataInit(void)
Definition: elman.cc:248
long int integer
Definition: colamd.c:51
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
double Real
Definition: mathtyp.h:39
Table & GetSymbolTable(void) const
Definition: mathp.cc:1931
struct DataManager::ElemDataStructure ElemData[Elem::LASTELEMTYPE]
DataManager::ElemContainerType::const_iterator end(Elem::Type t) const
Definition: dataman.cc:908
#define DEBUGLCOUT(level, msg)
Definition: myassert.h:244
bool RestartOpen(bool openResXSol=false)
Definition: output.cc:563
virtual ~DataManager(void)
Definition: dataman.cc:618
void OutputFrames(std::ostream &out) const
Definition: mbpar.cc:1323
void InitGustData(void)
Definition: gust.cc:212
bool bOutputAccels
Definition: dataman.h:119
VectorHandler * pXCurr
Definition: dataman.h:108
bool bOutputAccelerations(void) const
Definition: dataman.cc:878
#define SAFEDELETE(pnt)
Definition: mynewmem.h:710
void ElemAssInit(void)
Definition: elman.cc:318
void DestroyUDE(void)
Definition: userelem.cc:134
const char * psDriveNames[]
Definition: enums.cc:351