CONFIG LIB 1.5
Configuration Files Library (by TGG 2020)
Loading...
Searching...
No Matches
panukl_prj.cpp
1/*********************************************************************/
2/* */
3/* Config files library - (C) TGG 2015 */
4/* */
5/*********************************************************************/
6/* Warszawa, 2015 */
7/*********************************************************************/
8/* */
9/* File: panukl_prj.cpp */
10/* */
11/* Author: T.Grabowski */
12/* */
13/* Contents - prj file data (SDSA creation) class */
14/* */
15/* */
16/*********************************************************************/
17/* */
18/* */
19
20#include "panukl_prj.h"
21
22PANUKL_PRJ::PANUKL_PRJ( void ){ Clean(); }
23
24PANUKL_PRJ::~PANUKL_PRJ( void ){}
25
27{
28 memset( SDSA_dir, 0, 256 );
29 memset( DAT_file, 0, 256 );
30 memset( DAT_file1, 0, 256 );
31 memset( DAT_file2, 0, 256 );
32 memset( DAT_file3, 0, 256 );
33
34 iH = iV = iL = 0;
35 dH = dV = dL = 0.0;
36 dAlfa0 = dAlfak = dAlf = 0.0;
37 dMa0 = dMak = dMa = 0.0;
38 dBeta = 0.0;
39 dP = dQ = dR = 0.0;
40 iNum1 = iNum2 = 0;
41 iProc = 0;
42 iMeth = 0;
43 iAngle = 0;
44 iCompress = 0;
45 iPitchX = 0;
46 dXNum1 = dXNum2 = 0.0;
47 dCfe = 0.0;
48 dAoA_max = 0.0;
49 iMaxProc = 0;
50}
51
52int PANUKL_PRJ::Read( char *PrjFile )
53{
54 FILE *File;
55 File = fopen( PrjFile, "r" );
56 if( File == NULL )
57 {
58 fprintf( stderr, "[.PRJ] file open error to reading (%s)\n", PrjFile );
59 return (-1);
60 }
61
62 ReadComm( File );
63 ReadStr( File, SDSA_dir );
64 ReadStr( File, DAT_file );
65 ReadStr( File, DAT_file1 );
66 ReadStr( File, DAT_file2 );
67 ReadStr( File, DAT_file3 );
68 ReadPar( File, "%d %d %d", &iH, &iL, &iV );
69 ReadPar( File, "%lf %lf %lf", &dH, &dL, &dV );
70 ReadPar( File, "%lf %lf %lf", &dAlfa0, &dAlfak, &dAlf );
71 ReadPar( File, "%lf %lf %lf", &dMa0, &dMak, &dMa );
72 ReadPar( File, "%lf", &dBeta );
73 ReadPar( File, "%lf", &dP );
74 ReadPar( File, "%lf", &dQ );
75 ReadPar( File, "%lf", &dR );
76 ReadPar( File, "%d", &iProc );
77
78 ReadPar( File, "%d %d", &iNum1, &iNum2 );
79 ReadPar( File, "%d", &iMeth );
80 ReadPar( File, "%d", &iAngle );
81 ReadPar( File, "%lf %lf", &dXNum1, &dXNum2 );
82 ReadPar( File, "%d", &iCompress );
83 ReadPar( File, "%d", &iPitchX );
84
85 ReadPar( File, "%lf", &dCfe );
86 ReadPar( File, "%lf", &dAoA_max );
87
88 ReadPar( File, "%d", &iMaxProc );
89
90 fclose( File );
91
97
98 iMaxProc = iMaxProc > 64 ? 64 : iMaxProc;
99 iMaxProc = iMaxProc < 1 ? 1 : iMaxProc;
100
101 return (0);
102}
103
104int PANUKL_PRJ::Write( char *PrjFile )
105{
106 FILE *File;
107 File = fopen( PrjFile, "w" );
108 if( File == NULL )
109 {
110 fprintf( stderr, "[.PRJ] file open error to writing (%s)\n", PrjFile );
111 return (-1);
112 }
113
114 fprintf( File, "# Panukl -> SDSA configuration file\n");
115 fprintf( File, "%s # SDSA project directory\n", SDSA_dir );
116 fprintf( File, "%s # clean configuration data file [.dat] (grid with wake)\n", DAT_file );
117 fprintf( File, "%s # Elevator deflected configuration data file [.dat] (grid with wake)\n", DAT_file1 );
118 fprintf( File, "%s # Aileron deflected configuration data file [.dat] (grid with wake)\n", DAT_file2 );
119 fprintf( File, "%s # Rudder deflected configuration data file [.dat] (grid with wake)\n", DAT_file3 );
120 fprintf( File, "%d %d %d # deflected configuration flags\n", iH, iL, iV );
121 fprintf( File, "%f %f %f # control surfaces deflection\n", dH, dL, dV );
122
123 fprintf( File, "%7.3f %7.3f %7.3f # Alfa0, Alfa1, dA - angle of attack sequence [deg]\n", dAlfa0, dAlfak, dAlf );
124 fprintf( File, "%7.3f %7.3f %7.3f # Mach0, Mach1, dM - Mach number sequence \n", dMa0, dMak, dMa );
125 fprintf( File, "%7.3f # beta - sideslip angle [deg]\n", dBeta );
126 fprintf( File, "%6.2f # P - roll rate [rad/s]\n", dP );
127 fprintf( File, "%6.2f # Q - pitch rate [rad/s]\n", dQ );
128 fprintf( File, "%6.2f # R - yaw rate [rad/s]\n", dR );
129 fprintf( File, "%3d # type of linear system solver (1-LAPACK OPTIMIZED, 0-NOT OPTIMIZED)\n", iProc );
130
131 fprintf( File, "%d %d # range of panel's indices for pressure calculation\n", iNum1, iNum2 );
132 fprintf( File, "%3d # number of differentiation method\n", iMeth );
133 fprintf( File, "%3d # averaging flag\n", iAngle );
134 fprintf( File, "%6.2f %6.2f # range of X coordinates for pressure calculation\n", dXNum1, dXNum2 );
135 fprintf( File, "%3d # compressibility flag (0-none, 1-PG, 2-KT, 3-direct)\n", iCompress );
136 fprintf( File, "%3d # X component of pressure in pitching moment\n", iPitchX );
137
138 fprintf( File, "%10.6f # Cfe - equivalent parasite drag\n", dCfe );
139 fprintf( File, "%10.3f # AoA max - estimated max. angle of attack [deg]\n", dAoA_max );
140
141 fprintf( File, "%3d # max number of parallel process\n", iMaxProc );
142
143 fclose( File );
144
145 return (0);
146}
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
int iNum2
number of the last panel taken for global coefficients calculation
Definition panukl_prj.h:63
double dAlfa0
left (lower) bound of angle of attack [deg]
Definition panukl_prj.h:36
double dV
rudder deflection corresponding to mesh from DAT_file3 [deg]
Definition panukl_prj.h:48
char SDSA_dir[256]
path name for output - aerodynamic data files set for SDSA
Definition panukl_prj.h:31
char DAT_file1[256]
data (mesh+wake) file [.DAT] elevator deflected
Definition panukl_prj.h:54
int iCompress
compressibility flag (0-none, 1-Prandtl-Galuert, 2-Karman-Tsien, 3-direct)
Definition panukl_prj.h:58
double dAlf
step of angle of attack [deg]
Definition panukl_prj.h:38
char DAT_file3[256]
data (mesh+wake) file [.DAT] rudder deflected
Definition panukl_prj.h:56
int iMaxProc
max number of parallel process (shouldn't be greater than real number of CPUs (cores)
Definition panukl_prj.h:59
double dH
elevator deflection corresponding to mesh from DAT_file1 [deg]
Definition panukl_prj.h:46
int iPitchX
flag to take X component of forces for pitching moment calculation(0/1)
Definition panukl_prj.h:66
int iH
flag to compute configuration with elevator deflected (0/1)
Definition panukl_prj.h:32
double dBeta
sideslip angle [deg]
Definition panukl_prj.h:39
double dMak
right (upper) bound of Mach number range
Definition panukl_prj.h:44
double dL
aileron deflection corresponding to mesh from DAT_file2 [deg]
Definition panukl_prj.h:47
double dXNum2
upper bound of range of X coordinate taken for global coefficients calculation
Definition panukl_prj.h:69
int iProc
current number of CPUs (cores) - set by program
Definition panukl_prj.h:60
double dP
roll rate [rad/s]
Definition panukl_prj.h:40
int iMeth
number of differentiation method (see PANUKL manual)
Definition panukl_prj.h:64
double dR
yaw rate [rad/s]
Definition panukl_prj.h:42
double dAlfak
right (upper) bound of angle of attack [deg]
Definition panukl_prj.h:37
double dMa0
left (lower) bound of Mach number range
Definition panukl_prj.h:43
void Clean()
cleans local variables
char DAT_file2[256]
data (mesh+wake) file [.DAT] aileron deflected
Definition panukl_prj.h:55
int iV
flag to compute configuration with rudder deflected (0/1)
Definition panukl_prj.h:34
int Write(char *PrjFile)
writes the [.prj] file
double dAoA_max
max. value of angle of attack [deg]
Definition panukl_prj.h:51
char DAT_file[256]
data (mesh+wake) file [.DAT] for basic configuration
Definition panukl_prj.h:53
double dCfe
parasite drag coefficient
Definition panukl_prj.h:50
double dMa
step of Mach number
Definition panukl_prj.h:45
double dXNum1
lower bound of range of X coordinate taken for global coefficients calculation
Definition panukl_prj.h:68
int iAngle
averaging flag (0/1)
Definition panukl_prj.h:65
int iL
flag to compute configuration with aileron deflected (0/1)
Definition panukl_prj.h:33
int iNum1
number of the first panel taken for global coefficients calculation
Definition panukl_prj.h:62
int Read(char *PrjFile)
reads the [.prj] file
double dQ
pitch rate [rad/s]
Definition panukl_prj.h:41