Skip to content

Commit fe80097

Browse files
committed
Add obstacles : square, diamond and NACA 0012 profil
1 parent 1845947 commit fe80097

File tree

11 files changed

+724
-312
lines changed

11 files changed

+724
-312
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.5)
22

3-
project(RTCFD_Code VERSION 0.1 LANGUAGES CXX)
3+
project(RTCFD_Code VERSION 0.01 LANGUAGES CXX)
44

55
set(CMAKE_CXX_STANDARD 17)
66
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -41,10 +41,10 @@ set(PROJECT_SOURCES
4141

4242
add_executable(RTCFD_Code ${PROJECT_SOURCES})
4343

44-
target_link_libraries(RTCFD_Code PRIVATE ${wxWidgets_LIBRARIES} -O3 -fopenmp)
44+
target_link_libraries(RTCFD_Code PRIVATE ${wxWidgets_LIBRARIES} -O3 -fopenmp -ltbb)
4545

4646
set_target_properties(RTCFD_Code PROPERTIES
47-
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
47+
MACOSX_BUNDLE_GUI_IDENTIFIER sofiane.khelladi.page
4848
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
4949
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
5050
MACOSX_BUNDLE TRUE

include/draw (copie).h

Lines changed: 0 additions & 65 deletions
This file was deleted.

include/draw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class Draw : public wxPanel
3737
void onMouseReleased(wxMouseEvent& event);
3838
void animate(wxTimerEvent& event);
3939

40+
//OBJ object=CYLINDER;
41+
4042
// wxTimer *m_timer;
4143
int loop;
4244
wxBitmap m_Bitmap;

include/fluid.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <math.h>
77
#include <algorithm>
88

9+
#include "settings.h"
10+
911
#define U_FIELD 0
1012
#define V_FIELD 1
1113
#define S_FIELD 2
@@ -29,9 +31,9 @@ class Fluid
2931
double sampleField(double x, double y, int field);
3032
double avgU(int i, int j);
3133
double avgV(int i, int j);
32-
void ComputeVelMagnitude();
33-
void advectVel(double dt);
34-
void advectSmoke(double dt);
34+
void computeVelosityMagnitude();
35+
void advectVelocity(double dt);
36+
void advectTracer(double dt);
3537
void simulate(double dt, double gravity, int numIters);
3638
// ----------------- end of simulator ------------------------------
3739

include/region.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@
33
#include <iostream>
44
#include "fluid.h"
55

6+
enum OBJ {CYLINDER, SQUARE, DIAMOND, NACA, ROTOR};
7+
8+
// #define CALL_SET_OBSTACLE(object,ptrToMember) (object.*ptrToMember)
9+
10+
// class Region;
11+
// typedef void (Region::*SET_OBSTACLE)(double, double, bool);
12+
13+
14+
615
using namespace std;
716

17+
818
class Region
919
{
1020
public:
@@ -23,6 +33,11 @@ class Region
2333

2434
void setupRegion(int _RegionNr = 0, double _overRelaxation=1.9, int _resolution=50, double _density=1000, int _numThreads=4);
2535
void setObstacle(double x, double y, bool reset);
36+
void setObstacleCylinder(double x, double y, bool reset);
37+
void setObstacleSquare(double x, double y, bool reset);
38+
void setObstacleDiamond(double x, double y, bool reset);
39+
void setObstacleNaca(double x, double y, bool reset);
40+
void setObstacleRotor(double x, double y, bool reset);
2641
void updateRegionSize(int _height, int _width);
2742
void update();
2843

@@ -36,7 +51,7 @@ class Region
3651
double overRelaxation= 1.9;
3752
double obstacleX= 0.0;
3853
double obstacleY= 0.0;
39-
double obstacleRadius= 0.15;
54+
double characteristic_length= 0.15;
4055
bool paused= false;
4156
int RegionNr= 0;
4257
bool showObstacle= false;
@@ -58,6 +73,8 @@ class Region
5873
int resolution;
5974
int numThreads;
6075

76+
OBJ obstacle;
6177
};
6278

79+
6380
#endif // Region_H

include/settings.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,54 @@
22
#define SETTINGS_H_INCLUDED
33

44
#include <wx/wx.h>
5+
#include <vector>
6+
#include <algorithm>
7+
// #include <execution>
8+
9+
using namespace std;
10+
11+
// Structure pour représenter un point en 2D
12+
struct Point {
13+
double x;
14+
double y;
15+
};
16+
17+
// Fonction de comparaison de points selon leur abscisse
18+
// bool comparePoints(const Point &a, const Point &b);
519

620
wxArrayString getCaseList();
721
wxArrayString getObstacleList();
822
wxArrayString getScalarList();
923

24+
vector<wxPoint> getSquarePoints(wxPoint pos, double length);
25+
vector<Point> getSquarePoints(Point pos, double length);
26+
27+
vector<wxPoint> getDiamondPoints(wxPoint pos, double length);
28+
vector<Point> getDiamondPoints(Point pos, double length);
29+
30+
vector<wxPoint> getNacaPoints(wxPoint pos, double length);
31+
vector<Point> getNacaPoints(Point pos, double length);
32+
vector<Point> generateNacaProfile(Point pos, double chord, double thickness, int nb_points, double incidence=M_PI/12);
33+
vector<wxPoint> generateNacaProfile(wxPoint pos, double chord, double thickness, int nb_points, double incidence=M_PI/12);
34+
35+
vector<vector<Point>> generateRotorPoints(Point pos, double length);
36+
vector<vector<wxPoint>> generateRotorPoints(wxPoint pos, double length);
37+
vector<vector<Point>> generateRotor(Point center, double radius, double chord, double thickness, int nb_points, int Z);
38+
vector<vector<wxPoint>> generateRotor(wxPoint center, double radius, double chord, double thickness, int nb_points, int Z);
39+
40+
41+
42+
43+
wxPoint *fromVectorToPtr(vector<wxPoint> pt);
44+
45+
// bool isPointInPolygon(vector<wxPoint> P, wxPoint M);
46+
47+
// bool isInside(vector<Point> polygon, Point P);
48+
bool isInsidePolygon(vector<Point> polygon, Point P);
49+
vector<Point> rotatePolygon(vector<Point> polygon, Point center, double theta);
50+
vector<wxPoint> rotatePolygon(vector<wxPoint> polygon, wxPoint center, double theta);
51+
vector<vector<Point>> generateCircularRepeats(vector<Point> polygon, Point center, int n);
52+
53+
1054

1155
#endif // SETTINGS_H_INCLUDED

0 commit comments

Comments
 (0)