Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] jBAY and BAY vortex generator model #2273

Draft
wants to merge 115 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
913be46
Implemented class skeleton for Source term calculation
maxi120 Dec 27, 2023
0b37f2a
Added Cconfig options
maxi120 Jan 4, 2024
d24f5b1
Added initialization of source class in CDriver
maxi120 Jan 4, 2024
d6dd950
Added read config to generate VGs
maxi120 Jan 5, 2024
25257a2
Added implementation to preprocess the source term
maxi120 Jan 5, 2024
0bfc4cb
Added intersection edge algorithm anbd debug output source
maxi120 Jan 8, 2024
635bb5b
Added plane intersection
maxi120 Jan 8, 2024
9e61171
FIxed Normal not found in numerics
maxi120 Jan 8, 2024
1728c55
Added IntersectEdge and PointInConvexPolygon in GeometryToolbox
maxi120 Jan 8, 2024
4915efe
Fixed Intersect Edge Function
maxi120 Jan 8, 2024
e80095e
Refactored with new function
maxi120 Jan 8, 2024
d93924b
Fixed PointInCOnvexPolygon
maxi120 Jan 10, 2024
9f8b131
Added index acces to CNumerics
maxi120 Jan 10, 2024
64cc87f
Added source Initialization
maxi120 Jan 10, 2024
1daa486
Fix edge loop
maxi120 Jan 12, 2024
94b8830
Fixed RayCasting algorithm
maxi120 Jan 12, 2024
d03d277
Updated idx finder for easier debugging
maxi120 Jan 16, 2024
fddef7c
Updated PointInConvexPolygon
maxi120 Jan 16, 2024
76f7505
Added computation sorce term
maxi120 Jan 17, 2024
f171d93
Added hardcoded bay computation
maxi120 Jan 18, 2024
a3def55
Added parallel suppport for Vtot
maxi120 Jan 18, 2024
89cef17
fixed initializtion CDriver
maxi120 Jan 19, 2024
c8e3f64
added jacobian
maxi120 Jan 19, 2024
e1c42cc
Fixed source initialization parallel
maxi120 Jan 19, 2024
fe62f0e
Tried to fix memory issues
maxi120 Jan 19, 2024
a328e58
Fixed some memory stuff
maxi120 Jan 19, 2024
22e83a4
fix memory stuff
maxi120 Jan 19, 2024
9882ffd
Fixed old stuff
maxi120 Jan 19, 2024
d19ed91
Fixed crashig SU2
maxi120 Jan 19, 2024
88bf1da
Comments + Fix jacobain indexes cross product contribution
maxi120 Jan 22, 2024
7d7d54b
Added division by rho**2 in Jacobian
maxi120 Jan 22, 2024
63ff0dd
debug addition
maxi120 Jan 23, 2024
0143f3f
Removed addition on GEometryToolBox
maxi120 Jan 23, 2024
3c30481
Generalised PointInPolygon algorithm
maxi120 Jan 24, 2024
a37bb26
Missing brace
maxi120 Jan 24, 2024
29a168c
Added tolerance for projection PointInPolygon
maxi120 Jan 25, 2024
bf4a362
Added support for any VG orientation + MPI flags
maxi120 Jan 25, 2024
e59afa3
Hotfix vg defnition vectors
maxi120 Jan 26, 2024
365be9e
Hotfix direction vg
maxi120 Jan 26, 2024
1bf1df7
Added normalization to PointInPolygon plane
maxi120 Jan 26, 2024
8960873
Updated residual calculations
maxi120 Jan 31, 2024
6952ac4
Added jBAY model
maxi120 Feb 2, 2024
35bbab3
Fixed numerical cancelation velocity interpolation
maxi120 Feb 2, 2024
00bdb87
added enum option and fixed jbay
maxi120 Feb 5, 2024
e4dbeff
Fixed interpo
maxi120 Feb 5, 2024
20935cd
Updated for efficiency source calculation loop
maxi120 Feb 9, 2024
0d8ec27
Added comments
maxi120 Feb 12, 2024
f55faa5
Refactoring
maxi120 Feb 13, 2024
2df303a
Fixed double volume problem in locator algorithm
maxi120 Feb 13, 2024
ffab49c
Add deconstructor to prevent memory leaks
maxi120 Feb 13, 2024
240666c
Add comments in the Solver
maxi120 Feb 14, 2024
952cace
changed comment style
maxi120 Feb 16, 2024
49216ec
Added comments and cleaned up geometry toolbox
maxi120 Feb 22, 2024
3c1261f
Changed Edge data strcture to struct
maxi120 Feb 28, 2024
c8594cb
Merge remote-tracking branch 'origin/develop' into feature_VGBAYModel
maxi120 Feb 28, 2024
ba7ae64
Refactor BAY model initialization
maxi120 Feb 28, 2024
a685275
Removed reduntant checks and added support for triangular VGs
maxi120 Feb 28, 2024
1d92e3e
Fixes
maxi120 Mar 5, 2024
f39133f
Added CVgOption
maxi120 Mar 5, 2024
07cf43a
Temporary fix to make it compile
maxi120 Mar 6, 2024
13f2718
Moved VG coordinates, construction and config reading to CConfig.
maxi120 Mar 8, 2024
dddbae2
Added support for RIgid_Pitching
maxi120 Mar 12, 2024
1a20ce5
Moved to external loop
maxi120 Mar 14, 2024
e9f6c89
Hotfix vector not in CConf
maxi120 Mar 14, 2024
58aa325
Hotfix crashes withou BAY
maxi120 Mar 14, 2024
05344d2
Ficced output debug + file parsing loop
maxi120 Mar 17, 2024
6c37618
Restart support for pitching
maxi120 Mar 18, 2024
d5a92fb
Fixed segfault
maxi120 Mar 20, 2024
a7632ee
Removed unused variables
maxi120 Mar 20, 2024
d5ef022
removed unused varibles
maxi120 Mar 20, 2024
0eaec56
Deallocate Svg
maxi120 Mar 20, 2024
5980013
Moved deallocation coords_vg to CConfig
maxi120 Mar 20, 2024
4706c9d
Fix memory free
maxi120 Mar 21, 2024
27affa0
Merge branch 'feature_VGBAYModel_gridMovemen_master' of https://githu…
maxi120 Mar 21, 2024
10bb9ed
Removed override from CConf deconstructor
maxi120 Mar 21, 2024
74e1c37
Moved file reading to CSolver
maxi120 Apr 2, 2024
8303f90
Added restart file support for Unsteady
maxi120 Apr 5, 2024
b505b1f
Fix bug cell locator
maxi120 Apr 16, 2024
65e19a6
Comments and refactor
maxi120 Apr 16, 2024
2b680d5
Cleaned up
maxi120 Apr 17, 2024
043e0d9
pre-commit hooks + clean up COptionVG
maxi120 Apr 18, 2024
0823737
typo fix
maxi120 Apr 18, 2024
23dd88e
Extended to compressible solver
maxi120 Apr 18, 2024
c6caca7
Added deconstructor for variables
maxi120 Apr 19, 2024
17d6400
Added daptive projection plane selectuion in PointInPolygon
maxi120 Apr 19, 2024
d7cba25
Moved deconstructure for vg variables to CConfig
maxi120 Apr 19, 2024
cb358d6
Fixed memory leaks + cleanup
maxi120 Apr 19, 2024
8ee9b75
Refcatoring flowsources,CNumerics and CSolver
maxi120 Apr 23, 2024
af6e961
updated submodules
maxi120 Apr 23, 2024
bf18ba5
Hotfic geometrytoolbox
maxi120 Apr 24, 2024
cb2637b
Added support for 1st order timestepping
maxi120 Apr 25, 2024
8385ddd
Reactoring
maxi120 Apr 25, 2024
0a3ffc0
Extended support to rigid planging and tarnslation
maxi120 Apr 27, 2024
98629c5
Merge remote-tracking branch 'origin/master' into feature_VGBAYModel
maxi120 Apr 27, 2024
1597275
run pre-commit
maxi120 Apr 27, 2024
fc92fab
Updated submodules
maxi120 Apr 27, 2024
122caa4
merged develop
maxi120 Apr 27, 2024
0331b4e
typo
maxi120 Apr 27, 2024
106fbd3
typo
maxi120 Apr 27, 2024
dded5dd
Reformatted CEulerSolver CIncEulerSolver
maxi120 Apr 27, 2024
ecba7fe
typo
maxi120 Apr 27, 2024
5aba4b8
Refactor
maxi120 Apr 27, 2024
ef9285b
Updated external packages
maxi120 Apr 29, 2024
4f12c24
refactored CSolver
maxi120 Apr 29, 2024
7edc68b
Refactored CSolver
maxi120 Apr 29, 2024
e30dcec
Merge remote-tracking branch 'origin/develop' into feature_VGBAYModel…
maxi120 Apr 30, 2024
048967b
Refactor CNumerics
maxi120 Apr 30, 2024
19c8d09
Fixed n
maxi120 May 1, 2024
afdd282
Chenged calculation of n.
maxi120 May 2, 2024
7a033e7
Add flip n vector
maxi120 May 6, 2024
837852d
Fixed file parsing
maxi120 May 6, 2024
be7ef75
Refactoring and bug fixes in reading config file
maxi120 May 7, 2024
fb05c8a
Fixed n vector orientation
maxi120 May 20, 2024
697e1e2
Imporved file handling
maxi120 May 24, 2024
737dbe3
Added options to config template
maxi120 May 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,23 @@ class CConfig {
string* user_scalar_names; /*!< \brief Names of the user defined (auxiliary) transported scalars .*/
string* user_source_names; /*!< \brief Names of the source terms for the user defined transported scalars. */

/*--- Vortex Generator model config options ---*/ // Added by Max
string vg_filename;
su2double vg_constant;
ENUM_VG_MODEL vg_bay;

unsigned short nVgs=0;
su2double ***Vg_Coordinates=nullptr;
su2double **Vg_SurfaceNormalDirection=nullptr,
**Vg_SurfaceTangentialDirection=nullptr,
**Vg_SurfaceCrossFlowDirection=nullptr,
**Vg_StreamwiseDirection=nullptr;
su2double *Vg_SurfaceArea=nullptr,
*Vg_Angle=nullptr;
unsigned short nPointsVG = 4;

// End by Max

/*!
* \brief Set the default values of config options not set in the config file using another config object.
* \param config - Config object to use the default values from.
Expand Down Expand Up @@ -1379,6 +1396,11 @@ class CConfig {
unsigned short& nMarker_ActDiskBemInlet, unsigned short& nMarker_ActDiskBemOutlet, string*& Marker_ActDiskBemInlet, string*& Marker_ActDiskBemOutlet,
su2double**& ActDiskBem_X, su2double**& ActDiskBem_Y, su2double**& ActDiskBem_Z);

//added by max
// void addVgOption(const string& name, unsigned short& nVgs, su2double***& Vg_Coordinates,
// su2double**& Vg_SurfaceNormalDirection, su2double**& Vg_SurfaceTangentialDirection, su2double**& Vg_SurfaceCrossFlowDirection,su2double*& Vg_SurfaceArea,ENUM_VG_MODEL& bayModel);
//emd added by max

void addWallFunctionOption(const string &name, unsigned short &list_size,
string* &string_field, WALL_FUNCTIONS* &val_Kind_WF,
unsigned short** &val_IntInfo_WF, su2double** &val_DoubleInfo_WF);
Expand Down Expand Up @@ -9859,4 +9881,126 @@ class CConfig {
*/
LM_ParsedOptions GetLMParsedOptions() const { return lmParsedOptions; }

//Added by Max
/*!
* \brief Check which vortex generator model is in use.
* \return Vortex Genrator Model.
*/
ENUM_VG_MODEL GetVGModel(void) const {return vg_bay; }

/*!
* \brief Get VG Model calibration constant.
* \return Bay model calibration constant.
*/
su2double GetVGConstant(void) const {return vg_constant;}

/*!
* \brief Set vortex generator height vector.
* \param[in] b - height vector.
*/
void Set_bVG(su2double** b) { Vg_SurfaceNormalDirection = b; }

/*!
* \brief Ger vortex generator height vector.
* \param[in] iVg - Vortex generator index
* \return height vector.
*/
su2double* Get_bVG(unsigned short iVg) const { return Vg_SurfaceNormalDirection[iVg]; }

/*!
* \brief Set vortex generator normal vector.
* \param[in] n - height vector.
*/
void Set_nVG(su2double** n) { Vg_SurfaceCrossFlowDirection = n; }

/*!
* \brief Get vortex generator normal vector.
* \param[in] iVg - Vortex generator index
* \return height vector.
*/
su2double* Get_nVG(unsigned short iVg) const { return Vg_SurfaceCrossFlowDirection[iVg]; }

/*!
* \brief Set vortex generator tangential vector.
* \param[in] t - tangential vector.
*/
void Set_tVG(su2double** t) { Vg_SurfaceTangentialDirection = t; }

/*!
* \brief Get vortex generator tangential vector.
* \param[in] iVg - Vortex generator index
* \return tangential vector.
*/
su2double* Get_tVG(unsigned short iVg) const { return Vg_SurfaceTangentialDirection[iVg]; }

/*!
* \brief Get vortex generator coordinates.
* \param[in] iVg - Vortex generator index
* \param[in] vg_coord - vortex generator coordinates.
*/
su2double** GetVGcoord(unsigned short iVg) const {return Vg_Coordinates[iVg];}

/*!
* \brief Set vortex generator coordinates.
* \param[in] vg_coord - vortex generator coordinates.
*/
void SetVGCoord(su2double ***vg_coord){Vg_Coordinates=vg_coord;}
/*!
* \brief Get number of vortex generators for a specific problem.
* \return - Number of vortex genrators for a specific zone.
*/
unsigned short Get_nVGs(void) const {return nVgs;}

/*!
* \brief Set number of vortex generators for a specific problem.
* \param[in] nVgs_zone - Number of vortex genrators for a specific zone.
*/
void Set_nVGs(unsigned short nVgs_zone){nVgs=nVgs_zone;}

/*!
* \brief Get number of vortex generators for a specific problem.
* \return - Number of vortex genrators for a specific zone.
*/
unsigned short Get_nPointsVg() const {return nPointsVG;};
/*!
* \brief Get vortex generators area.
* \param[in] iVg - Vortex generator index
* \return Area of the vortex generators plane.
*/
su2double Get_Svg(unsigned short iVg) const {return Vg_SurfaceArea[iVg];}

/*!
* \brief Set vortex generators area.
* \param[in] Svg - Areas of the vortex generators planes.
*/
void Set_Svg(su2double* Svg){Vg_SurfaceArea=Svg;}

/*!
* \brief Set vortex generators streawise direction.
* \param[in] Vg_StreamwiseDirection - Vortex generators streawise direction.
*/
void Set_uhatVg(su2double** uhat){Vg_StreamwiseDirection=uhat;}

/*!
* \brief Get vortex generators streawise direction.
* \param[in] iVg - Vortex generator index
* \return Vortex generators streawise direction.
*/
su2double* Get_uhatVg(unsigned short iVG) const {return Vg_StreamwiseDirection[iVG];}
/*!
* \brief Set vortex generators angles.
* \param[in] beta - Vortex generators angles.
*/
void Set_betaVg(su2double *beta){Vg_Angle=beta;}

/*!
* \brief Get vortex generators angles.
* \param[in] iVg - Vortex generator index
* \return Vortex generator angle.
*/
su2double Get_betaVg(unsigned short iVg) const {return Vg_Angle[iVg];}


const string& GetVGFileName() const {return vg_filename;}
//End added by max
};
13 changes: 13 additions & 0 deletions Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2571,6 +2571,19 @@ static const MapType<std::string, ENUM_PROJECTION_FUNCTION> Projection_Function_
MakePair("HEAVISIDE_UP", ENUM_PROJECTION_FUNCTION::HEAVISIDE_UP)
MakePair("HEAVISIDE_DOWN", ENUM_PROJECTION_FUNCTION::HEAVISIDE_DOWN)
};
//Added by max

enum class ENUM_VG_MODEL{
NONE,
BAY,
JBAY
};
static const MapType<std::string,ENUM_VG_MODEL> VgModel_Map={
MakePair("NONE",ENUM_VG_MODEL::NONE)
MakePair("BAY",ENUM_VG_MODEL::BAY)
MakePair("JBAY",ENUM_VG_MODEL::JBAY)
};
//End added by max

/*!
* \brief the different validation solution
Expand Down
95 changes: 95 additions & 0 deletions Common/include/toolboxes/geometry_toolbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,100 @@ inline void TangentProjection(Int nDim, const Mat& tensor, const Scalar* vector,

for (Int iDim = 0; iDim < nDim; iDim++) proj[iDim] -= normalProj * vector[iDim];
}
// Added by max

/*!
* \brief Check if the edge intersects the plane
* \param[in] nDim - Number of dimensions of the particular problem.
* \param[in] p0 - Point defining the plane.
* \param[in] n - Plane normal vector.
* \param[in] p1,p2 - Points defining the edge
* \return Returns <code>TRUE</code> if the edge intersect the plane, <code>FALSE</code> it doesn't.
*/
template <class T, class Int>
inline bool IntersectEdge(Int nDim, const T* p0, const T* n, const T* p1, const T* p2) {
T d = -DotProduct(nDim, n, p0);
auto a = DotProduct(nDim, n, p1) + d;
auto b = DotProduct(nDim, n, p2) + d;
if (a * b <= 0 && (a != 0 || b != 0))
return true;
else
return false;
}

/*!
* \brief Check if a point is inside a polygon
* \param[in] nDim - Number of dimensions of the particular problem.
* \param[in] vector - Vector to normalize.
*/
template <class T, class Int>
inline void NormalizeVector(Int nDim, T* vector) {
T norm = Norm(nDim, vector);
for (Int i = 0; i < nDim; i++) vector[i] /= norm;
}

/*!
* \brief Check if a point is inside a polygon
* \param[in] nDim - Number of dimensions of the particular problem.
* \param[in] pVert - Point defining the polygon.
* \param[in] p0 - Point to test
* \param[in] nVert - Number of points that form the polygon.
* \return Returns TRUE if the edge intersect the plane, FALSE it doesn't.
*/
template <class Mat, class T, class Int>
inline bool PointInConvexPolygon(Int nDim, const Mat& pVert, const T* p0, int nVert) {
unsigned short i = 0, j = 1;
unsigned short idxPoint1 = 0, idxPoint2 = 1;
unsigned short nIntersections = 0;
unsigned short proj_index = 0;
T max_proj = 0;

/* Check which of the x,y,z planes is the most parallel to the polygon */

if (nDim == 3) {
T plane_norm[3];
TriangleNormal(pVert, plane_norm);
NormalizeVector(3, plane_norm);

for (unsigned short iDim = 0; iDim < nDim; iDim++) {
if (abs(plane_norm[iDim]) > max_proj) {
proj_index = iDim;
max_proj = abs(plane_norm[iDim]);
}
}

switch (proj_index) {
case 0:
i = 1;
j = 2;
break;
case 1:
i = 2;
j = 0;
break;
default:
i = 0;
j = 1;
break;
}
}

/* Loop across the polygon edges and check if the ray intersect a vertex */

for (unsigned short iVert = 1; iVert < nVert + 1; iVert++) {
idxPoint2 = iVert % nVert;

if (((p0[j] < pVert[idxPoint1][j]) != (p0[j] < pVert[idxPoint2][j])) &&
(p0[i] < pVert[idxPoint1][i] + ((p0[j] - pVert[idxPoint1][j]) / (pVert[idxPoint2][j] - pVert[idxPoint1][j])) *
(pVert[idxPoint2][i] - pVert[idxPoint1][i]))) {
nIntersections++;
}
idxPoint1 = idxPoint2;
}

return nIntersections % 2 == 1;
}

// end added by max
/// @}
} // namespace GeometryToolbox
49 changes: 49 additions & 0 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,18 @@ void CConfig::addActDiskBemOption(const string& name,
option_map.insert(pair<string, COptionBase *>(name, val));
}

// // added by max
// void CConfig::addVgOption(const string& name, unsigned short& nVgs,
// su2double***& Vg_Coordinates, su2double**& Vg_SurfaceNormalDirection,
// su2double**& Vg_SurfaceTangentialDirection, su2double**& Vg_SurfaceCrossFlowDirection,su2double*& Vg_SurfaceArea,ENUM_VG_MODEL& bayModel) {
// assert(option_map.find(name) == option_map.end());
// all_options.insert(pair<string, bool>(name, true));
// COptionBase* val = new COptionVGmodel(name, nVgs, Vg_Coordinates, Vg_SurfaceNormalDirection,
// Vg_SurfaceTangentialDirection, Vg_SurfaceCrossFlowDirection,Vg_SurfaceArea,bayModel);
// option_map.insert(pair<string, COptionBase*>(name, val));
// }
// // end added by max

void CConfig::addWallFunctionOption(const string &name, unsigned short &list_size, string* &string_field,
WALL_FUNCTIONS* &val_Kind_WF, unsigned short** &val_IntInfo_WF,
su2double** &val_DoubleInfo_WF) {
Expand Down Expand Up @@ -2961,6 +2973,20 @@ void CConfig::SetConfig_Options() {
/*!\brief ROM_SAVE_FREQ \n DESCRIPTION: How often to save snapshots for unsteady problems.*/
addUnsignedShortOption("ROM_SAVE_FREQ", rom_save_freq, 1);

//Added by Max

/*!\brief VG_CONST \n DESCRIPTION: Calibration constant for VG model.*/
addEnumOption("VG_MODEL", vg_bay,VgModel_Map, ENUM_VG_MODEL::NONE);

/*!\brief VG_CONST \n DESCRIPTION: Calibration constant for VG model.*/
addDoubleOption("VG_CONST", vg_constant, 10);

/*!\brief VG_CONFIG \n DESCRIPTION: VG configuration file name*/
addStringOption("VG_CONFIG", vg_filename, " ");
// addVgOption("VG_CONFIG",nVgs,Vg_Coordinates,Vg_SurfaceNormalDirection,Vg_SurfaceTangentialDirection,Vg_SurfaceCrossFlowDirection,Vg_SurfaceArea,vg_bay);

//End Max

/* END_CONFIG_OPTIONS */

}
Expand Down Expand Up @@ -8220,6 +8246,29 @@ CConfig::~CConfig() {

delete [] nBlades;
delete [] FreeStreamTurboNormal;
//Added by max

/*--- Free variables used for the VG model ---*/

for(unsigned short iVG=0;iVG<nVgs;iVG++){
for(unsigned short iPoint=0;iPoint<nPointsVG;iPoint++){
delete [] Vg_Coordinates[iVG][iPoint];
}
delete [] Vg_Coordinates[iVG];
delete [] Vg_SurfaceNormalDirection[iVG];
delete [] Vg_SurfaceTangentialDirection[iVG];
delete [] Vg_SurfaceCrossFlowDirection[iVG];
delete [] Vg_StreamwiseDirection[iVG];
}
delete [] Vg_Coordinates;
delete [] Vg_SurfaceNormalDirection;
delete [] Vg_SurfaceTangentialDirection;
delete [] Vg_SurfaceCrossFlowDirection;
delete [] Vg_StreamwiseDirection;
delete [] Vg_SurfaceArea;
delete [] Vg_Angle;

//End added by max
}

string CConfig::GetFilename(string filename, const string& ext, int timeIter) const {
Expand Down
Loading