MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
gauss.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/libraries/libmbutil/gauss.cc,v 1.23 2017/01/12 14:44:04 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 /* Punti di Gauss */
33 
34 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
35 
36 #include "gauss.h"
37 
38 
39 /* Dati dei punti */
40 const doublereal dGaussPnt[] = {
41  /* 1 point, 2nd order */ 0.000000000000000,
42  /* 2 point, 4th order */ -0.577350269189626, 0.577350269189626,
43  /* 3 point, 6th order */ -0.774596669241483, 0.000000000000000, 0.774596669241483,
44  /* 4 point, 8th order */ -0.861136311594053, -0.339981043584856, 0.339981043584856, 0.861136311594053,
45  /* 5 point, 10th order */ -0.906179845938664, -0.538469310105683, 0.000000000000000, 0.538469310105683, 0.906179845938664,
46  /* 6 point, 12th order */ -0.932469514203152, -0.661209386466264, -0.238619186083197, 0.238619186083197, 0.661209386466264, 0.932469514203152,
47  /* 7 point, 14th order */ -0.949107912342758, -0.741531185599394, -0.405845151377397, 0.000000000000000, 0.405845151377397, 0.741531185599394, 0.949107912342758,
48  /* 8 point, 16th order */ -0.960289856497536, -0.796666477413627, -0.525532409916329, -0.183434642495650, 0.183434642495650, 0.525532409916329, 0.796666477413627, 0.960289856497536,
49  /* 9 point, 18th order */ -0.968160239507626, -0.836031107326636, -0.613371432700590, -0.324253423403809, 0.000000000000000, 0.324253423403809, 0.613371432700591, 0.836031107326636, 0.968160239507626,
50  /* 10 point, 20th order */ -0.973906528517171, -0.865063366688985, -0.679409568299025, -0.433395394129247, -0.148874338981631, 0.148874338981631, 0.433395394129247, 0.679409568299024, 0.865063366688984, 0.973906528517172
51  /* 11 point, 22nd order */
52 };
53 
54 const doublereal dGaussWght[] = {
55  /* 1 point, 2nd order */ 2.000000000000000,
56  /* 2 point, 4nd order */ 1.000000000000000, 1.000000000000000,
57  /* 3 point, 6nd order */ 0.555555555555556, 0.888888888888889, 0.555555555555556,
58  /* 4 point, 8nd order */ 0.347854845137454, 0.652145154862546, 0.652145154862546, 0.347854845137454,
59  /* 5 point, 10nd order */ 0.236926885056189, 0.478628670499367, 0.568888888888889, 0.478628670499367, 0.236926885056189,
60  /* 6 point, 12th order */ 0.171324492379171, 0.360761573048139, 0.467913934572690, 0.467913934572690, 0.360761573048139, 0.171324492379171,
61  /* 7 point, 14th order */ 0.129484966168870, 0.279705391489277, 0.381830050505119, 0.417959183673469, 0.381830050505119, 0.279705391489277, 0.129484966168870,
62  /* 8 point, 16th order */ 0.101228536290376, 0.222381034453375, 0.313706645877887, 0.362683783378362, 0.362683783378362, 0.313706645877887, 0.222381034453375, 0.101228536290376,
63  /* 9 point, 18th order */ 0.081274388361575, 0.180648160694858, 0.260610696402935, 0.312347077040002, 0.330239355001259, 0.312347077040002, 0.260610696402936, 0.180648160694857, 0.081274388361575,
64  /* 10 point, 20th order */ 0.066671344308688, 0.149451349150581, 0.219086362515981, 0.269266719309996, 0.295524224714752, 0.295524224714752, 0.269266719309996, 0.219086362515982, 0.149451349150581, 0.066671344308688
65  /* 11 point, 22nd order */
66 };
67 
69  0.,
70  -1., 1.,
71  -1., 0., 1.,
72  -1., -.3333333333333333, .3333333333333333, 1.,
73  -1., -.5, 0., .5, 1.
74 };
75 
77  2.,
78  1., 1.,
79  .3333333333333333, 1.333333333333333, .3333333333333333,
80  .25, .75, .75, .25,
81  .1555555555555556, .7111111111111111, .2666666666666667,
82  .7111111111111111, .1555555555555556
83 };
84 
85 /* GaussData - begin */
86 
88 : NumIntData((iN < 1 ? 1 : (iN > 10 ? 10 : iN))), pdPnt(NULL), pdWght(NULL) {
89  ASSERT(iNum >= 1 && iNum <= 10);
90  integer i = iNum*(iNum-1)/2-1;
93 }
94 
95 
97 {
98  ASSERT(i > 0 && i <= iNum);
99  return pdPnt[i];
100 }
101 
102 
104 {
105  ASSERT(i > 0 && i <= iNum);
106  return pdWght[i];
107 }
108 
109 
111 {
112  ASSERT(i > 0 && i <= iNum);
113  return PntWght(pdPnt[i], pdWght[i]);
114 }
115 
116 
117 const doublereal* GaussData::pdGetPnt(void) const
118 {
119  return pdPnt+1;
120 }
121 
122 
124 {
125  return pdWght+1;
126 }
127 
128 /* GaussData - end */
129 
130 
131 /* TrapezoidData - begin */
132 
134 : NumIntData((iN < 1 ? 1 : (iN > 5 ? 5 : iN))), pdPnt(NULL), pdWght(NULL) {
135  integer i = iNum*(iNum-1)/2-1;
138 }
139 
140 
142 {
143  ASSERT(i > 0 && i <= iNum);
144  return pdPnt[i];
145 }
146 
147 
149 {
150  ASSERT(i > 0 && i <= iNum);
151  return pdWght[i];
152 }
153 
154 
156 {
157  ASSERT(i > 0 && i <= iNum);
158  return PntWght(pdPnt[i], pdWght[i]);
159 }
160 
161 
163 {
164  return pdPnt+1;
165 }
166 
167 
169 {
170  return pdWght+1;
171 }
172 
173 /* TrapezoidData - end */
174 
175 
176 /* GaussDataIterator - begin */
177 
179 : GaussData(iN), iCurr(1)
180 {
181  NO_OP;
182 }
183 
184 
186 {
187  ASSERT(i == 0 || i == 1);
188 
189  (integer&)iCurr = 1;
190  if(i == 0) {
191  return pdPnt[1];
192  }
193  /* if(i == 1) */
194  return pdWght[1];
195 }
196 
197 
199 {
200  (integer&)iCurr = 1;
201  return PntWght(pdPnt[1], pdWght[1]);
202 }
203 
204 
206 {
207  ASSERT(i == 0 || i == 1);
208 
209  (integer&)iCurr += 1;
210  if(iCurr > iNum) {
211  return flag(0);
212  }
213 
214  if(i == 0) {
215  d = pdPnt[iCurr];
216  } else /* if(i == 1) */ {
217  d = pdWght[iCurr];
218  }
219 
220  return flag(1);
221 }
222 
223 
225 {
226  ASSERT(iCurr >= 1 && iCurr <= iNum);
227 
228  return pdPnt[iCurr];
229 }
230 
231 
233 {
234  ASSERT(iCurr >= 1 && iCurr <= iNum);
235 
236  return pdWght[iCurr];
237 }
238 
239 
241 {
242  (integer&)iCurr += 1;
243  if(iCurr > iNum) {
244  return flag(0);
245  }
246 
247  PW = PntWght(pdPnt[iCurr], pdWght[iCurr]);
248 
249  return flag(1);
250 }
251 
252 /* GaussdataIterator - end */
253 
254 
255 /* NumIntIterator - begin */
256 
258 : iCurr(1), data(d)
259 {
260  NO_OP;
261 }
262 
263 
265 {
266  NO_OP;
267 }
268 
269 
271 {
272  ASSERT(i == 0 || i == 1);
273 
274  (integer&)iCurr = 1;
275  if(i == 0) {
276  return data.dGetPnt(1);
277  }
278  /* else if(i == 1) */
279  return data.dGetWght(1);
280 }
281 
282 
284 {
285  (integer&)iCurr = 1;
286  return PntWght(data.Get(1));
287 }
288 
289 
291 {
292  ASSERT(i == 0 || i == 1);
293 
294  (integer&)iCurr += 1;
295  if(iCurr > data.iGetNum()) {
296  return flag(0);
297  }
298 
299  if(i == 0) {
300  d = data.dGetPnt(iCurr);
301  } else /* if(i == 1) */ {
302  d = data.dGetWght(iCurr);
303  }
304 
305  return flag(1);
306 }
307 
308 
310 {
311  ASSERT(iCurr >= 1 && iCurr <= data.iGetNum());
312 
313  return data.dGetPnt(iCurr);
314 }
315 
316 
318 {
319  ASSERT(iCurr >= 1 && iCurr <= data.iGetNum());
320 
321  return data.dGetWght(iCurr);
322 }
323 
324 
326 {
327  (integer&)iCurr += 1;
328  if(iCurr > data.iGetNum()) {
329  return flag(0);
330  }
331 
332  PW = PntWght(data.Get(iCurr));
333 
334  return flag(1);
335 }
336 
337 /* NumIntIterator - end */
338 
339 
const doublereal *const pdWght
Definition: gauss.h:119
long int flag
Definition: mbdyn.h:43
const doublereal dTrapezoidWght[]
Definition: gauss.cc:76
virtual doublereal dGetPnt(integer i) const =0
const doublereal dGaussPnt[]
Definition: gauss.cc:40
flag fGetNext(doublereal &d, integer i=0) const
Definition: gauss.cc:205
virtual PntWght GetFirst(void) const
Definition: gauss.cc:283
PntWght GetFirst(void) const
Definition: gauss.cc:198
NumIntData & data
Definition: gauss.h:181
doublereal dGetWght(integer i) const
Definition: gauss.cc:103
const doublereal * pdGetPnt(void) const
Definition: gauss.cc:162
virtual PntWght Get(integer i) const =0
#define NO_OP
Definition: myassert.h:74
PntWght Get(integer i) const
Definition: gauss.cc:155
virtual flag fGetNext(doublereal &d, integer i=0) const
Definition: gauss.cc:290
const doublereal * pdGetPnt(void) const
Definition: gauss.cc:117
virtual ~NumIntIterator(void)
Definition: gauss.cc:264
doublereal dGetFirst(integer i=0) const
Definition: gauss.cc:185
const doublereal *const pdPnt
Definition: gauss.h:118
const doublereal dTrapezoidPnt[]
Definition: gauss.cc:68
const doublereal * pdGetWght(void) const
Definition: gauss.cc:123
doublereal dGetWght(integer i) const
Definition: gauss.cc:148
GaussData(integer iN)
Definition: gauss.cc:87
const doublereal * pdGetWght(void) const
Definition: gauss.cc:168
PntWght Get(integer i) const
Definition: gauss.cc:110
#define ASSERT(expression)
Definition: colamd.c:977
doublereal dGetCurrWght(void) const
Definition: gauss.cc:232
integer iCurr
Definition: gauss.h:180
GaussDataIterator(integer iN)
Definition: gauss.cc:178
doublereal dGetPnt(integer i) const
Definition: gauss.cc:141
doublereal dGetCurrPnt(void) const
Definition: gauss.cc:224
TrapezoidData(integer iN)
Definition: gauss.cc:133
integer iCurr
Definition: gauss.h:166
virtual integer iGetNum(void) const
Definition: gauss.h:96
NumIntIterator(NumIntData &d)
Definition: gauss.cc:257
doublereal dGetPnt(integer i) const
Definition: gauss.cc:96
virtual doublereal dGetFirst(integer i=0) const
Definition: gauss.cc:270
virtual doublereal dGetCurrPnt(void) const
Definition: gauss.cc:309
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
const doublereal *const pdWght
Definition: gauss.h:105
const doublereal dGaussWght[]
Definition: gauss.cc:54
const doublereal *const pdPnt
Definition: gauss.h:104
virtual doublereal dGetCurrWght(void) const
Definition: gauss.cc:317
integer iNum
Definition: gauss.h:92
virtual doublereal dGetWght(integer i) const =0
Definition: gauss.h:50