CONFIG LIB 1.5
Configuration Files Library (by TGG 2020)
Loading...
Searching...
No Matches
panukl_struct.cpp
1/*********************************************************************/
2/* */
3/* Panukl package - (C) TGG 2002 */
4/* */
5/*********************************************************************/
6/* Warszawa, 2002 */
7/*********************************************************************/
8/* */
9/* File: PanuklGlobalStruct.cpp */
10/* */
11/* Author: T.Grabowski */
12/* */
13/* Contents - structures definitions */
14/* */
15/* */
16/*********************************************************************/
17/* */
18/* */
19
20#include <iostream>
21#include <sstream>
22#include <string>
23#include <fstream>
24
25#include "panukl_struct.h"
26
27using namespace std;
28
36
38 {
39
40 DELETE_TAB( dX );
41 DELETE_TAB( dXw );
43
46 DELETE_TAB( iKw );
47
51
52 DELETE_TAB( dXp );
53 DELETE_TAB( dYp );
54 DELETE_TAB( dZp );
55 DELETE_TAB( dQx );
56 DELETE_TAB( dQy );
57 DELETE_TAB( dQz );
59
61 DELETE_TAB( dX0 );
62 DELETE_TAB( dY0 );
63 DELETE_TAB( dZ0 );
64 DELETE_TAB( dAlf1 );
65 DELETE_TAB( dAlf2 );
66 DELETE_TAB( dAlf3 );
67 DELETE_TAB( dBet1 );
68 DELETE_TAB( dBet2 );
69 DELETE_TAB( dBet3 );
70 DELETE_TAB( dGam1 );
71 DELETE_TAB( dGam2 );
72 DELETE_TAB( dGam3 );
73
74 DELETE_TAB( dAi );
76 DELETE_TAB( dRh );
78
87
98
99 DELETE_TAB( dZzz );
100 DELETE_TAB( dObr );
101 DELETE_TAB( dCpb );
102 }
103
104//
105// Array element order (according to Fortran standard)
106//
107// A3(n,m,l) = A(n*m*l)
108// A3(i,j,k) = A(fortran)( n*m * k(k-1) + n * j(j-1) + i )
109//
110// A2(n,m) = A(n*m)
111// A2(i,j) = A(fortran)( n * j(j-1) + i )
112//
113//
114//
115
116void GRID_ARRAYS::DeleteINP( void )
117{
118 DELETE_TAB( dX );
120 DELETE_TAB( dXkw );
121 DELETE_TAB( iNkw );
122 DELETE_TAB( iKw );
123 Points.clear();
124 Panels.clear();
125}
126
128{
129 for(int j=0; j<(int)Points.size(); j++ )
130 {
131 if( Points[j] == *P )
132 {
133 *iD = j;
134 return;
135 }
136 }
137
138 Points.push_back( *P );
139 *iD = Points.size()-1;
140}
141
143{
144 Points.clear();
145 for(int i=0; i<iN; i++)
146 {
147 Corner2Points( &Panels[i].IdP1, &Panels[i].P1 );
148 Corner2Points( &Panels[i].IdP2, &Panels[i].P2 );
149 Corner2Points( &Panels[i].IdP3, &Panels[i].P3 );
150 Corner2Points( &Panels[i].IdP4, &Panels[i].P4 );
151 }
152}
153
155{
156 for( int i=0; i<iMaxPanelNumber; i++ )
157 {
158 dX[ i ] = Panels[i].P1.x;
159 dX[ iMaxPanelNumber*4 + i ] = Panels[i].P1.y;
160 dX[ iMaxPanelNumber*8 + i ] = Panels[i].P1.z;
161
162 dX[ iMaxPanelNumber + i ] = Panels[i].P2.x;
163 dX[ iMaxPanelNumber*4 + iMaxPanelNumber + i ] = Panels[i].P2.y;
164 dX[ iMaxPanelNumber*8 + iMaxPanelNumber + i ] = Panels[i].P2.z;
165
166 dX[ iMaxPanelNumber*2 + i ] = Panels[i].P3.x;
167 dX[ iMaxPanelNumber*4 + iMaxPanelNumber*2 + i ] = Panels[i].P3.y;
168 dX[ iMaxPanelNumber*8 + iMaxPanelNumber*2 + i ] = Panels[i].P3.z;
169
170 dX[ iMaxPanelNumber*3 + i ] = Panels[i].P4.x;
171 dX[ iMaxPanelNumber*4 + iMaxPanelNumber*3 + i ] = Panels[i].P4.y;
172 dX[ iMaxPanelNumber*8 + iMaxPanelNumber*3 + i ] = Panels[i].P4.z;
173 }
174}
175
177{
178 Panels.clear();
179 PANEL Panel;
180 for( int i=0; i<iMaxPanelNumber; i++ )
181 {
182 Panel.P1.x = dX[ i ];
183 Panel.P1.y = dX[ iMaxPanelNumber*4 + i ];
184 Panel.P1.z = dX[ iMaxPanelNumber*8 + i ];
185
186 Panel.P2.x = dX[ iMaxPanelNumber + i ];
187 Panel.P2.y = dX[ iMaxPanelNumber*4 + iMaxPanelNumber + i ];
188 Panel.P2.z = dX[ iMaxPanelNumber*8 + iMaxPanelNumber + i ];
189
190 Panel.P3.x = dX[ iMaxPanelNumber*2 + i ];
191 Panel.P3.y = dX[ iMaxPanelNumber*4 + iMaxPanelNumber*2 + i ];
192 Panel.P3.z = dX[ iMaxPanelNumber*8 + iMaxPanelNumber*2 + i ];
193
194 Panel.P4.x = dX[ iMaxPanelNumber*3 + i ];
195 Panel.P4.y = dX[ iMaxPanelNumber*4 + iMaxPanelNumber*3 + i ];
196 Panel.P4.z = dX[ iMaxPanelNumber*8 + iMaxPanelNumber*3 + i ];
197
198 Panels.push_back( Panel );
199 }
200}
201
203{
204 for( int i=0; i<iN; i++ )
205 {
206 Panels[i].P1 = Points[ Panels[i].IdP1 ];
207 Panels[i].P2 = Points[ Panels[i].IdP2 ];
208 Panels[i].P3 = Points[ Panels[i].IdP3 ];
209 Panels[i].P4 = Points[ Panels[i].IdP4 ];
210 }
211}
212
213int GRID_ARRAYS::ReadINP( char *FileName )
214{
215 FILE *File;
216 File = fopen( FileName, "r" );
217 if( File == NULL )
218 {
219 fprintf( stderr, "[.INP] file open error (%s)\n", FileName );
220 return (-1);
221 }
222
223 DeleteINP();
224
226
227 char cRob[256], cc[10];
228 int iReturn;
229 ReadStr( File, cRob );
230 if( !strncmp( cRob, "PANELS", 6 ) )
231 {
232 fscanf( File," %s %f %d", cc, &fVer, &iSym );
233 iReturn = ReadIN1( File );
234 }
235 else if ( !strncmp( cRob, "POINTS", 6 ) )
236 {
237 fscanf( File," %s %f %d", cc, &fVer, &iSym );
238 iReturn = ReadIN2( File );
239 }
240 else if ( !strncmp( cRob, "ver", 3 ) )
241 {
242 sscanf( cRob," %s %f %d", cc, &fVer, &iSym );
243 iReturn = ReadIN1( File );
244 }
245 else
246 {
247 rewind( File );
248 iSym = 99;
249 iReturn = ReadIN1( File );
250 }
251
253 ReadPar( File, "%d", &iMaxBodyNeighbours_rob );
257 NEW_TAB( iKw, int, iMaxBodyNeighbours*3 );
258
259 for( int i=0; i<3; i++ ) iKw[i] = 0;
260
261 for( int k=0; k<iMaxBodyNeighbours_rob; k++ )
262 {
263 for( int i=0; i<3; i++ ) fscanf( File, "%d", &iKw[ iMaxBodyNeighbours*i + k ] );
264 for( int i=0; i<iKw[ k ]; i++ )
265 {
266 for( int j=0; j<3; j++ ) fscanf( File, "%lf", &dXkw[ iMaxWakePanelNumber*3*k + iMaxWakePanelNumber*j + i ] );
267 fscanf( File, "%d", &iNkw[ iMaxWakePanelNumber*k + i ] );
268 }
269 }
270
271 ReadObjs( File );
272
273 fclose( File );
274
275 return iReturn;
276}
277
278int GRID_ARRAYS::ReadIN1( FILE *File )
279{
280 fscanf( File, " %d %lf %lf %lf %lf %lf %lf",
282
283 NEW_TAB( dX, double, iMaxPanelNumber * 4 * 3 );
284 NEW_TAB( iNeigh, int, iMaxPanelNumber * 8 );
285
286 int iRob;
287 for( int i=0; i<iMaxPanelNumber; i++ )
288 {
289 fscanf( File, "%d", &iRob );
290 for( int j=0; j<4; j++ )
291 for( int k=0; k<3; k++ )
292 fscanf( File, "%lf", &dX[ iMaxPanelNumber*4*k + iMaxPanelNumber*j + i ] );
293 }
294
295 Array2Panels();
297
298 return(0);
299}
300
301int GRID_ARRAYS::ReadIN2( FILE *File )
302{
303 int iMaxPoints;
304 fscanf( File, " %d %d %lf %lf %lf %lf %lf %lf",
306
307 NEW_TAB( dX, double, iMaxPanelNumber * 4 * 3 );
308 NEW_TAB( iNeigh, int, iMaxPanelNumber * 8 );
310
311 int iRob;
313 Points.clear();
314 for( int i=0; i<iMaxPoints; i++ )
315 {
316 fscanf (File,"%d ",&iRob);
317 fscanf (File, "%lf %lf %lf", &Point.x, &Point.y, &Point.z );
318 Points.push_back( Point );
319 }
320
321 PANEL Panel;
322 for( int i=0; i<iMaxPanelNumber; i++ )
323 {
324 fscanf (File,"%d ",&iRob);
325 fscanf (File, "%d %d %d %d", &Panel.IdP1, &Panel.IdP2, &Panel.IdP3, &Panel.IdP4 );
326 Panels.push_back( Panel );
327 }
328
330 Panels2Array();
331
332 return(0);
333}
334
335int GRID_ARRAYS::WriteInpFromPanels( char *FileName, int iScale )
336{
337 FILE *File;
338 File = fopen( FileName, "w" );
339 if( File == NULL )
340 {
341 fprintf( stderr, "[.INP] file open error (%s)\n", FileName );
342 return (-1);
343 }
344
345 fprintf( File, "PANELS\n");
346 fprintf( File, "ver %5.2f %d\n", fVer, iSym );
347
348 double dScale = iScale ? 1. : dWsp_sk;
349
350 fprintf( File, " %5d %10.4f %10.4f %10.4f %10.4f %10.4f %10.4f\n",
352
353 PANEL rob;
354 for( int i=0; i<(int)Panels.size(); i++ )
355 {
356 fprintf (File,"%5d ",i+1);
357 rob.PutTo( Panels[i].P1*dWsp_sk, Panels[i].P2*dWsp_sk, Panels[i].P3*dWsp_sk, Panels[i].P4*dWsp_sk );
358 rob.Vout(File);
359 fprintf (File,"\n");
360 }
361
362 fprintf( File, "%d\n", iMaxBodyNeighbours );
363
364 for( int k=0; k<iMaxBodyNeighbours; k++ )
365 {
366 for( int i=0; i<3; i++ ) fprintf( File, "%d ", iKw[ iMaxBodyNeighbours*i + k ] );
367 fprintf( File, "\n" );
368 for( int i=0; i<iKw[ k ]; i++ )
369 {
370 for( int j=0; j<3; j++ ) fprintf( File, "%12.7f ", dXkw[ iMaxWakePanelNumber*3*k + iMaxWakePanelNumber*j + i ]*dWsp_sk );
371 fprintf( File, "%d\n", iNkw[ iMaxWakePanelNumber*k + i ] );
372 }
373 }
374
375 WriteObjs( File );
376 fclose( File );
377
378 return 0;
379}
380
381int GRID_ARRAYS::WriteInpFromPoints( char *FileName, int iScale )
382{
383 FILE *File;
384 File = fopen( FileName, "w" );
385 if( File == NULL )
386 {
387 fprintf( stderr, "[.INP] file open error (%s)\n", FileName );
388 return (-1);
389 }
390
391 fprintf( File, "POINTS\n");
392 fprintf( File, "ver %5.2f %d\n", fVer, iSym );
393
394 double dScale = iScale ? 1. : dWsp_sk;
395
396 fprintf( File, " %5d %5d %10.4f %10.4f %10.4f %10.4f %10.4f %10.4f\n",
397 iMaxPanelNumber, (int)Points.size(), dSS, dCa, dBs, dXca25, dZca25, dScale );
398
400 for( int i=0; i<(int)Points.size(); i++ )
401 {
402 fprintf (File,"%5d ",i+1);
403 rob = Points[i]*dWsp_sk;
404 vout( File, rob );
405 fprintf (File,"\n");
406 }
407
408 for( int i=0; i<(int)Panels.size(); i++ )
409 {
410 fprintf (File,"%5d ",i+1);
411 Panels[i].Iout(File);
412 fprintf (File,"\n");
413 }
414
415 fprintf( File, "%d\n", iMaxBodyNeighbours );
416
417 for( int k=0; k<iMaxBodyNeighbours; k++ )
418 {
419 for( int i=0; i<3; i++ ) fprintf( File, "%d ", iKw[ iMaxBodyNeighbours*i + k ] );
420 fprintf( File, "\n" );
421 for( int i=0; i<iKw[ k ]; i++ )
422 {
423 for( int j=0; j<3; j++ ) fprintf( File, "%12.7f ", dXkw[ iMaxWakePanelNumber*3*k + iMaxWakePanelNumber*j + i ]*dWsp_sk );
424 fprintf( File, "%d\n", iNkw[ iMaxWakePanelNumber*k + i ] );
425 }
426 }
427
428 WriteObjs( File );
429 fclose( File );
430
431 return 0;
432}
433
434int GRID_ARRAYS::ReadObjs( FILE *File )
435{
436 Objs.clear();
437 return ReadObjs( File, Objs, 0, fVer );
438}
439
440int GRID_ARRAYS::ReadObjs( FILE *File, vector<MS2_OBJ> &Objs, int N1, float fVer )
441{
442 int iNobj = 0;
443 int iRet = ReadPar( File, "%d", &iNobj );
444 if( iRet == EOF || iNobj <= 0 )return 0;
445
446 char name[200];
447 MS2_OBJ rob;
448
449// Objs.clear();
450
451 for( int i=0; i<iNobj; i++ )
452 {
453 if(fVer < 4.)
454 fscanf( File, "%d %d", &rob.n1, &rob.n2 );
455 else
456 fscanf( File, "%d %d %d %d %d %d %d %d %d", &rob.n1, &rob.n2, &rob.ID, &rob.iType,
457 &rob.SurfType, &rob.RibNr, &rob.iClosingRib, &rob.DivNo, &rob.DivType );
458 rob.n1 += N1;
459 rob.n2 += N1;
460 ReadStr( File, name );
461 rob.Name = string( name );
462 Objs.push_back( rob );
463 }
464
465 return iNobj;
466}
467
468int GRID_ARRAYS::ReadObjs( ifstream &f, vector<MS2_OBJ> &Objs, int N1, float fVer )
469{
470 int iNobj = 0;
471 f >> iNobj;
472 if( f.eof() || iNobj <= 0 )return 0;
473
474 MS2_OBJ rob;
475
476// Objs.clear();
477
478 for( int i=0; i<iNobj; i++ )
479 {
480 if(fVer < 4.)
481 f >> rob.n1 >> rob.n2;
482 else
483 f >> rob.n1 >> rob.n2 >> rob.ID >> rob.iType >> rob.SurfType >> rob.RibNr >> rob.iClosingRib >> rob.DivNo >> rob.DivType;
484 rob.n1 += N1;
485 rob.n2 += N1;
486 getline( f, rob.Name );
487 Objs.push_back( rob );
488 }
489
490 return iNobj;
491}
492
493void GRID_ARRAYS::WriteObjs( FILE *File )
494{
495 WriteObjs( File, Objs );
496}
497
498void GRID_ARRAYS::WriteObjs( FILE *File, std::vector<MS2_OBJ> &Objs )
499{
500#ifdef x86_64
501 #ifdef Linux
502 fprintf( File, " %5lu\n", Objs.size() );
503 #else
504 fprintf( File, " %5llu\n", Objs.size() );
505 #endif
506#else
507 fprintf( File, " %5d\n", Objs.size() );
508#endif
509 for( int i=0; i<(int)Objs.size(); i++ )
510 fprintf( File, "%5d %5d %5d %5d %5d %5d %5d %5d %5d %s\n",
511 Objs[i].n1, Objs[i].n2, Objs[i].ID, Objs[i].iType,
512 Objs[i].SurfType, Objs[i].RibNr, Objs[i].iClosingRib,
513 Objs[i].DivNo, Objs[i].DivType, Objs[i].Name.c_str() );
514}
515
516void GRID_ARRAYS::DeleteDAT( void )
517{
518 DELETE_TAB( dX );
520 DELETE_TAB( iNnww );
521 DELETE_TAB( iIpas );
522}
523
524int GRID_ARRAYS::ReadDAT( char *FileName, int iProg )
525{
526 FILE *File;
527 File = fopen( FileName, "r" );
528 if( File == NULL )
529 {
530 fprintf( stderr, "[.DAT] file open error (%s)\n", FileName );
531 return (-1);
532 }
533
534 DeleteDAT();
535
537
538 char cRob[256];
539 ReadStr( File, cRob );
540 if( !strncmp( cRob, "ver", 3 ) )
541 {
542 char cc[10];
543 sscanf( cRob," %s %f %d", cc, &fVer, &iSym );
544 fscanf( File, " %d %d %d %lf %lf %lf %lf %lf",
546 }
547 else
548 {
549 sscanf( cRob, " %d %d %d %lf %lf %lf %lf %lf",
551 iSym = 99;
552 }
553
555
556 iNw = iN + iLiczw; // samolot + slad (gora) (1 panel/pasmo)
557 iNw2 = iNw + iLiczw; // samolot + slad (gora+dol) (1 panel/pasmo)
558 iNww = iN + iLiczp; // samolot + slad (gora)
559 iNww2 = iNww + iLiczw; // j.w. + dol sladu (1 panel/pasmo)
560
561 NEW_TAB( dX, double, iNww2 * 4 * 3 );
562 NEW_TAB( iNeigh, int, iNww2 * 8 );
563
564 int iRob;
565 for( int i=0; i<iN; i++ )
566 {
567 fscanf( File, "%d", &iRob );
568 for( int j=0; j<4; j++ )
569 for( int k=0; k<3; k++ )
570 fscanf( File, "%lf", &dX[ iNww2*4*k + iNww2*j + i ] );
571 }
572
573 ReadPar( File, "%d", &iLiczp );
574 NEW_TAB( iNnww, int, iLiczw * 5 );
576
577 for( int i=iN; i<iN+iLiczp; i++ )
578 {
579 fscanf( File, "%d", &iRob );
580 for( int j=0; j<4; j++ )
581 for( int k=0; k<3; k++ )
582 fscanf( File, "%lf", &dX[ iNww2*4*k + iNww2*j + i ] );
583 }
584
585 for( int i=0; i<iN; i++ )
586 {
587 fscanf( File, "%d", &iRob );
588 for( int j=0; j<8; j++ ) fscanf( File, "%d", &iNeigh[ iNww2*j + i ] );
589 }
590
591 for( int i=0; i<iLiczw; i++ )
592 {
593 fscanf( File, "%d", &iRob );
594 fscanf( File, "%d", &iNnww[ i ]);
595 fscanf( File, "%d", &iNnww[ iLiczw + i ]);
596 fscanf( File, "%d", &iNnww[ iLiczw*2 + i ]);
597 for( int j=0; j<iNnww[iLiczw*2+i]+1; j++ )
598 fscanf( File, "%d", &iIpas[ iLiczw*j + i ] );
599 }
600
601 ReadObjs( File );
602
603 fclose( File );
604
605 if( iProg == 1 )
607 else if( iProg == 2 )
608 InitForPress();
609
610 dWsp_sk = 1.;
611
612 return(0);
613}
614
615void GRID_ARRAYS::DeleteDATw( void )
616{
617 DELETE_TAB( dX );
619 DELETE_TAB( dXw );
620
622 DELETE_TAB( iIpas );
623 DELETE_TAB( iNpas );
624}
625
626int GRID_ARRAYS::ReadDATw( char *FileName )
627{
628 FILE *File;
629 File = fopen( FileName, "r" );
630 if( File == NULL )
631 {
632 fprintf( stderr, "[.DAT] file open error (%s)\n", FileName );
633 return (-1);
634 }
635
636 DeleteDATw();
637
639
640 char cRob[256];
641 ReadStr( File, cRob );
642 if( !strncmp( cRob, "ver", 3 ) )
643 {
644 char cc[10];
645 sscanf( cRob," %s %f %d", cc, &fVer, &iSym );
646 fscanf( File, " %d %d %d %lf %lf %lf %lf %lf",
648 }
649 else
650 sscanf( cRob, " %d %d %d %lf %lf %lf %lf %lf",
652
654
655 NEW_TAB( dX, double, iMaxPanelNumber * 4 * 3 );
656 NEW_TAB( iNeigh, int, iMaxPanelNumber * 8 );
657
658 int iRob;
659 for( int i=0; i<iMaxPanelNumber; i++ )
660 {
661 fscanf( File, "%d", &iRob );
662 for( int j=0; j<4; j++ )
663 for( int k=0; k<3; k++ )
664 fscanf( File, "%lf", &dX[ iMaxPanelNumber*4*k + iMaxPanelNumber*j + i ] );
665 }
666
667 ReadPar( File, "%d", &iLiczp );
668 InitRob();
669
671 for( int i=0; i<iLiczp; i++ )
672 {
673 fscanf( File, "%d", &iRob );
674 for( int j=0; j<4; j++ )
675 for( int k=0; k<3; k++ )
676 fscanf( File, "%lf", &dXw[ iMaxWP*4*k + iMaxWP*j + i ] );
677 }
678
679 for( int i=0; i<iMaxPanelNumber; i++ )
680 {
681 fscanf( File, "%d", &iRob );
682 for( int j=0; j<8; j++ ) fscanf( File, "%d", &iNeigh[ iMaxPanelNumber*j + i ] );
683 }
684
685 for( int i=0; i<iLiczw; i++ )
686 {
687 fscanf( File, "%d", &iRob );
688 fscanf( File, "%d", &iNnww[ i ]);
689 fscanf( File, "%d", &iNnww[ iMaxWakesNumber + i ]);
690 fscanf( File, "%d", &iNpas[ i ]);
691 for( int j=0; j<iNpas[i]+1; j++ )
692 fscanf( File, "%d", &iIpas[ iMaxWakesNumber*j + i ] );
693 }
694
695 ReadObjs( File );
696
697 fclose( File );
698
699 dWsp_sk = 1.;
700
701 return(0);
702}
703
704int GRID_ARRAYS::WriteDAT( char *FileName )
705{
706 FILE *File;
707 File = fopen( FileName, "w" );
708 if( File == NULL )
709 {
710 fprintf( stderr, "[.DAT] file open error (%s)\n", FileName );
711 return (-1);
712 }
713
714 fprintf( File, "ver %f %d\n", fVer, iSym );
715
716 fprintf( File, " %5d %5d %5d %10.4f %10.4f %10.4f %10.4f %10.4f\n",
718
719 for( int i=0; i<iMaxPanelNumber; i++ )
720 {
721 fprintf( File, " %4d", i+1 );
722 for( int j=0; j<4; j++ )
723 for( int k=0; k<3; k++ )
724 fprintf( File, " %12.7f", dX[ iMaxPanelNumber*4*k + iMaxPanelNumber*j + i ] );
725 fprintf( File, "\n" );
726 }
727
728 fprintf( File, " %d\n", iLiczp );
729
731 for( int i=0; i<iLiczp; i++ )
732 {
733 fprintf( File, " %4d", i+iMaxPanelNumber+1 );
734 for( int j=0; j<4; j++ )
735 for( int k=0; k<3; k++ )
736 fprintf( File, " %12.7f", dXw[ iRob*4*k + iRob*j + i ] );
737 fprintf( File, "\n" );
738 }
739
740 for( int i=0; i<iMaxPanelNumber; i++ )
741 {
742 fprintf( File, " %5d", i+1 );
743 for( int j=0; j<8; j++ ) fprintf( File, " %5d", iNeigh[ iMaxPanelNumber*j + i ] );
744 fprintf( File, "\n" );
745 }
746
747 for( int i=0; i<iLiczw; i++ )
748 {
749 fprintf( File, " %5d", i+1 );
750 fprintf( File, " %5d", iNnww[ i ]);
751 fprintf( File, " %5d", iNnww[ iMaxWakesNumber + i ]);
752 fprintf( File, " %5d", iNpas[ i ]);
753 for( int j=0; j<iNpas[i]+1; j++ )
754 fprintf( File, " %5d", iIpas[ iMaxWakesNumber*j + i ] );
755 fprintf( File, "\n" );
756 }
757
758 WriteObjs( File );
759
760 fclose( File );
761
762 return(0);
763}
764
765int GRID_ARRAYS::ReadWyn( char *FileName )
766{
767 DeleteWyn();
768
769 FILE *f = fopen( FileName, "r" );
770 if( f == NULL )return( -1 );
771
774
775 ReadComm( f );
776 int N, NN = 0;
777 do
778 {
779 N = 0;
780 ReadPar( f, "%d", &N );
781 if( N ) NN = N;
782 }
783 while( N > 0 );
784
785 for( int i=0; i<23; i++ ) pdWyniki[i] = new double[NN];
786 rewind( f );
787// fseek( f, 0L, SEEK_SET );
788 ReadComm( f );
789 char cRob[1024];
790 int iM = 0;
791 for( int i=0; i<NN; i++ )
792 {
793 ReadStr( f, cRob );
794 string ccc = cRob;
795
796 istringstream iss(ccc,istringstream::in);
797 iss.clear();
798 iss >> N;
799 for( int j=0; j<23; j++ )
800 {
801 if( iss.good() ) iM = j+1;
802 iss >> pdWyniki[j][i];
803 }
804
805 /*
806 fscanf( f, "%d", &N );
807 for( int j=0; j<23; j++ )
808 fscanf( f, "%lf", &pdWyniki[j][i] );
809 */
810 }
811 fclose( f );
812
813 iNwyn = NN;
814 iMwyn = iM;
815
816 fprintf( stderr, "mwyn = %d nwyn = %d\n", iMwyn, iNwyn );
817
818 return( 0 );
819}
820
822{
823 int k,jj,n1,n2,n3;
824 double x,y,z;
825 VECTOR_3D v;
826
827 for( int i=0; i<iN; i++ )
828 {
829 for( int j=0; j<4; j++ )
830 {
831 k = 0; x = dX[ iMaxPanelNumber*4*k + iMaxPanelNumber*j + i ];
832 k = 1; y = dX[ iMaxPanelNumber*4*k + iMaxPanelNumber*j + i ];
833 k = 2; z = dX[ iMaxPanelNumber*4*k + iMaxPanelNumber*j + i ];
834
835 v.x = x-pdWyniki[10][i];
836 v.y = y-pdWyniki[11][i];
837 v.z = z-pdWyniki[12][i];
838 double dRob = v.Len();
839
840 double dSum=1./dRob;
841 pdWyniki[14+j][i]=pdWyniki[9][i]/dRob;
842
843 jj = 1;
844 n1 = 2*j - 1;
845 if( n1 < 0 )n1 = 7;
846 n2 = 2*j;
847 n3 = 2*j + 1;
848
849 k = iNeigh[ iMaxPanelNumber*n1 + i ]-1;
850 if( k >= 0 && k < iMaxPanelNumber )
851 {
852 v.x = x-pdWyniki[10][k];
853 v.y = y-pdWyniki[11][k];
854 v.z = z-pdWyniki[12][k];
855 dRob = v.Len();
856 dSum += 1./dRob;
857 pdWyniki[14+j][i]+=pdWyniki[9][k]/dRob;
858 jj=jj+1;
859 }
860
861 k = iNeigh[ iMaxPanelNumber*n2 + i ]-1;
862 if( k >= 0 && k < iMaxPanelNumber )
863 {
864 v.x = x-pdWyniki[10][k];
865 v.y = y-pdWyniki[11][k];
866 v.z = z-pdWyniki[12][k];
867 dRob = v.Len();
868 dSum += 1./dRob;
869 pdWyniki[14+j][i]+=pdWyniki[9][k]/dRob;
870 jj=jj+1;
871 }
872
873 k = iNeigh[ iMaxPanelNumber*n3 + i ]-1;
874 if( k >= 0 && k < iMaxPanelNumber )
875 {
876 v.x = x-pdWyniki[10][k];
877 v.y = y-pdWyniki[11][k];
878 v.z = z-pdWyniki[12][k];
879 dRob = v.Len();
880 dSum += 1./dRob;
881 pdWyniki[14+j][i]+=pdWyniki[9][k]/dRob;
882 jj=jj+1;
883 }
884
885 pdWyniki[14+j][i] /= dSum;
886 //pdWyniki[14+j][i] /= jj;
887 }
888
889 for( int j=0; j<4; j++ )
890 {
891 k = 0; x = 0.5 * dX[ iMaxPanelNumber*4*k + iMaxPanelNumber*j + i ];
892 k = 1; y = 0.5 * dX[ iMaxPanelNumber*4*k + iMaxPanelNumber*j + i ];
893 k = 2; z = 0.5 * dX[ iMaxPanelNumber*4*k + iMaxPanelNumber*j + i ];
894
895 int j1=(j+1)%4;
896 k = 0; x += 0.5 * dX[ iMaxPanelNumber*4*k + iMaxPanelNumber*j1 + i ];
897 k = 1; y += 0.5 * dX[ iMaxPanelNumber*4*k + iMaxPanelNumber*j1 + i ];
898 k = 2; z += 0.5 * dX[ iMaxPanelNumber*4*k + iMaxPanelNumber*j1 + i ];
899
900 v.x = x-pdWyniki[10][i];
901 v.y = y-pdWyniki[11][i];
902 v.z = z-pdWyniki[12][i];
903 double dRob = v.Len();
904
905 double dSum=1./dRob;
906 pdWyniki[18+j][i]=pdWyniki[9][i]/dRob;
907
908 k = iNeigh[ iMaxPanelNumber*(2*j+1) + i ]-1;
909 if( k >= 0 && k < iMaxPanelNumber )
910 {
911 v.x = x-pdWyniki[10][k];
912 v.y = y-pdWyniki[11][k];
913 v.z = z-pdWyniki[12][k];
914 dRob = v.Len();
915 dSum += 1./dRob;
916 pdWyniki[18+j][i]+=pdWyniki[9][k]/dRob;
917 }
918
919 pdWyniki[18+j][i] /= dSum;
920 }
921 }
922
923 iMwyn = 22;
924
925 //tg_filename_setext( TXTfile, ".tx0" );
926 //WriteWyn( TXTfile );
927}
928
929int GRID_ARRAYS::WriteWyn( char *FileName )
930{
931 FILE *f = fopen( FileName, "w" );
932 if( f == NULL )
933 {
934 fprintf(stderr, "Open problem %s: %s\n", FileName, strerror(errno) );
935 return( -1 );
936 }
937
938 fprintf(f, "No doublet source vxd vyd vzd qx qy qz v^2 cp x y z Ma cp1 cp2 cp3 cp4 cpw1 cpw2 cpw3 cpw4 ss\n");
939 for( int i=0; i<iN; i++ )
940 {
941 fprintf( f, " %5d", i+1 );
942 for( int j=0; j<23; j++ )
943 fprintf( f, " %16.8g", pdWyniki[j][i] );
944 fprintf( f, "\n" );
945 }
946 fclose( f );
947
948 return( 0 );
949}
950
952{
953 for( int i=0; i<23; i++ ) DELETE_TAB( pdWyniki[i] );
954 iNwyn = 0;
955 iMwyn = 0;
956}
957
959{
961
962 NEW_TAB( iNnww, int, iMaxWakesNumber * 3 );
965}
966
968{
969 NEW_TAB( dQx, double, iN );
970 NEW_TAB( dQy, double, iN );
971 NEW_TAB( dQz, double, iN );
972 NEW_TAB( dSig, double, iN );
973
974 NEW_TAB( dSss, double, iNww2 );
975 NEW_TAB( dX0, double, iNww2 );
976 NEW_TAB( dY0, double, iNww2 );
977 NEW_TAB( dZ0, double, iNww2 );
978 NEW_TAB( dAlf1, double, iNww2 );
979 NEW_TAB( dAlf2, double, iNww2 );
980 NEW_TAB( dAlf3, double, iNww2 );
981 NEW_TAB( dBet1, double, iNww2 );
982 NEW_TAB( dBet2, double, iNww2 );
983 NEW_TAB( dBet3, double, iNww2 );
984 NEW_TAB( dGam1, double, iNww2 );
985 NEW_TAB( dGam2, double, iNww2 );
986 NEW_TAB( dGam3, double, iNww2 );
987
988 NEW_TAB( dRhs, double, iNww2 );
989}
990
992{
993 InitCommon();
994
995 NEW_TAB( dXp, double, iN );
996 NEW_TAB( dYp, double, iN );
997 NEW_TAB( dZp, double, iN );
998
999 NEW_TAB( dAi, double, iN*iNww );
1000 NEW_TAB( dRh, double, iN );
1001 NEW_TAB( IPIV, int, iN );
1002}
1003
1005{
1006 InitCommon();
1007 NEW_TAB( dVVVV, double, iN );
1008 NEW_TAB( dVxd, double, iN );
1009 NEW_TAB( dVyd, double, iN );
1010 NEW_TAB( dVzd, double, iN );
1011 NEW_TAB( dSs_rzut, double, iN );
1012 NEW_TAB( dCpp, double, iN );
1013 NEW_TAB( dVv2, double, iN );
1014 NEW_TAB( dMach, double, iN );
1015
1016 NEW_TAB( dCxi, double, iLiczw );
1017 NEW_TAB( dCzi, double, iLiczw );
1018 NEW_TAB( dCpr, double, iLiczw );
1019 NEW_TAB( dSs_cpr0, double, iLiczw );
1020 NEW_TAB( dSs_cpr, double, iLiczw );
1021 NEW_TAB( dCmr, double, iLiczw );
1022 NEW_TAB( dCay, double, iLiczw );
1023 NEW_TAB( dCzr, double, iLiczw );
1024 NEW_TAB( dCyr, double, iLiczw );
1025 NEW_TAB( dCxr, double, iLiczw );
1026
1027 NEW_TAB( dZzz, double, iN*4*3 );
1028 NEW_TAB( dObr, double, iN*4 );
1029 NEW_TAB( dCpb, double, iN*4 );
1030}
1031
int ReadIN1(FILE *File)
reads [.inp] data from stream FILE - data written as panels
void InitCommon(void)
initialization of commonly used arrays
double * dSs_cpr0
strip wetted area
int ReadINP(char *FileName)
reads [.inp] file from pathname FileName
int WriteDAT(char *FileName)
writes [.dat] file to pathname FileName
double * dRhs
right hand side vector input - result on output (Nww2)
double * dCzi
strip lift coeffcient
double * dCay
strip chord
double dZca25
z coordinate of reference point for moment calculation (usually 0.25 MAC)
int WriteInpFromPanels(char *FileName, int iScale=0)
writes [.inp] file to pathname FileName - data stored in panels
double * dSig
source (singularity) value
int iN
= iMaxPanelNumber;
int iMaxPanelNumber
number of body (airplane) panels
int iLiczw
number of wake strips
int * iNnww
array containing upper surface panels neighbouring with the wake iNnww[i,j] i - strip number j=1...
int iLiczp
number of wake panels
double * dCyr
"y" force coefficient acting on the strip
double dCa
mean aerodynamic chord (MAC)
void WriteObjs(FILE *f)
Writes objects.
void Points2Panels(void)
converts nodes (std::vector<VECTOR_3D>) to panels (std::vector<PANEL>)
int WriteInpFromPoints(char *FileName, int iScale=0)
writes [.inp] file to pathname FileName - data stored in nodes
int ReadObjs(FILE *f)
Reads objects.
double * dQz
tangential undisturbed velocity - z coordinate
double * dCpp
pressure coefficient
void Corner2Points(int *iD, VECTOR_3D *P)
assigns panel corner P to node number iD
int * iNeigh
neighbours numbers array (Nww2,8)
double * dX
main grid (+ wake for Panukl) X[i,j,k], i=panel number, j=corner number, k=coordinate number
double * dCpr
normal force coefficient acting on the strip
double dSS
reference area
double * dXw
wake grid (Xw[i,j,k])
double * dMach
lacal panel Mach number
double * dVv2
square of total velocity on the panel
double * dSss
panels areas
~GRID_ARRAYS(void)
destructor
double * dCzr
"z" force coefficient acting on the strip
int iNww
= iN + iLiczp; # airplane + wake (up)
double * dVyd
"y" component of induced velocity (from doublet distribution)
int * iKw
info about side body wake neighbours iKw[i,j] i - side body-wake neighbour number,...
char File_DAT_date[100]
date and time of mesh with wake file
int * iNkw
numbers of panels in Xkw (wake grid)
double dXca25
x coordinate of reference point for moment calculation (usually 0.25 MAC)
void Panels2Points(void)
converts panels (std::vector<PANEL>) to nodes (std::vector<VECTOR_3D>)
double * dAi
coefficient array (N x Nww)
double * dCxi
induced drag coeffcient (from strip)
char File_INP_date[100]
date and time of mesh file
int iNww2
= iNww + iLiczw; # airplane + wake (up) + wake (down 1 panel/strip)
std::vector< MS2_OBJ > Objs
Objects (MS2_OBJ) vector.
int ReadDATw(char *FileName)
reads [.dat] file from pathname FileName - body and wake panels stored in separated arrays (for visua...
int WriteWyn(char *FileName)
writes results array to pathname FileName
int ReadWyn(char *FileName)
reads results array from pathname FileName
double dWsp_sk
scale factor (default: 1)
char TXTfile[256]
pathname of [.txt] file
void InitForPress(void)
initialization of arrays used by Press program
int * iNpas
number of panels in the wake strip [liczw]
void DeleteWyn(void)
erases results objects
double dBs
wingspan
int iMaxWakesNumber
maximum of numbers of wake strips
void Array2Panels(void)
converts array (double X[i,j,k]) to panels (std::vector<PANEL>)
std::vector< PANEL > Panels
panels array
int iSym
symmetry flag
double * dVzd
"z" component of induced velocity (from doublet distribution)
double * dQy
tangential undisturbed velocity - y coordinate
void InitRob(void)
initialization of scratch arrays
double * dXkw
side body-wake neighbours (panels)
std::vector< VECTOR_3D > Points
nodes array
int iMaxBodyNeighbours
number of side body-wake neighbours
void Panels2Array(void)
converts panels (std::vector<PANEL>) to array (double X[i,j,k])
double * dSs_rzut
projection areas of panels on plane xy
double * dVxd
"x" component of induced velocity (from doublet distribution)
float fVer
version number of data file [.inp] format: from data file on input, defined in VERSION on output
double * dRh
working area (N)
int iNw
= iN + iLiczw; # airplane + wake (up) (1 panel/strip)
int iNw2
= iNw + iLiczw; # airplane + wake (up+down) (1 panel/strip)
int iMaxWakePanelNumber
maximum number of panels in wake strip
int * iIpas
wake panels numbers in the strip [liczw, MaxWakePanelNumber]
double * dVVVV
undisturbed velocity
int ReadDAT(char *FileName, int iProg)
reads [.dat] file from pathname FileName - body and wake panels stored in dX array iProg: 1 initial...
void SupWyn(void)
computes data for sides centers
double * dCxr
"z" force coefficient acting on the strip
int iNwyn
current number of rows of pdWyniki array
double * pdWyniki[23]
results array - 22 variables x number of panels
double * dQx
tangential undisturbed velocity - x coordinate
int * IPIV
pivot table
double * dCmr
twisting moment coefficient acting on the strip
void InitForPanukl(void)
initialization of arrays used by PANUKL (main program)
double * dSs_cpr
strip area
int iMwyn
current number of columns of pdWyniki array (<=22)
GRID_ARRAYS(void)
default constructor
char File_TXT_date[100]
date and time of results file
int ReadIN2(FILE *File)
reads [.inp] data from stream FILE - data written as nodes
static FILE * fopen(const char *filename, const char *mode)
Cross-platform function to fopen function that supports UTF-8 encoded name.
Definition iofun.cpp:358
static const char * filename_date(const char *name)
Returns pointer to the string that contains the date of last file modification/creation.
Definition iofun.cpp:399
static int ReadComm(FILE *stream)
Function to read of a comment till the end of line. It returns 0 or EOF if it is performed.
Definition iofun.cpp:42
static int ReadStr(FILE *stream, char *Par)
Function to read the new line from FILE "stream" and to store it in table of char "Par"....
Definition iofun.cpp:163
static int ReadPar(FILE *stream, const char *Format, void *Par)
Function to read one variable. The type of variable depends on Format, compatible with stdio library.
Definition iofun.cpp:67
A class for manipulating the rectangular panel.
Definition panel.h:35
VECTOR_3D P1
the coordinates of the 1st corner of the panel
Definition panel.h:56
Vector 3D class - vector manipulation.
Definition vector3d.h:34
double x
x coordinate
Definition vector3d.h:38
#define DELETE_TAB(OBJ)
Macro for safe deleteing the array and sets the pointer to zero.
Definition memfun.h:97
#define NEW_TAB(Var, Typ, Len)
Macro for initializing array with zeros.
Definition memfun.h:71
This file contains class for PANUKL input and output files manipulation.
#define VERSION
VERSION of the data file [.inp] format currently is equal to 4.00
#define MaxWakesNumber
limit of numbers of wake strips
#define MaxWakePanelNumber
limit of numbers of panels in wake strip
structure that contains data of main airplane objects (wings, fuselage)
int n1
the first panel number in the object