MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
dofman.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/dofman.cc,v 1.33 2017/01/12 14:46:09 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 /* dof manager */
33 
34 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
35 
36 #include "dataman.h"
37 
38 /* DataManager - begin */
39 
41 {
44 
45  /* Resetta la struttura statica */
46  for(int i = 0; i < DofOwner::LASTDOFTYPE; i++) {
47  DofData[i].pFirstDofOwner = NULL;
48  DofData[i].iNum = 0;
49  DofData[i].iSize = 0;
50  DofData[i].dDefScale = 1.;
51  }
52 }
53 
54 
55 void
57 {
58  DEBUGCOUTFNAME("DataManager::DofManagerDestructor");
59 
60  // TODO: remove?
61 }
62 
65 {
66  return DofData[t].dDefScale;
67 }
68 
70 {
71  /* struttura dei DofOwner */
72 
73  /* Calcola il numero totale di DofOwner */
74  for (int iCnt = 0; iCnt < DofOwner::LASTDOFTYPE; iCnt++) {
75  iTotDofOwners += DofData[iCnt].iNum;
76  }
77 
78  DEBUGLCOUT(MYDEBUG_INIT, "iTotDofOwners = " << iTotDofOwners << std::endl);
79 
80  /* Crea la struttura dinamica dei DofOwner */
81  if (iTotDofOwners > 0) {
82  DofOwners.resize(iTotDofOwners);
83 
84  /* Resetta la struttura dinamica dei DofOwner */
85  for (int iCnt = 0; iCnt < iTotDofOwners; iCnt++) {
86  DofOwners[iCnt].iFirstIndex = 0;
87  DofOwners[iCnt].iNumDofs = 0;
88  }
89 
90  /* Inizializza la struttura dinamica dei DofOwner
91  * con il numero di Dof di ognuno */
92  DofData[0].pFirstDofOwner = &DofOwners[0];
93  for (int iType = 0; iType < DofOwner::LASTDOFTYPE - 1; iType++) {
94  DofData[iType + 1].pFirstDofOwner =
95  DofData[iType].pFirstDofOwner+
96  DofData[iType].iNum;
97 
98  for (int iDof = 0; iDof < DofData[iType].iNum; iDof++) {
99  DofData[iType].pFirstDofOwner[iDof].SetScale(dGetDefaultScale(DofOwner::Type(iType)));
100  }
101  }
102 
103  } else {
104  /* Se non sono definiti DofOwners, la simulazione non ha senso,
105  * quindi il programma termina */
106  silent_cerr("warning, no dof owners are defined" << std::endl);
107  throw NoErr(MBDYN_EXCEPT_ARGS);
108  }
109 }
110 
112 {
113  if (iTotDofOwners > 0) {
114 
115  /* Di ogni DofOwner setta il primo indice
116  * e calcola il numero totale di Dof */
117  integer iIndex = 0; /* contatore dei Dof */
118  integer iNumDofs = 0; /* numero di dof di un owner */
119 
120  for (int iCnt = 0; iCnt < iTotDofOwners; iCnt++) {
121  iNumDofs = DofOwners[iCnt].iNumDofs;
122  if (iNumDofs > 0) {
123  DofOwners[iCnt].iFirstIndex = iIndex;
124  iIndex += iNumDofs;
125  } else {
126  DofOwners[iCnt].iFirstIndex = -1;
127  DEBUGCERR("warning, item " << (iCnt + 1) << " has 0 dofs" << std::endl);
128  }
129  }
130 
131  iTotDofs = iIndex;
132 
133  DEBUGLCOUT(MYDEBUG_INIT, "iTotDofs = " << iTotDofs << std::endl);
134  } else {
135  DEBUGCERR("");
136  silent_cerr("no dof owners are defined" << std::endl);
137 
139  }
140 
141 
142  /* Crea la struttura dinamica dei Dof */
143  if(iTotDofs > 0) {
144  Dofs.resize(iTotDofs);
145  integer iIndex = DofOwners[0].iFirstIndex;
146  for (DofIterator i = Dofs.begin(); i != Dofs.end(); ++i) {
147  i->iIndex = iIndex++;
148  i->Order = DofOrder::DIFFERENTIAL;
149  }
150  } else {
151  DEBUGCERR("");
152  silent_cerr("no dofs are defined" << std::endl);
153 
155  }
156 }
157 
158 void
160 {
161  for (integer iCnt = 0; iCnt < iTotDofOwners; iCnt++) {
162  integer iFirstIndex = DofOwners[iCnt].iFirstIndex;
163  unsigned int iNumDofs = DofOwners[iCnt].iNumDofs;
164  doublereal dScale = DofOwners[iCnt].dScale;
165 
166  for (unsigned int iDof = 1; iDof <= iNumDofs; iDof++) {
167  XScale.PutCoef(iFirstIndex + iDof, dScale);
168  }
169  }
170 }
171 
172 /* DataManager - end */
void SetScale(VectorHandler &XScale) const
Definition: dofman.cc:159
integer iTotDofOwners
Definition: dataman.h:795
DofVecType::iterator DofIterator
Definition: dataman.h:803
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
#define DEBUGCOUTFNAME(fname)
Definition: myassert.h:256
unsigned int iNumDofs
Definition: dofown.h:95
DofVecType Dofs
Definition: dataman.h:813
DofOwner DummyDofOwner
Definition: dataman.h:815
void DofManagerDestructor(void)
Definition: dofman.cc:56
doublereal dGetDefaultScale(DofOwner::Type t) const
Definition: dofman.cc:64
#define DEBUGCERR(msg)
Definition: myassert.h:235
integer iFirstIndex
Definition: dofown.h:94
std::vector< DofOwner > DofOwners
Definition: dataman.h:796
void DofDataInit(void)
Definition: dofman.cc:69
integer iTotDofs
Definition: dataman.h:809
void DofInit(void)
Definition: dofman.cc:111
virtual void PutCoef(integer iRow, const doublereal &dCoef)=0
Definition: except.h:79
void DofManager(void)
Definition: dofman.cc:40
struct DataManager::@30 DofData[DofOwner::LASTDOFTYPE]
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
#define DEBUGLCOUT(level, msg)
Definition: myassert.h:244