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] Implementation of Simplified LM Transition model #1901

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a7136d3
- Just copied the CTransLMSolver header and source to commit
rois1995 Jan 27, 2023
e9226db
- Start of implementation of Simplified LM transition model
rois1995 Jan 27, 2023
d03742a
- Modify number of variables if SLM option is used
rois1995 Jan 27, 2023
e17872d
- Updates on the transition model.
rois1995 Jan 31, 2023
4b9c615
- Added Cross flow effects for SLM
rois1995 Jan 31, 2023
04cd56d
- Fixed Intermittency_Sep computation for SLM.
rois1995 Feb 2, 2023
e29b4df
- Added computation for normals of grid points
rois1995 Feb 24, 2023
0319d62
Fixed normal extraction from structure
rois1995 Feb 24, 2023
b1edf61
Added computation of wall normals to the CPoint structure
rois1995 Feb 24, 2023
7eee4ab
Check For changes
rois1995 Apr 27, 2023
c461518
Removing changes for SA-R
rois1995 Apr 27, 2023
e68a9e4
Fixed vertex indexing for wall normal computation
rois1995 Apr 27, 2023
bcdd671
Removed a cout
rois1995 Apr 27, 2023
9bb2435
Fixed division by zero with Corr_Rec
rois1995 Apr 27, 2023
a9a6ce4
Removed cout
rois1995 Apr 27, 2023
86b068c
Fixed Max Velocity-Z output for Incompressible flow
rois1995 Apr 27, 2023
73c0a4b
Fixed output of Normals in volume
rois1995 Apr 27, 2023
8d5148e
- Added Simplified Langtry Menter model
rois1995 Jul 1, 2024
9db7301
- corrected bu in output
rois1995 Jul 1, 2024
1e7e7a3
Merge branch 'develop' into feature_Trans_SLM_v8
rois1995 Sep 12, 2024
ab2d71b
Merge remote-tracking branch 'origin/feature_Trans_SLM_v8' into featu…
rois1995 Sep 13, 2024
a6fe9bc
- finish update
rois1995 Sep 13, 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
66 changes: 62 additions & 4 deletions Common/include/geometry/dual_grid/CPoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ class CPoint {
su2vector<unsigned long>
ClosestWall_Elem; /*!< \brief Element index of closest wall element, for givenrank, zone and marker index. */

su2activevector SharpEdge_Distance; /*!< \brief Distance to a sharp edge. */
su2activevector Curvature; /*!< \brief Value of the surface curvature (SU2_GEO). */
su2activevector MaxLength; /*!< \brief The maximum cell-center to cell-center length. */
su2activevector RoughnessHeight; /*!< \brief Roughness of the nearest wall. */
su2activevector SharpEdge_Distance; /*!< \brief Distance to a sharp edge. */
su2activevector Curvature; /*!< \brief Value of the surface curvature (SU2_GEO). */
su2activevector MaxLength; /*!< \brief The maximum cell-center to cell-center length. */
su2activevector RoughnessHeight; /*!< \brief Roughness of the nearest wall. */
su2activematrix Normals; /*!< \brief Normal of the nearest wall element. */

su2matrix<int> AD_InputIndex; /*!< \brief Indices of Coord variables in the adjoint vector. */
su2matrix<int>
Expand Down Expand Up @@ -484,6 +485,27 @@ class CPoint {
}
inline void SetWall_Distance(unsigned long iPoint, su2double distance) { Wall_Distance(iPoint) = distance; }

/*!
* \brief Get the index of the closest wall element.
* \param[in] iPoint - Index of the point.
* \param[out] ClosestWall_Elem - ID of the closest element on a wall boundary.
*/
inline unsigned long GetClosestWall_Elem(unsigned long iPoint) {return ClosestWall_Elem(iPoint);}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the param[out] for these please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll do it now.


/*!
* \brief Get the marker of the closest wall marker.
* \param[in] iPoint - Index of the point.
* \param[out] ClosestWall_Marker - MarkerID of the closest wall boundary.
*/
inline unsigned long GetClosestWall_Marker(unsigned long iPoint) {return ClosestWall_Marker(iPoint);}

/*!
* \brief Get the rank of the closest wall marker.
* \param[in] iPoint - Index of the point.
* \param[out] ClosestWall_Rank - RankID of the closest wall boundary.
*/
inline unsigned long GetClosestWall_Rank(unsigned long iPoint) {return ClosestWall_Rank(iPoint);}

/*!
* \brief Get the value of the distance to the nearest wall.
* \param[in] iPoint - Index of the point.
Expand All @@ -506,6 +528,24 @@ class CPoint {
*/
inline su2double GetRoughnessHeight(unsigned long iPoint) const { return RoughnessHeight(iPoint); }

/*!
* \brief Set the value of the normal of the nearest wall element.
* \param[in] iPoint - Index of the point.
* \param[in] normal - Value of the normal.
*/
template<typename Normals_type>
inline void SetNormal(unsigned long iPoint, Normals_type const&normal) {
for (unsigned long iDim = 0; iDim < nDim; iDim++)
Normals(iPoint,iDim) = normal[iDim];
}

/*!
* \brief Set the value of the normal of the nearest wall element.
* \param[in] iPoint - Index of the point.
* \return normal to the normal of the nearest wall element.
*/
inline su2double *GetNormal(unsigned long iPoint) { return Normals[iPoint]; }

/*!
* \brief Set the value of the distance to a sharp edge.
* \param[in] iPoint - Index of the point.
Expand Down Expand Up @@ -906,4 +946,22 @@ class CPoint {
}
}
}


/*!
* \brief Set wall normal according to stored closest wall information.
* \param[in] normals - Mapping [rank][zone][marker][element] -> normal
*/
template<typename Normals_type>
void SetWallNormals(Normals_type const&normals){
for (unsigned long iPoint=0; iPoint<GlobalIndex.size(); ++iPoint) {
auto rankID = ClosestWall_Rank[iPoint];
auto zoneID = ClosestWall_Zone[iPoint];
auto markerID = ClosestWall_Marker[iPoint];
auto elementID = ClosestWall_Elem[iPoint];
if(rankID >= 0)
SetNormal(iPoint, normals[rankID][zoneID][markerID][elementID]);
}
}

};
70 changes: 57 additions & 13 deletions Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1215,27 +1215,37 @@ static const MapType<std::string, TURB_TRANS_MODEL> Trans_Model_Map = {
* \brief LM Options
*/
enum class LM_OPTIONS {
NONE, /*!< \brief No option / default. */
LM2015, /*!< \brief Cross-flow corrections. */
MALAN, /*!< \brief Kind of transition correlation model (Malan). */
SULUKSNA, /*!< \brief Kind of transition correlation model (Suluksna). */
KRAUSE, /*!< \brief Kind of transition correlation model (Krause). */
KRAUSE_HYPER, /*!< \brief Kind of transition correlation model (Krause hypersonic). */
MEDIDA_BAEDER,/*!< \brief Kind of transition correlation model (Medida-Baeder). */
MEDIDA, /*!< \brief Kind of transition correlation model (Medida). */
MENTER_LANGTRY, /*!< \brief Kind of transition correlation model (Menter-Langtry). */
DEFAULT /*!< \brief Kind of transition correlation model (Menter-Langtry if SST, MALAN if SA). */
NONE, /*!< \brief No option / default. */
CROSSFLOW, /*!< \brief Cross-flow corrections. */
SLM, /*!< \brief Simplified version. */
PRODLIM, /*!< \brief Add production term to Pk. */
MALAN, /*!< \brief Kind of transition correlation model (Malan). */
SULUKSNA, /*!< \brief Kind of transition correlation model (Suluksna). */
KRAUSE, /*!< \brief Kind of transition correlation model (Krause). */
KRAUSE_HYPER, /*!< \brief Kind of transition correlation model (Krause hypersonic). */
MEDIDA_BAEDER, /*!< \brief Kind of transition correlation model (Medida-Baeder). */
MEDIDA, /*!< \brief Kind of transition correlation model (Medida). */
MENTER_LANGTRY, /*!< \brief Kind of transition correlation model (Menter-Langtry). */
MENTER_SLM, /*!< \brief Kind of transition correlation model (Menter Simplified LM model). */
CODER_SLM, /*!< \brief Kind of transition correlation model (Coder Simplified LM model). */
MOD_EPPLER_SLM, /*!< \brief Kind of transition correlation model (Modified Eppler Simplified LM model). */
DEFAULT /*!< \brief Kind of transition correlation model (Menter-Langtry if SST, MALAN if SA). */
};

static const MapType<std::string, LM_OPTIONS> LM_Options_Map = {
MakePair("NONE", LM_OPTIONS::NONE)
MakePair("LM2015", LM_OPTIONS::LM2015)
MakePair("CROSSFLOW", LM_OPTIONS::CROSSFLOW)
MakePair("SLM", LM_OPTIONS::SLM)
MakePair("PRODLIM", LM_OPTIONS::PRODLIM)
MakePair("MALAN", LM_OPTIONS::MALAN)
MakePair("SULUKSNA", LM_OPTIONS::SULUKSNA)
MakePair("KRAUSE", LM_OPTIONS::KRAUSE)
MakePair("KRAUSE_HYPER", LM_OPTIONS::KRAUSE_HYPER)
MakePair("MEDIDA_BAEDER", LM_OPTIONS::MEDIDA_BAEDER)
MakePair("MENTER_LANGTRY", LM_OPTIONS::MENTER_LANGTRY)
MakePair("MENTER_SLM", LM_OPTIONS::MENTER_SLM)
MakePair("CODER_SLM", LM_OPTIONS::CODER_SLM)
MakePair("MOD_EPPLER_SLM", LM_OPTIONS::MOD_EPPLER_SLM)
MakePair("DEFAULT", LM_OPTIONS::DEFAULT)
};

Expand All @@ -1253,13 +1263,26 @@ enum class TURB_TRANS_CORRELATION {
DEFAULT /*!< \brief Kind of transition correlation model (Menter-Langtry if SST, MALAN if SA). */
};

/*!
* \brief Types of transition correlations for Simplified LM model
*/
enum class TURB_TRANS_CORRELATION_SLM {
MENTER_SLM, /*!< \brief Kind of transition correlation model (Menter Simplified LM model). */
CODER_SLM, /*!< \brief Kind of transition correlation model (Coder Simplified LM model). */
MOD_EPPLER_SLM, /*!< \brief Kind of transition correlation model (Modified Eppler Simplified LM model). */
DEFAULT /*!< \brief Kind of transition correlation model. */
};

/*!
* \brief Structure containing parsed LM options.
*/
struct LM_ParsedOptions {
LM_OPTIONS version = LM_OPTIONS::NONE; /*!< \brief LM base model. */
bool LM2015 = false; /*!< \brief Use cross-flow corrections. */
bool SLM = false; /*!< \brief Use simplified version. */
bool ProdLim = false; /*!< \brief Add production term to Pk. */
bool CrossFlow = false; /*!< \brief Use cross-flow corrections. */
TURB_TRANS_CORRELATION Correlation = TURB_TRANS_CORRELATION::DEFAULT;
TURB_TRANS_CORRELATION_SLM Correlation_SLM = TURB_TRANS_CORRELATION_SLM::DEFAULT;
};

/*!
Expand All @@ -1277,7 +1300,10 @@ inline LM_ParsedOptions ParseLMOptions(const LM_OPTIONS *LM_Options, unsigned sh
return std::find(LM_Options, lm_options_end, option) != lm_options_end;
};

LMParsedOptions.LM2015 = IsPresent(LM_OPTIONS::LM2015);
LMParsedOptions.SLM = IsPresent(LM_OPTIONS::SLM);
LMParsedOptions.ProdLim = IsPresent(LM_OPTIONS::PRODLIM);

LMParsedOptions.CrossFlow = IsPresent(LM_OPTIONS::CROSSFLOW);

int NFoundCorrelations = 0;
if (IsPresent(LM_OPTIONS::MALAN)) {
Expand Down Expand Up @@ -1309,6 +1335,20 @@ inline LM_ParsedOptions ParseLMOptions(const LM_OPTIONS *LM_Options, unsigned sh
NFoundCorrelations++;
}

int NFoundCorrelations_SLM = 0;
if (IsPresent(LM_OPTIONS::MENTER_SLM)) {
LMParsedOptions.Correlation_SLM = TURB_TRANS_CORRELATION_SLM::MENTER_SLM;
NFoundCorrelations_SLM++;
}
if (IsPresent(LM_OPTIONS::CODER_SLM)) {
LMParsedOptions.Correlation_SLM = TURB_TRANS_CORRELATION_SLM::CODER_SLM;
NFoundCorrelations_SLM++;
}
if (IsPresent(LM_OPTIONS::MOD_EPPLER_SLM)) {
LMParsedOptions.Correlation_SLM = TURB_TRANS_CORRELATION_SLM::MOD_EPPLER_SLM;
NFoundCorrelations_SLM++;
}

if (NFoundCorrelations > 1) {
SU2_MPI::Error("Two correlations selected for LM_OPTIONS. Please choose only one.", CURRENT_FUNCTION);
}
Expand All @@ -1321,6 +1361,10 @@ inline LM_ParsedOptions ParseLMOptions(const LM_OPTIONS *LM_Options, unsigned sh
}
}

if (LMParsedOptions.Correlation_SLM == TURB_TRANS_CORRELATION_SLM::DEFAULT){
LMParsedOptions.Correlation_SLM = TURB_TRANS_CORRELATION_SLM::MENTER_SLM;
}

return LMParsedOptions;
}

Expand Down
37 changes: 30 additions & 7 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3495,9 +3495,9 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
if (Kind_Trans_Model == TURB_TRANS_MODEL::LM) {
lmParsedOptions = ParseLMOptions(LM_Options, nLM_Options, rank, Kind_Turb_Model);

/*--- Check if problem is 2D and LM2015 has been selected ---*/
if (lmParsedOptions.LM2015 && val_nDim == 2) {
SU2_MPI::Error("LM2015 is available only for 3D problems", CURRENT_FUNCTION);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is LM2015 gone? or is crossflow the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed the option to CROSSFLOW, since I will use it also for the Simplified model.

/*--- Check if problem is 2D and CrossFlow has been selected ---*/
if (lmParsedOptions.CrossFlow && val_nDim == 2) {
SU2_MPI::Error("Cross-flow corrections are available only for 3D problems", CURRENT_FUNCTION);
}
}

Expand Down Expand Up @@ -6230,11 +6230,27 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) {
switch (Kind_Trans_Model) {
case TURB_TRANS_MODEL::NONE: break;
case TURB_TRANS_MODEL::LM: {
cout << "Transition model: Langtry and Menter's 4 equation model";
if (lmParsedOptions.LM2015) {
cout << " w/ cross-flow corrections (2015)" << endl;
int NTurbEqs = 0;
switch (Kind_Turb_Model) {
case TURB_MODEL::SA: NTurbEqs = 1; break;
case TURB_MODEL::SST: NTurbEqs = 2; break;
case TURB_MODEL::NONE: SU2_MPI::Error("No turbulence model has been selected but LM transition model is active.", CURRENT_FUNCTION); break;
}
if (!lmParsedOptions.SLM) {
int NEquations = 2;
cout << "Transition model: Langtry and Menter's "<< NEquations+NTurbEqs <<" equation model";
} else {
cout << " (2009)" << endl;
int NEquations = 1;
cout << "Transition model: Simplified Langtry and Menter's "<< NEquations+NTurbEqs <<" equation model";
}
if (lmParsedOptions.CrossFlow) {
cout << " w/ cross-flow corrections" << endl;
} else {
if (!lmParsedOptions.SLM) {
cout << " (2009)" << endl;
} else {
cout << " (2015)" << endl;
}
}
break;
}
Expand All @@ -6258,6 +6274,13 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) {
}
break;
}
cout << "Correlation Functions for Simplified LM model: ";
switch (lmParsedOptions.Correlation_SLM) {
case TURB_TRANS_CORRELATION_SLM::CODER_SLM: cout << "Coder et al. (2012)" << endl; break;
case TURB_TRANS_CORRELATION_SLM::MOD_EPPLER_SLM: cout << "Modified Eppler (from Coder et al. 2012)" << endl; break;
case TURB_TRANS_CORRELATION_SLM::MENTER_SLM:
case TURB_TRANS_CORRELATION_SLM::DEFAULT: cout << "Menter et al. (2015)" << endl; break;
}
}
cout << "Hybrid RANS/LES: ";
switch (Kind_HybridRANSLES) {
Expand Down
76 changes: 76 additions & 0 deletions Common/src/geometry/CGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3969,5 +3969,81 @@
}
}
}


su2vector<su2vector<su2matrix<su2double>>> WallNormal_container;
WallNormal_container.resize(nZone) = su2vector<su2matrix<su2double>>();
for (int iZone = 0; iZone < nZone; iZone++){
const CConfig* config = config_container[iZone];
const CGeometry* geometry = geometry_container[iZone][iInst][MESH_0];
WallNormal_container[iZone].resize(geometry->GetnMarker());
for (auto iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++){
if (config->GetViscous_Wall(iMarker)) {
WallNormal_container[iZone][iMarker].resize(geometry->GetnElem_Bound(iMarker), 3);

// cout << "geometry->nVertex[iMarker] = " << geometry->nVertex[iMarker] << endl;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
for (auto iElem = 0u; iElem < geometry->GetnElem_Bound(iMarker); iElem++) {
su2vector<su2double> NormalHere;
NormalHere.resize(3) = su2double(0.0);

for (unsigned short iNode = 0; iNode < geometry->bound[iMarker][iElem]->GetnNodes(); iNode++) {
// Extract global coordinate of the node
unsigned long iPointHere = geometry->bound[iMarker][iElem]->GetNode(iNode);
long iVertexHere = geometry->nodes->GetVertex(iPointHere, iMarker);
for (auto iDim = 0u; iDim < 3; iDim++)
NormalHere[iDim] += geometry->vertex[iMarker][iVertexHere]->GetNormal(iDim);
}

for (auto iDim = 0u; iDim < 3; iDim++)
NormalHere[iDim] /= geometry->bound[iMarker][iElem]->GetnNodes();

su2double NormalMag = 0.0;
for (auto iDim = 0u; iDim < 3; iDim++)
NormalMag += NormalHere[iDim]*NormalHere[iDim];
NormalMag = sqrt(NormalMag);

for (auto iDim = 0u; iDim < 3; iDim++)
NormalHere[iDim] /= NormalMag;

for (auto iDim = 0u; iDim < 3; iDim++)
WallNormal_container[iZone][iMarker](iElem, iDim) = NormalHere[iDim];

}
} else {
WallNormal_container[iZone][iMarker].resize(1, 3) = su2double(0.0);
}
}
}

auto normal_i =
make_pair(nZone, [config_container,geometry_container,iInst,WallNormal_container](unsigned long iZone){
const CConfig* config = config_container[iZone];
const CGeometry* geometry = geometry_container[iZone][iInst][MESH_0];
const auto nMarker = geometry->GetnMarker();
const auto WallNormal = WallNormal_container[iZone];

return make_pair( nMarker, [config,geometry,WallNormal](unsigned long iMarker){
auto nElem_Bou = geometry->GetnElem_Bound(iMarker);
if (!config->GetViscous_Wall(iMarker)) nElem_Bou = 1;

return make_pair(nElem_Bou, [WallNormal,iMarker](unsigned long iElem){
const auto dimensions = 3;

return make_pair(dimensions, [WallNormal,iMarker,iElem](unsigned short iDim){

return WallNormal[iMarker](iElem, iDim);
});
});
});
});

NdFlattener<4>Normals_Local(normal_i);
NdFlattener<5> Normals_global(Nd_MPI_Environment(), Normals_Local);


// use it to update roughnesses
for(int jZone=0; jZone<nZone; jZone++){
geometry_container[jZone][iInst][MESH_0]->nodes->SetWallNormals(Normals_global);
}
}
}
3 changes: 3 additions & 0 deletions Common/src/geometry/dual_grid/CPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ void CPoint::FullAllocation(unsigned short imesh, const CConfig* config) {

RoughnessHeight.resize(npoint) = su2double(0.0);
SharpEdge_Distance.resize(npoint) = su2double(0.0);

Normals.resize(npoint, 3) = su2double(0.0);

}

void CPoint::SetElems(const vector<vector<long> >& elemsMatrix) { Elem = CCompressedSparsePatternL(elemsMatrix); }
Expand Down
Loading
Loading