CONFIG LIB 1.5
Configuration Files Library (by TGG 2020)
Loading...
Searching...
No Matches
panukl_par.cpp
1/*********************************************************************/
2/* */
3/* Config files library - (C) TGG 2015 */
4/* */
5/*********************************************************************/
6/* Warszawa, 2015 */
7/*********************************************************************/
8/* */
9/* File: panukl_par.cpp */
10/* */
11/* Author: T.Grabowski */
12/* */
13/* Contents - par file data (doublet computation) class */
14/* */
15/* */
16/*********************************************************************/
17/* */
18/* */
19
20#include "panukl_par.h"
21
22PAR_FILE::PAR_FILE( void ){ Clean (); }
23
24PAR_FILE::~PAR_FILE( void ){}
25
26void PAR_FILE::Clean( void )
27{
28 memset( DAT_file, 0, 256 );
29 memset( PAN_file, 0, 256 );
30 memset( ACD_file, 0, 256 );
31
32 dAlfa = 0.0;
33 dBeta = 0.0;
34 dP = dQ = dR = 0.0;
35 iProc = 0;
36 dMach = 0.0;
37 iACD = 0;
38}
39
40int PAR_FILE::ReadPAR( char *FileName )
41{
42 FILE *File;
43 File = fopen( FileName, "r" );
44 if( File == NULL )
45 {
46 fprintf( stderr, "[.PAR] file open error to reading (%s)\n", FileName );
47 return (-1);
48 }
49
50 ReadComm( File );
51 ReadStr( File, DAT_file );
52 ReadStr( File, PAN_file );
53 ReadPar( File, "%lf", &dAlfa );
54 ReadPar( File, "%lf", &dBeta );
55 ReadPar( File, "%lf", &dP );
56 ReadPar( File, "%lf", &dQ );
57 ReadPar( File, "%lf", &dR );
58 ReadPar( File, "%d", &iProc );
59 if(ReadPar( File, "%lf", &dMach )==EOF)dMach=0.;
60 if(ReadPar( File, "%d", &iACD )==EOF)iACD=0;
61 if(iACD)ReadStr( File, ACD_file );
62
63 fclose( File );
64
68
69 strcpy( PAR_file, FileName );
70
71 return (0);
72}
73
74int PAR_FILE::WritePAR( char *FileName )
75{
76 FILE *File;
77 File = fopen( FileName, "w" );
78 if( File == NULL )
79 {
80 fprintf( stderr, "[.PAR] file open error to writing (%s)\n", FileName );
81 return (-1);
82 }
83
84 fprintf( File, "# Panukl main program configuration file\n");
85 fprintf( File, "%s # input data file (grid with wake)\n", DAT_file );
86 fprintf( File, "%s # output file (input for Press program)\n", PAN_file );
87 fprintf( File, "%6.2f # alfa - angle of attack [deg]\n", dAlfa );
88 fprintf( File, "%6.2f # beta - sideslip angle [deg]\n", dBeta );
89 fprintf( File, "%6.2f # P - roll rate [rad/s]\n", dP );
90 fprintf( File, "%6.2f # Q - pitch rate [rad/s]\n", dQ );
91 fprintf( File, "%6.2f # R - yaw rate [rad/s]\n", dR );
92 fprintf( File, "%3d # type of linear system solver (1-LAPACK OPTIMIZED, 0-NOT OPTIMIZED)\n", iProc );
93 fprintf( File, "%6.3f # Mach number\n", dMach );
94 fprintf( File, "%3d # ACD file flag\n", iACD );
95 if(iACD)fprintf( File, "%s # propeller data configuration file (input)\n", ACD_file );
96
97
98 fclose( File );
99
100 return (0);
101}
102
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 iProc
type of linear system solver (1-LAPACK OPTIMIZED, 0-NOT OPTIMIZED)
Definition panukl_par.h:41
double dAlfa
angle of attack [deg]
Definition panukl_par.h:35
int iACD
flag of using the propellers data configuration file (0-no file, 1-file present)
Definition panukl_par.h:42
int WritePAR(char *Filename)
writes parameters file
char ACD_file[256]
optional input file - propellers data configuration file [.ACD]
Definition panukl_par.h:33
double dBeta
sideslip angle [deg]
Definition panukl_par.h:36
double dMach
Mach number.
Definition panukl_par.h:37
char DAT_file[256]
input file - mesh + wake data file [.DAT]
Definition panukl_par.h:31
double dP
roll rate [rad/s]
Definition panukl_par.h:38
double dQ
pitch rate [rad/s]
Definition panukl_par.h:39
char PAR_file[256]
current parameters file [.PAR]
Definition panukl_par.h:43
int ReadPAR(char *FileName)
reads parameters file
void Clean()
cleans local variables
double dR
yaw rate [rad/s]
Definition panukl_par.h:40
char PAN_file[256]
output file - doublet distribution file [.PAN]
Definition panukl_par.h:32