CONFIG LIB 1.5
Configuration Files Library (by TGG 2020)
Loading...
Searching...
No Matches
panukl_plr.cpp
1/*********************************************************************/
2/* */
3/* Config files library - (C) TGG 2019 */
4/* */
5/*********************************************************************/
6/* Warszawa, 2019 */
7/*********************************************************************/
8/* */
9/* File: panukl_plr.h */
10/* */
11/* Author: T.Grabowski */
12/* */
13/* Contents - plr file data (POLAR creation) class */
14/* */
15/* */
16/*********************************************************************/
17/* */
18/* */
19
20
21#include "panukl_plr.h"
22
23PANUKL_PLR::PANUKL_PLR( void ){ Clean(); }
24
25PANUKL_PLR::~PANUKL_PLR( void ){}
26
28{
29 memset( POLAR_dir, 0, 256 );
30 memset( DAT_file, 0, 256 );
31 memset( OUT_file, 0, 256 );
32
33 dAlfa0 = dAlfak = dAlf = 0.0;
34 dMa = 0.0;
35 iNum1 = iNum2 = 0;
36 iProc = 0;
37 iMeth = 0;
38 iAngle = 0;
39 iCompress = 0;
40 iPitchX = 0;
41 dXNum1 = dXNum2 = 0.0;
42 dCfe = 0.0;
43 iMaxProc = 0;
44}
45
46int PANUKL_PLR::Read( char *PolarFile )
47{
48 FILE *File;
49 File = fopen( PolarFile, "r" );
50 if( File == NULL )
51 {
52 fprintf( stderr, "[.PLR] file open error to reading (%s)\n", PolarFile );
53 return (-1);
54 }
55
56 ReadComm( File );
57 ReadStr( File, POLAR_dir );
58 ReadStr( File, DAT_file );
59 ReadStr( File, OUT_file );
60 ReadPar( File, "%lf %lf %lf", &dAlfa0, &dAlfak, &dAlf );
61 ReadPar( File, "%lf", &dMa );
62
63 ReadPar( File, "%d", &iProc );
64
65 ReadPar( File, "%d %d", &iNum1, &iNum2 );
66 ReadPar( File, "%d", &iMeth );
67 ReadPar( File, "%d", &iAngle );
68 ReadPar( File, "%lf %lf", &dXNum1, &dXNum2 );
69 ReadPar( File, "%d", &iCompress );
70 ReadPar( File, "%d", &iPitchX );
71
72 ReadPar( File, "%lf", &dCfe );
73
74 ReadPar( File, "%d", &iMaxProc );
75
76 fclose( File );
77
81
82 iMaxProc = iMaxProc > 64 ? 64 : iMaxProc;
83 iMaxProc = iMaxProc < 1 ? 1 : iMaxProc;
84
85 return (0);
86}
87
88int PANUKL_PLR::Write( char *PolarFile )
89{
90 FILE *File;
91 File = fopen( PolarFile, "w" );
92 if( File == NULL )
93 {
94 fprintf( stderr, "[.PLR] file open error to writing (%s)\n", PolarFile );
95 return (-1);
96 }
97
98 fprintf( File, "# Panukl -> POLAR configuration file\n");
99 fprintf( File, "%s # POLAR output directory\n", POLAR_dir );
100 fprintf( File, "%s # data (grid+wake) file [.dat] for A/C configuration\n", DAT_file );
101 fprintf( File, "%s # output polar file [.TXT]\n", OUT_file );
102
103 fprintf( File, "%7.3f %7.3f %7.3f # Alfa0, Alfa1, dA - angle of attack sequence [deg]\n", dAlfa0, dAlfak, dAlf );
104 fprintf( File, "%7.3f # Mach number \n", dMa );
105
106 fprintf( File, "%3d # type of linear system solver (1-LAPACK OPTIMIZED, 0-NOT OPTIMIZED)\n", iProc );
107
108 fprintf( File, "%d %d # range of panel's indices for pressure calculation\n", iNum1, iNum2 );
109 fprintf( File, "%3d # number of differentiation method\n", iMeth );
110 fprintf( File, "%3d # averaging flag\n", iAngle );
111 fprintf( File, "%6.2f %6.2f # range of X coordinates for pressure calculation\n", dXNum1, dXNum2 );
112 fprintf( File, "%3d # compressibility flag (0-none, 1-PG, 2-KT, 3-direct)\n", iCompress );
113 fprintf( File, "%3d # X component of pressure in pitching moment\n", iPitchX );
114
115 fprintf( File, "%10.6f # Cfe - equivalent parasite drag\n", dCfe );
116
117 fprintf( File, "%3d # max number of parallel process\n", iMaxProc );
118
119 fclose( File );
120
121 return (0);
122}
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 void ClipFileName(char *string)
Clipping of the ending blanc characters of "string".
Definition iofun.cpp:250
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
double dXNum2
upper bound of range of X coordinate taken for global coefficients calculation
Definition panukl_plr.h:54
int Read(char *PolarFile)
reads the [.plr] file
char POLAR_dir[256]
path name for output - aerodynamic data files to create POLAR
Definition panukl_plr.h:31
int iProc
current number of CPUs (cores) - set by program
Definition panukl_plr.h:45
char DAT_file[256]
data (grid+wake) file [.DAT] for A/C configuration
Definition panukl_plr.h:40
double dAlf
step of angle of attack [deg]
Definition panukl_plr.h:35
int iAngle
averaging flag (0/1)
Definition panukl_plr.h:50
void Clean()
cleans local variables
int iPitchX
flag to take X component of forces for pitching moment calculation(0/1)
Definition panukl_plr.h:51
int iMeth
number of differentiation method (see PANUKL manual)
Definition panukl_plr.h:49
double dMa
Mach number.
Definition panukl_plr.h:36
double dXNum1
lower bound of range of X coordinate taken for global coefficients calculation
Definition panukl_plr.h:53
int iNum2
number of the last panel taken for global coefficients calculation
Definition panukl_plr.h:48
double dCfe
parasite drag coefficient
Definition panukl_plr.h:38
int iCompress
compressibility flag (0-none, 1-Prandtl-Galuert, 2-Karman-Tsien, 3-direct)
Definition panukl_plr.h:43
double dAlfa0
left (lower) bound of angle of attack [deg]
Definition panukl_plr.h:33
double dAlfak
right (upper) bound of angle of attack [deg]
Definition panukl_plr.h:34
int iMaxProc
max number of parallel process (shouldn't be greater than real number of CPUs (cores)
Definition panukl_plr.h:44
char OUT_file[256]
output polar file [.TXT]
Definition panukl_plr.h:41
int Write(char *PolarFile)
writes the [.plr] file
int iNum1
number of the first panel taken for global coefficients calculation
Definition panukl_plr.h:47