CONFIG LIB 1.5
Configuration Files Library (by TGG 2020)
Loading...
Searching...
No Matches
AIRFOIL Class Reference

AIRFOIL class to manipulate the airfoil geometry or
it can read geometry data from file (5 commonly used fromats) or generate 4-digit and 5-digit naca airfoils
Geometry data (coordinates) is stored in the arrays. More...

#include <airfoil.h>

Inheritance diagram for AIRFOIL:
IOFUN MEMFUN

Public Member Functions

void Print (FILE *f=stdout)
 prints PRF file (default on stdout)
 
int Read (char *cFile)
 reads profile file
 
int Write (char *cFile, int iTyp=0)
 saves profile file - two types are available:
0 - native PANUKL (4 columns)
3 - SELIG (Xfoil compatible)
other - no action
 
int ReadStatus (void)
 returns read status: 0 - no data, 1 - data read succesfuly
 
int GetReadType (void)
 returns the type of format recognition:
0 - recognition by content (default),
1 - recognition by filename extention
 
void SetReadType (int iRT)
 sets the type of format recognition
 
int ReadNaca (long int iNACA, int NN=100)
 generates NACA airfoil given by long int value (e.g. iNACA = 23012),
NN - the number of points that define the airfoil geometry
 
int ReadNaca (char *cNACA, int NN=100)
 generates NACA airfoil given by string (e.g. cNACA = "23012"),
NN - the number of points that define the airfoil geometry
 
void Clean (void)
 cleans local variables
 

Public Attributes

int Nf
 size of the vectors with geometry data - compatible with Xfoil
 
double * Xf
 X coordinates (Nf points)
 
double * Zf
 Z coordinates (Nf points)
 
int N
 size of the vectors with geometry data - 4 column native PANUKL format
 
double * Xd
 X coordinates of lower contour (N points)
 
double * Xg
 X coordinates of upper contour (N points)
 
double * Zd
 Z coordinates of lower contour (N points)
 
double * Zg
 Z coordinates of upper contour (N points)
 
int iType
 File type:
0 - PRF - PANUKL (prf1) - native PANUKL (4 columns) format
1 - PRF - prf2 - by L.Wiechers- NAME in header, N below header
2 - KOO - koordinate by L.Wiechers
3 - DAT - SELIG - (Xfoil)
4 - DAT - LEDNICER.
 
char cName [100]
 filename (without path)
 

Protected Attributes

int iRead
 0 - no data, 1 - data read succesfuly
 
int iGUI
 GUI flag - messages displayed using wrapping function "alert".
 
void(* alert )(char *c) = NULL
 virtual fuction to display the message (if iGUI > 0)
 

Additional Inherited Members

- Static Public Member Functions inherited from IOFUN
static void Win2Unix (char *s)
 conversion of directory separators - MS Windows to Unix
 
static void Unix2Win (char *s)
 conversion of directory separators - Unix to MS Windows
 
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.
 
static void ReadDummy (FILE *stream)
 Function to read a comment line.
 
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.
 
static int ReadPar (FILE *stream, const char *Format, void *Par1, void *Par2)
 Function to read two variables. The type of variables depends on Format, compatible with stdio library.
 
static int ReadPar (FILE *stream, const char *Format, void *Par1, void *Par2, void *Par3)
 Function to read three variables. The type of variables depends on Format, compatible with stdio library.
 
static int ReadPar (FILE *stream, const char *Format, void *Par1, void *Par2, void *Par3, void *Par4)
 Function to read four variables. The type of variables depends on Format, compatible with stdio library.
 
static int ReadVect3 (FILE *stream, double *Par, double dScal=1.)
 Function to read double vector "Par" of "3" dimension from FILE "stream". The read values are scaled by multiplier "dScal".
 
static int ReadVect3 (FILE *stream, float *Par, float fScal=1.)
 Function to read float vector "Par" of "3" dimension from FILE "stream". The read values are scaled by multiplier "fScal".
 
static int ReadVect3 (FILE *stream, long *Par, long lScal=1)
 Function to read long vector "Par" of "3" dimension from FILE "stream". The read values are scaled by multiplier "lScal".
 
static int ReadVect3 (FILE *stream, int *Par, int iScal=1)
 Function to read int vector "Par" of "3" dimension from FILE "stream". The read values are scaled by multiplier "iScal".
 
static int ReadVect (FILE *stream, double *Par, int n, double dScal=1.)
 Function to read double vector "Par" of "n" dimension from FILE "stream". The read values are scaled by multiplier "dScal".
 
static int ReadVect (FILE *stream, float *Par, int n, float fScal=1.)
 Function to read float vector "Par" of "n" dimension from FILE "stream". The read values are scaled by multiplier "fScal".
 
static int ReadVect (FILE *stream, long *Par, int n, long lScal=1)
 Function to read long vector "Par" of "n" dimension from FILE "stream". The read values are scaled by multiplier "lScal".
 
static int ReadVect (FILE *stream, int *Par, int n, int iScal=1)
 Function to read int vector "Par" of "n" dimension from FILE "stream". The read values are scaled by multiplier "iScal".
 
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". The starting and ending blanc charaters are clipped.
 
static void ReadStrL (FILE *stream, char *Par, int *len)
 Function to read the string (Par) from FILE "stream". It reads from current pointer of FILE to the end of line or EOF. Number of read characters is returned in "len".
 
static void ClipString (char *string)
 Clipping of the "string" up to the first blanc character or comment "#" character.
 
static void ClipFileName (char *string)
 Clipping of the ending blanc characters of "string".
 
static bool CompareStrings (char *str1, char *str2)
 Compares two strings (str1 and str2). Returns true if they match, false otherwise.
 
static int file_exist (const char *name)
 Returns true (1) if file "name" does exist, 0 otherwise.
 
static const char * filename_name (const char *name)
 Returns pointer to filename without path.
 
static const char * filename_ext (const char *buf)
 Returns pointer to filename extension.
 
static char * filename_setext (char *buf, int buflen, const char *ext)
 set/change filename extension
 
static int filename_dir (char *name)
 returns the length of the path in (path)name
 
static const char * filename_date (const char *name)
 Returns pointer to the string that contains the date of last file modification/creation.
 
static FILE * fopen (const char *filename, const char *mode)
 Cross-platform function to fopen function that supports UTF-8 encoded name.
 
static int stat (const char *f, struct stat *b)
 Cross-platform function to stat() a file using a UTF-8 encoded name or value.
 
static size_t strlcpy (char *d, const char *s, size_t bufsize)
 The implementation of nonstandard strlcpy function.
 
static int nLines (FILE *stream)
 Returns number of lines of text file from current pointer to EOF.
 
static int nColumns (FILE *stream, char Par[][32])
 Returns number of columns of text file (number of strings in the first line). Names of columns are stored in Par array.
 
static int isstrblank (char *cc, int iLen)
 Checks if string (cc) is blank (1/0)
 
static void ReadVect3 (FILE *stream, VECTOR_3D *Vec, double dScal=1.)
 Function to read VECTOR_3D Vec components from FILE "stream". The read values are scaled by multiplier "dScal".
 
static int readln (FILE *ff, char *value_x)
 Pascal style "readln" function to read string.
 
static int readln (FILE *ff, int *value_x)
 Pascal style "readln" function to read int.
 
static int readln (FILE *ff, long *value_x)
 Pascal style "readln" function to read long.
 
static int readln (FILE *ff, float *value_x)
 Pascal style "readln" function to read float.
 
static int readln (FILE *ff, double *value_x)
 Pascal style "readln" function to read double.
 
static int readln (FILE *ff, long double *value_x)
 Pascal style "readln" function to read long double.
 
static int readln (FILE *ff)
 Pascal style "readln" function to read comment.
 
static int readln (FILE *ff, VECTOR_3D *vec)
 Pascal style "readln" function to read VECTOR_3D components.
 
static int read (FILE *ff, char *value_x)
 Pascal style "read" function to read string.
 
static int read (FILE *ff, int *value_x)
 Pascal style "read" function to read int.
 
static int read (FILE *ff, long *value_x)
 Pascal style "read" function to read long.
 
static int read (FILE *ff, float *value_x)
 Pascal style "read" function to read float.
 
static int read (FILE *ff, double *value_x)
 Pascal style "read" function to read double.
 
static int read (FILE *ff, long double *value_x)
 Pascal style "read" function to read long double.
 
static int read (FILE *ff, VECTOR_3D *vec)
 Pascal style "read" function to read VECTOR_3D components.
 
- Static Public Member Functions inherited from MEMFUN
static void * operator new (size_t st, const char *text="(unknown)", int ierr_print=1)
 Overloaded "new" operator initializing object with zeros.
 

Detailed Description

AIRFOIL class to manipulate the airfoil geometry or
it can read geometry data from file (5 commonly used fromats) or generate 4-digit and 5-digit naca airfoils
Geometry data (coordinates) is stored in the arrays.


included to PanuklConfigLib 20.11.2020

Definition at line 40 of file airfoil.h.

Constructor & Destructor Documentation

◆ AIRFOIL()

AIRFOIL::AIRFOIL ( void )

Definition at line 29 of file airfoil.cpp.

30{
31 Xd = 0;
32 Xg = 0;
33 Zd = 0;
34 Zg = 0;
35 Xf = 0;
36 Zf = 0;
37 Xrob = 0;
38 Zrob = 0;
39 N = 0;
40 Nf = 0;
41 Nrob = 0;
42
43 /* Types:
44 0 - PRF - PANUKL (prf1) - native PANUKL (4 columns) format \n
45 1 - PRF - prf2 - by L.Wiechers- NAME in header, N below header \n
46 2 - KOO - koordinate by L.Wiechers \n
47 3 - DAT - SELIG - (Xfoil) \n
48 4 - DAT - LEDNICER
49 */
50
51 iType = 0;
52 iReadType = 0;
53 memset( cName, 0, 100 );
54}
double * Xf
X coordinates (Nf points)
Definition airfoil.h:99
double * Xd
X coordinates of lower contour (N points)
Definition airfoil.h:103
double * Zf
Z coordinates (Nf points)
Definition airfoil.h:100
int Nf
size of the vectors with geometry data - compatible with Xfoil
Definition airfoil.h:98
char cName[100]
filename (without path)
Definition airfoil.h:117
int iType
File type: 0 - PRF - PANUKL (prf1) - native PANUKL (4 columns) format 1 - PRF - prf2 - by L....
Definition airfoil.h:115
int N
size of the vectors with geometry data - 4 column native PANUKL format
Definition airfoil.h:102
double * Zg
Z coordinates of upper contour (N points)
Definition airfoil.h:106
double * Zd
Z coordinates of lower contour (N points)
Definition airfoil.h:105
double * Xg
X coordinates of upper contour (N points)
Definition airfoil.h:104

◆ ~AIRFOIL()

AIRFOIL::~AIRFOIL ( void )
inline

Definition at line 141 of file airfoil.h.

141{ Clean(); };
void Clean(void)
cleans local variables
Definition airfoil.cpp:56

Member Function Documentation

◆ Clean()

void AIRFOIL::Clean ( void )

cleans local variables

Definition at line 56 of file airfoil.cpp.

57{
58 DELETE_TAB( Xd );
59 DELETE_TAB( Xg );
60 DELETE_TAB( Zd );
61 DELETE_TAB( Zg );
62 DELETE_TAB( Xf );
63 DELETE_TAB( Zf );
64 DELETE_TAB( Xrob );
65 DELETE_TAB( Zrob );
66 N = 0;
67 Nf = 0;
68 Nrob = 0;
69 iType = 0;
70 memset( cName, 0, 100 );
71}
#define DELETE_TAB(OBJ)
Macro for safe deleteing the array and sets the pointer to zero.
Definition memfun.h:97

Referenced by Read().

◆ GetReadType()

int AIRFOIL::GetReadType ( void )
inline

returns the type of format recognition:
0 - recognition by content (default),
1 - recognition by filename extention

Definition at line 129 of file airfoil.h.

129{ return iReadType; };

◆ Print()

void AIRFOIL::Print ( FILE * f = stdout)

prints PRF file (default on stdout)

Definition at line 681 of file airfoil.cpp.

681 {
682
683 fprintf(f,"%d\t#\t%s\n", N, cName );
684 for( int i=0; i<N; i++ )
685 fprintf(f,"%f %f %f %f\n", Xg[i], Zg[i], Xd[i], Zd[i] );
686
687}

◆ Read()

int AIRFOIL::Read ( char * cFile)

reads profile file

Definition at line 73 of file airfoil.cpp.

74{
75 Clean();
76
77 fprintf(stderr,"iReadType %d\n",iReadType);
78 if( iReadType )
79 getiTypeByContent(cFile); // gets file type by content
80 if( iReadType == 0 || iType == -1 )
81 getiTypeByExt(cFile); // gets file type by extension
82
83 // in case no type was detected finish
84 if(iType==-1)
85 {
86 fprintf(stderr,"No correct file was provided!\n");
87 return -1;
88 }
89
90 fprintf(stderr, "airfoil %s type %d\n", cFile, iType );
91
92 switch( iType )
93 {
94 default:
95 case 0:
96 if( Read_PRF_0( cFile ) )return -1;
97 break;
98 case 1:
99 if( Read_PRF_1( cFile ) )return -1;
100 break;
101 case 2:
102 if( Read_KOO( cFile ) )return -1;
103 break;
104 case 3:
105 if( Read_DAT( cFile ) )return -1;
106 break;
107 case 4:
108 if( Read_DAT_LEDNICER( cFile ) )return -1;
109 break;
110 }
111
112 return 0;
113}

◆ ReadNaca() [1/2]

int AIRFOIL::ReadNaca ( char * cNACA,
int NN = 100 )

generates NACA airfoil given by string (e.g. cNACA = "23012"),
NN - the number of points that define the airfoil geometry

Definition at line 144 of file airfoil.cpp.

145{
146 sprintf(cName, "NACA %s", cNACA );
147
148 NACA_PROFILE *NacaProfile = new NACA_PROFILE();
149 NacaProfile->setTE0( 1 );
150 NacaProfile->generate_naca( cNACA, NN );
151
152 Nf = NacaProfile->N;
153 Xf = new double[Nf+1];
154 Zf = new double[Nf+1];
155
156 for( int i=0; i<Nf; i++ )
157 {
158 Xf[i] = NacaProfile->X[i];
159 Zf[i] = NacaProfile->Z[i];
160 }
161
162 DELETE_(NacaProfile);
163
164 XFOIL2PRF();
165
166 return 0;
167}
NACA_PROFILE class to generate 4-digit and 5-digit naca airfoils Created by Alexandre Naaman (hoser...
Definition naca.h:69
int generate_naca(char *name, int num, FILE *fp)
generates naca airfoil coordinates (NN points) and stores it in file defined by stream "fp"
Definition naca.cpp:314
void setTE0(int TE=1)
TE=1 forces the zero thickness trailing edge.
Definition naca.h:108
double * Z
z coordinates vecotr
Definition naca.h:111
int N
coordiantes vectors' size
Definition naca.h:112
double * X
x coordinates vector
Definition naca.h:110
#define DELETE_(OBJ)
Macro for safe deleteing the object and sets the pointer to zero.
Definition memfun.h:84

◆ ReadNaca() [2/2]

int AIRFOIL::ReadNaca ( long int iNACA,
int NN = 100 )

generates NACA airfoil given by long int value (e.g. iNACA = 23012),
NN - the number of points that define the airfoil geometry

Definition at line 137 of file airfoil.cpp.

138{
139 char cNACA[10];
140 sprintf(cNACA, "%04ld", iNACA );
141 return ReadNaca( cNACA );
142}
int ReadNaca(long int iNACA, int NN=100)
generates NACA airfoil given by long int value (e.g. iNACA = 23012), NN - the number of points that...
Definition airfoil.cpp:137

Referenced by ReadNaca().

◆ ReadStatus()

int AIRFOIL::ReadStatus ( void )
inline

returns read status: 0 - no data, 1 - data read succesfuly

Definition at line 127 of file airfoil.h.

127{ return iRead; };
int iRead
0 - no data, 1 - data read succesfuly
Definition airfoil.h:91

◆ SetReadType()

void AIRFOIL::SetReadType ( int iRT)
inline

sets the type of format recognition

Definition at line 131 of file airfoil.h.

131{ iReadType = iRT; };

◆ Write()

int AIRFOIL::Write ( char * cFile,
int iTyp = 0 )

saves profile file - two types are available:
0 - native PANUKL (4 columns)
3 - SELIG (Xfoil compatible)
other - no action

Definition at line 115 of file airfoil.cpp.

116{
117 switch( iTyp )
118 {
119 default:
120 case 0:
121 if( Write_PRF( cFile ) )return -1;
122 break;
123/* case 1:
124 if( Write_PRF_1( cFile ) )return -1;
125 break;
126 case 2:
127 if( Write_KOO( cFile ) )return -1;
128 break;
129*/ case 3:
130 if( Write_DAT( cFile ) )return -1;
131 break;
132 }
133
134 return 0;
135}

Member Data Documentation

◆ alert

void(* AIRFOIL::alert) (char *c) = NULL
protected

virtual fuction to display the message (if iGUI > 0)

Definition at line 94 of file airfoil.h.

◆ cName

char AIRFOIL::cName[100]

filename (without path)

Definition at line 117 of file airfoil.h.

Referenced by Clean(), Print(), and ReadNaca().

◆ iGUI

int AIRFOIL::iGUI
protected

GUI flag - messages displayed using wrapping function "alert".

Definition at line 93 of file airfoil.h.

◆ iRead

int AIRFOIL::iRead
protected

0 - no data, 1 - data read succesfuly

Definition at line 91 of file airfoil.h.

Referenced by ReadStatus().

◆ iType

int AIRFOIL::iType

File type:
0 - PRF - PANUKL (prf1) - native PANUKL (4 columns) format
1 - PRF - prf2 - by L.Wiechers- NAME in header, N below header
2 - KOO - koordinate by L.Wiechers
3 - DAT - SELIG - (Xfoil)
4 - DAT - LEDNICER.

Definition at line 115 of file airfoil.h.

Referenced by Clean(), and Read().

◆ N

int AIRFOIL::N

size of the vectors with geometry data - 4 column native PANUKL format

Definition at line 102 of file airfoil.h.

Referenced by Clean(), and Print().

◆ Nf

int AIRFOIL::Nf

size of the vectors with geometry data - compatible with Xfoil

Definition at line 98 of file airfoil.h.

Referenced by Clean(), and ReadNaca().

◆ Xd

double* AIRFOIL::Xd

X coordinates of lower contour (N points)

Definition at line 103 of file airfoil.h.

Referenced by Clean(), and Print().

◆ Xf

double* AIRFOIL::Xf

X coordinates (Nf points)

Definition at line 99 of file airfoil.h.

Referenced by Clean(), and ReadNaca().

◆ Xg

double* AIRFOIL::Xg

X coordinates of upper contour (N points)

Definition at line 104 of file airfoil.h.

Referenced by Clean(), and Print().

◆ Zd

double* AIRFOIL::Zd

Z coordinates of lower contour (N points)

Definition at line 105 of file airfoil.h.

Referenced by Clean(), and Print().

◆ Zf

double* AIRFOIL::Zf

Z coordinates (Nf points)

Definition at line 100 of file airfoil.h.

Referenced by Clean(), and ReadNaca().

◆ Zg

double* AIRFOIL::Zg

Z coordinates of upper contour (N points)

Definition at line 106 of file airfoil.h.

Referenced by Clean(), and Print().


The documentation for this class was generated from the following files: