CONFIG LIB 1.5
Configuration Files Library (by TGG 2020)
Loading...
Searching...
No Matches
panukl_ngh.cpp
1/*********************************************************************/
2/* */
3/* Config files library - (C) TGG 2015 */
4/* */
5/*********************************************************************/
6/* Warszawa, 2015 */
7/*********************************************************************/
8/* */
9/* File: panukl_ngh.cpp */
10/* */
11/* Author: T.Grabowski */
12/* */
13/* Contents - ngh file data (wake and neighbours) class */
14/* */
15/* */
16/*********************************************************************/
17/* */
18/* */
19
20#include "panukl_ngh.h"
21
22NGH_FILE::NGH_FILE( void ){ Clean(); }
23
24NGH_FILE::~NGH_FILE( void ){}
25
26void NGH_FILE::Clean( void )
27{
28 memset( DAT_file, 0, 256 );
29 memset( INP_file, 0, 256 );
30 memset( NGH_file, 0, 256 );
31
32 dAlfa = 0.0;
33 dBeta = 0.0;
34 dAngleTE = 0.0;
35 dAngleNGH = 0.0;
36 dLastPanel = 0.0;
37 iWakeType = 0;
38}
39
40int NGH_FILE::ReadNGH( char *FileName )
41{
42 FILE *File;
43 File = fopen( FileName, "r" );
44 if( File == NULL )
45 {
46 fprintf( stderr, "[.NGH] file open error to reading (%s)\n", FileName );
47 return (-1);
48 }
49
50 ReadPar( File, "%d", &iWakeType );
51 ReadPar( File, "%lf", &dAngleTE );
52 ReadPar( File, "%lf", &dAngleNGH );
53 ReadPar( File, "%lf", &dAlfa );
54 ReadPar( File, "%lf", &dBeta );
55 ReadPar( File, "%lf", &dLastPanel );
56 ReadStr( File, INP_file );
57 ReadStr( File, DAT_file );
58
59 fclose( File );
60
63
64 strcpy( NGH_file, FileName );
65
66 return (0);
67}
68
69int NGH_FILE::WriteNGH( char *FileName )
70{
71 FILE *File;
72 File = fopen( FileName, "w" );
73 if( File == NULL )
74 {
75 fprintf( stderr, "[.NGH] file open error to writing (%s)\n", FileName );
76 return (-1);
77 }
78
79 fprintf( File, "# Neigh program configuration file\n");
80 fprintf( File, "%d # wake type\n", iWakeType );
81 fprintf( File, "%6.2f # trailing edge angle\n", dAngleTE );
82 fprintf( File, "%6.2f # neighbour condition angle\n", dAngleNGH );
83 fprintf( File, "%6.2f # angle of attack\n", dAlfa );
84 fprintf( File, "%6.2f # sideslip angle\n", dBeta );
85 fprintf( File, "%6.2f # last panel length (MAC multiplication)\n", dLastPanel );
86 fprintf( File, "%s # input grid file\n", INP_file );
87 fprintf( File, "%s # output file - grid with wake and neighbours\n", DAT_file );
88
89 fclose( File );
90
91 return (0);
92}
93
94
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 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 dLastPanel
length of wake - MAC multiplicator (default 20)
Definition panukl_ngh.h:38
double dAlfa
angle of attack [deg] - active in case iWakeType = 1,3,4,6
Definition panukl_ngh.h:34
double dAngleTE
angle of trailing edge [deg], which determines wake creation (Kutta-Joukovsky condition)
Definition panukl_ngh.h:36
double dBeta
sideslip angle [deg] - active in case iWakeType = 2,3,5,6
Definition panukl_ngh.h:35
char INP_file[256]
data (mesh) file [.INP] - input
Definition panukl_ngh.h:31
int ReadNGH(char *FileName)
reads parameters [.ngh] file
char NGH_file[256]
name of current [.ngh] file
Definition panukl_ngh.h:49
double dAngleNGH
max. value of angle [deg] (max. 90) between panels for which panels are treated as neighbouring
Definition panukl_ngh.h:37
int iWakeType
Type of wake: 0 - wake paralel to MAC, 1 - wake with downwash due to angle of attack,...
Definition panukl_ngh.h:47
int WriteNGH(char *Filename)
writes parameters [.ngh] file
void Clean(void)
cleans local variables
char DAT_file[256]
data (mesh+wake) file [.DAT] - output
Definition panukl_ngh.h:32