Skip to content

Commit

Permalink
Add obstacles : square, diamond and NACA 0012 profil
Browse files Browse the repository at this point in the history
  • Loading branch information
skhelladi committed Dec 24, 2022
1 parent 1845947 commit fe80097
Show file tree
Hide file tree
Showing 11 changed files with 724 additions and 312 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.5)

project(RTCFD_Code VERSION 0.1 LANGUAGES CXX)
project(RTCFD_Code VERSION 0.01 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -41,10 +41,10 @@ set(PROJECT_SOURCES

add_executable(RTCFD_Code ${PROJECT_SOURCES})

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

set_target_properties(RTCFD_Code PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
MACOSX_BUNDLE_GUI_IDENTIFIER sofiane.khelladi.page
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
Expand Down
65 changes: 0 additions & 65 deletions include/draw (copie).h

This file was deleted.

2 changes: 2 additions & 0 deletions include/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class Draw : public wxPanel
void onMouseReleased(wxMouseEvent& event);
void animate(wxTimerEvent& event);

//OBJ object=CYLINDER;

// wxTimer *m_timer;
int loop;
wxBitmap m_Bitmap;
Expand Down
8 changes: 5 additions & 3 deletions include/fluid.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <math.h>
#include <algorithm>

#include "settings.h"

#define U_FIELD 0
#define V_FIELD 1
#define S_FIELD 2
Expand All @@ -29,9 +31,9 @@ class Fluid
double sampleField(double x, double y, int field);
double avgU(int i, int j);
double avgV(int i, int j);
void ComputeVelMagnitude();
void advectVel(double dt);
void advectSmoke(double dt);
void computeVelosityMagnitude();
void advectVelocity(double dt);
void advectTracer(double dt);
void simulate(double dt, double gravity, int numIters);
// ----------------- end of simulator ------------------------------

Expand Down
19 changes: 18 additions & 1 deletion include/region.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@
#include <iostream>
#include "fluid.h"

enum OBJ {CYLINDER, SQUARE, DIAMOND, NACA, ROTOR};

// #define CALL_SET_OBSTACLE(object,ptrToMember) (object.*ptrToMember)

// class Region;
// typedef void (Region::*SET_OBSTACLE)(double, double, bool);



using namespace std;


class Region
{
public:
Expand All @@ -23,6 +33,11 @@ class Region

void setupRegion(int _RegionNr = 0, double _overRelaxation=1.9, int _resolution=50, double _density=1000, int _numThreads=4);
void setObstacle(double x, double y, bool reset);
void setObstacleCylinder(double x, double y, bool reset);
void setObstacleSquare(double x, double y, bool reset);
void setObstacleDiamond(double x, double y, bool reset);
void setObstacleNaca(double x, double y, bool reset);
void setObstacleRotor(double x, double y, bool reset);
void updateRegionSize(int _height, int _width);
void update();

Expand All @@ -36,7 +51,7 @@ class Region
double overRelaxation= 1.9;
double obstacleX= 0.0;
double obstacleY= 0.0;
double obstacleRadius= 0.15;
double characteristic_length= 0.15;
bool paused= false;
int RegionNr= 0;
bool showObstacle= false;
Expand All @@ -58,6 +73,8 @@ class Region
int resolution;
int numThreads;

OBJ obstacle;
};


#endif // Region_H
44 changes: 44 additions & 0 deletions include/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,54 @@
#define SETTINGS_H_INCLUDED

#include <wx/wx.h>
#include <vector>
#include <algorithm>
// #include <execution>

using namespace std;

// Structure pour représenter un point en 2D
struct Point {
double x;
double y;
};

// Fonction de comparaison de points selon leur abscisse
// bool comparePoints(const Point &a, const Point &b);

wxArrayString getCaseList();
wxArrayString getObstacleList();
wxArrayString getScalarList();

vector<wxPoint> getSquarePoints(wxPoint pos, double length);
vector<Point> getSquarePoints(Point pos, double length);

vector<wxPoint> getDiamondPoints(wxPoint pos, double length);
vector<Point> getDiamondPoints(Point pos, double length);

vector<wxPoint> getNacaPoints(wxPoint pos, double length);
vector<Point> getNacaPoints(Point pos, double length);
vector<Point> generateNacaProfile(Point pos, double chord, double thickness, int nb_points, double incidence=M_PI/12);
vector<wxPoint> generateNacaProfile(wxPoint pos, double chord, double thickness, int nb_points, double incidence=M_PI/12);

vector<vector<Point>> generateRotorPoints(Point pos, double length);
vector<vector<wxPoint>> generateRotorPoints(wxPoint pos, double length);
vector<vector<Point>> generateRotor(Point center, double radius, double chord, double thickness, int nb_points, int Z);
vector<vector<wxPoint>> generateRotor(wxPoint center, double radius, double chord, double thickness, int nb_points, int Z);




wxPoint *fromVectorToPtr(vector<wxPoint> pt);

// bool isPointInPolygon(vector<wxPoint> P, wxPoint M);

// bool isInside(vector<Point> polygon, Point P);
bool isInsidePolygon(vector<Point> polygon, Point P);
vector<Point> rotatePolygon(vector<Point> polygon, Point center, double theta);
vector<wxPoint> rotatePolygon(vector<wxPoint> polygon, wxPoint center, double theta);
vector<vector<Point>> generateCircularRepeats(vector<Point> polygon, Point center, int n);



#endif // SETTINGS_H_INCLUDED
Loading

0 comments on commit fe80097

Please sign in to comment.