MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
schurmh.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/libraries/libmbmath/schurmh.cc,v 1.29 2017/01/12 14:43:54 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  * Copyright (C) 1999-2017
33  * Giuseppe Quaranta <quaranta@aero.polimi.it>
34  *
35  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
36  * via La Masa, 34 - 20156 Milano, Italy
37  * http://www.aero.polimi.it
38  *
39  */
40 
41 /* Schur Matrix Handler */
42 
43 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
44 
45 #include "schurmh.h"
46 
47 /* dimensioni */
48 integer
50 {
51  return LSize + ISize;
52 }
53 
54 integer
56 {
57  return LSize + ISize;
58 }
59 
60 /* Restituisce l'handler alla matrice B */
63 {
64  return pB;
65 }
66 
67 /* Setta l'handler alla matrice B */
68 void
70 {
71  pB = pBM;
72 }
73 
74 /* Restituisce il puntatore alla matrice C
75  * che e' un vettore doublereal contenente le righe in successione */
78 {
79  return pdC;
80 }
81 
82 SchurMatrixHandler::SchurMatrixHandler(int LocSize, int IntSize,
83  MatrixHandler* pBM, integer* pGlobToLoc, doublereal* pdEv)
84 : LSize(LocSize),
85 ISize(IntSize),
86 pB(pBM),
87 pE(0),
88 pdE(0),
89 pF(0),
90 pC(0),
91 pdC(0),
92 pGTL(pGlobToLoc),
93 bExtpdE(pdEv != 0 ? true : false)
94 {
95  if (!bExtpdE) {
97  pdEv = pdE;
98  }
99 
102  MyVectorHandler(LSize*ISize, pdEv));
103  SAFENEWARR(pdC, doublereal, ISize*ISize);
106  MyVectorHandler(ISize*ISize, pdC));
109  SpMapMatrixHandler(ISize, LSize));
110 
111 #ifdef DEBUG
112  IsValid();
113 #endif /* DEBUG */
114 }
115 
117 {
118  if (pE != 0) {
119  SAFEDELETE(pE);
120  }
121  if (pC != 0) {
122  SAFEDELETE(pC);
123  }
124  if (pF != 0) {
125  SAFEDELETE(pF);
126  }
127  if (!bExtpdE && pdE != 0) {
129  }
130  if (pdC != 0) {
132  }
133 }
134 
135 #ifdef DEBUG
136 /* Usata per il debug */
137 void
138 SchurMatrixHandler::IsValid(void) const
139 {
140  ASSERT(LSize >0);
141  ASSERT(ISize >0);
142  ASSERT(pB != 0);
143  ASSERT(pE != 0);
144  ASSERT(pF != 0);
145  ASSERT(pC != 0);
146  ASSERT(pGTL != 0);
147 }
148 #endif /* DEBUG */
149 
150 /* Ridimensiona la matrice */
151 void
153 {
154  silent_cerr("cannot resize a SchurMatrixHandler" << std::endl);
156 }
157 
158 /* SchurMatrixHandler - End */
159 
160 /* SchurVectorHandler - Start */
161 
162 SchurVectorHandler::SchurVectorHandler(int LocSize, int IntSize,
163  VectorHandler* pLocVec, integer* pGlobToLoc)
164 : LSize(LocSize),
165 ISize(IntSize),
166 pLV(pLocVec),
167 pIV(0),
168 bExtpIV(false),
169 pGTL(pGlobToLoc)
170 {
173  MyVectorHandler(IntSize));
174 }
175 
176 SchurVectorHandler::SchurVectorHandler(int LocSize, int IntSize,
177  VectorHandler* pLocV, VectorHandler* pIntV,
178  integer* pGlobToLoc)
179 : LSize(LocSize),
180 ISize(IntSize),
181 pLV(pLocV),
182 pIV(pIntV),
183 bExtpIV(pIntV != 0 ? true : false),
184 pGTL(pGlobToLoc)
185 {
186  NO_OP;
187 }
188 
189 
191 {
192  if (!bExtpIV && pIV != 0) {
193  SAFEDELETE(pIV);
194  }
195 }
196 
197 #ifdef DEBUG
198 /* Usata per il debug */
199 void
200 SchurVectorHandler::IsValid(void) const
201 {
202  NO_OP;
203 }
204 #endif /* DEBUG */
205 
206 /* SchurVectorHandler - End */
207 
208 
209 /* SchurMatrixHandlerUm - Begin */
210 
212  MatrixHandler* pBM,
213  integer* pGlobToLoc)
214 : SchurMatrixHandler(LocSize, IntSize, pBM, pGlobToLoc, 0),
215 pdEs(0),
216 pEs(0),
217 Eflag(1)
218 {
220  pdE = pdEs + LSize;
221  pE->Attach(LSize*ISize, pdE, LSize*ISize);
224  MyVectorHandler(LSize*ISize, pdEs));
225 }
226 
228 {
229  if (pE != 0) {
230  SAFEDELETE(pE);
231  }
232 
233  if (pdEs != 0) {
235  }
236 
237  pdE = 0;
238 }
239 
240 /* SchurMatrixHandlerUm - End */
241 
integer ISize
Definition: schurmh.h:60
doublereal * GetCMat(void)
Definition: schurmh.cc:77
SchurMatrixHandler(int LocSize, int IntSize, MatrixHandler *pBM, integer *pGlobToLoc, doublereal *pdEv=0)
Definition: schurmh.cc:82
SpMapMatrixHandler * pF
Definition: schurmh.h:64
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
MatrixHandler * GetBMat(void)
Definition: schurmh.cc:62
doublereal * pdE
Definition: schurmh.h:63
integer * pGTL
Definition: schurmh.h:72
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
doublereal * pdEs
Definition: schurmh.h:780
virtual void Resize(integer, integer)
Definition: schurmh.cc:152
#define NO_OP
Definition: myassert.h:74
virtual ~SchurMatrixHandler(void)
Definition: schurmh.cc:116
virtual integer iGetNumRows(void) const
Definition: schurmh.cc:49
~SchurMatrixHandlerUm(void)
Definition: schurmh.cc:227
MyVectorHandler * pC
Definition: schurmh.h:65
SchurMatrixHandlerUm(int LocSize, int IntSize, MatrixHandler *pBM, integer *pGlobToLoc)
Definition: schurmh.cc:211
Definition: mbdyn.h:76
virtual integer iGetNumCols(void) const
Definition: schurmh.cc:55
Definition: mbdyn.h:77
MyVectorHandler * pEs
Definition: schurmh.h:781
#define ASSERT(expression)
Definition: colamd.c:977
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
MyVectorHandler * pE
Definition: schurmh.h:62
doublereal * pdC
Definition: schurmh.h:66
MatrixHandler * pB
Definition: schurmh.h:61
void SetBMat(MatrixHandler *pBM)
Definition: schurmh.cc:69
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
VectorHandler * pIV
Definition: schurmh.h:512
void Attach(integer iSize, doublereal *pd, integer iMSize=0)
Definition: vh.cc:418
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
integer LSize
Definition: schurmh.h:60
SchurVectorHandler(int LocSize, int IntSize, VectorHandler *pLocVec, integer *pGlobToLoc)
Definition: schurmh.cc:162
#define SAFEDELETE(pnt)
Definition: mynewmem.h:710
~SchurVectorHandler(void)
Definition: schurmh.cc:190