-
Notifications
You must be signed in to change notification settings - Fork 876
[WIP] pywrapper - custom source terms for all solvers #2388
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
base: develop
Are you sure you want to change the base?
Conversation
… type in loop condition Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…into feature_custom_source
unsigned long CDriver::GetNumberOuterIter() const { return config_container[selected_zone]->GetnOuter_Iter(); } | ||
|
||
unsigned long CDriver::GetDensity_FreeStreamND() const { | ||
return SU2_TYPE::GetValue(config_container[selected_zone]->GetDensity_FreeStreamND()); |
Check warning
Code scanning / CodeQL
Lossy function result cast Warning
return SU2_TYPE::GetValue(config_container[selected_zone]->GetDensity_FreeStreamND()); | ||
} | ||
unsigned long CDriver::GetForce_Ref() const { | ||
return SU2_TYPE::GetValue(config_container[selected_zone]->GetForce_Ref()); |
Check warning
Code scanning / CodeQL
Lossy function result cast Warning
@@ -66,6 +76,11 @@ | |||
|
|||
string CDriver::GetSurfaceFileName() const { return config_container[selected_zone]->GetSurfCoeff_FileName(); } | |||
|
|||
unsigned long CDriver::GetSolution(unsigned short iSOLVER, unsigned long iPoint, unsigned short iVar) { | |||
auto solver = solver_container[iZone][INST_0][MESH_0][iSOLVER]; | |||
return SU2_TYPE::GetValue(solver->GetNodes()->GetSolution(iPoint,iVar)); |
Check warning
Code scanning / CodeQL
Lossy function result cast Warning
iDENSITY = primindex.get("DENSITY") | ||
#print("index of density = ",iDENSITY) | ||
|
||
index_Vel = varindex.get("VELOCITY_X") |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To fix the issue, we should remove the assignment to index_Vel
entirely, as it is not used anywhere in the code. This will eliminate the unused variable and make the code cleaner. Since the right-hand side of the assignment (varindex.get("VELOCITY_X")
) does not have any side effects, it is safe to remove the entire line.
-
Copy modified line R80
@@ -79,4 +79,3 @@ | ||
|
||
index_Vel = varindex.get("VELOCITY_X") | ||
#print("index of velocity = ",index_Vel) | ||
#print("index of velocity = ", varindex.get('VELOCITY_X')) # Optional: Keep for debugging | ||
custom_source_vector = [0.0 for i in range(nVars)] |
solvar = list(SU2Driver.GetSolutionVector(iFLOWSOLVER, iPoint)) | ||
# the list with names | ||
solindex = getsolvar(SU2Driver) | ||
primindex = SU2Driver.GetPrimitiveIndices() |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 7 days ago
To fix the issue, we should remove the assignment to the unused variable primindex
on line 103. Since the variable is not used anywhere in the function, its removal will not affect the functionality of the code. Care should be taken to ensure that the removal does not inadvertently delete any other necessary code or comments.
-
Copy modified line R103
@@ -102,3 +102,3 @@ | ||
solindex = getsolvar(SU2Driver) | ||
primindex = SU2Driver.GetPrimitiveIndices() | ||
# Removed unused variable primindex | ||
iTEMP = solindex.get("TEMPERATURE") |
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
for prim in varindex.copy(): | ||
if varindex[prim] >=nVars: | ||
del varindex[prim] | ||
varindex = dict(sorted(varindex.items(), key=lambda item: item[1])) |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 7 days ago
To fix the issue, we need to address the unused variable varindex
. Since the variable is not used after its assignment, we can safely remove the assignment on line 212. This ensures that the code remains clean and avoids unnecessary computations.
If the variable was intended for documentation purposes or debugging, we could rename it to follow conventions for unused variables (e.g., _unused_varindex
). However, there is no evidence in the code to suggest this intention.
-
Copy modified line R212
@@ -211,3 +211,3 @@ | ||
del varindex[prim] | ||
varindex = dict(sorted(varindex.items(), key=lambda item: item[1])) | ||
# Removed unused assignment to varindex | ||
|
@@ -615,9 +619,13 @@ | |||
*Kind_Data_Giles; /*!< \brief Kind of inlet boundary treatment. */ | |||
INLET_TYPE Kind_Inlet; | |||
INLET_TYPE *Kind_Inc_Inlet; | |||
|
|||
//WALL_SPECIES_TYPE **Wall_SpeciesType; | |||
unsigned short **Wall_SpeciesType; |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 7 days ago
To resolve the issue, we need to either remove the commented-out code or reinstate it as active code. Since there is no context indicating that the commented-out line is necessary or relevant, the best approach is to remove it entirely. This will improve code readability and eliminate potential confusion for developers.
-
Copy modified line R624
@@ -623,3 +623,3 @@ | ||
|
||
//WALL_SPECIES_TYPE **Wall_SpeciesType; | ||
|
||
unsigned short **Wall_SpeciesType; |
su2double** & wall_species_val, unsigned short & nSpecies_per_Wall); | ||
void addWallSpeciesType(const string& name, unsigned short & nMarker_Wall_Species, string * & Marker_Wall_Species, | ||
// WALL_SPECIES_TYPE** & wall_species_type, unsigned short & nSpecies_per_Wall); | ||
unsigned short** & wall_species_type, unsigned short & nSpecies_per_Wall); |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 7 days ago
To resolve the issue, the commented-out code on line 1354 should be removed. This ensures that the codebase remains clean and avoids confusion for developers. Removing the line does not affect functionality because the uncommented version of the code (line 1355) already serves the intended purpose.
Steps to implement the fix:
- Locate the commented-out code on line 1354 in the file
Common/include/CConfig.hpp
. - Remove the line entirely.
- Verify that the removal does not affect the functionality of the surrounding code.
@@ -1353,3 +1353,2 @@ | ||
void addWallSpeciesType(const string& name, unsigned short & nMarker_Wall_Species, string * & Marker_Wall_Species, | ||
// WALL_SPECIES_TYPE** & wall_species_type, unsigned short & nSpecies_per_Wall); | ||
unsigned short** & wall_species_type, unsigned short & nSpecies_per_Wall); |
//unsigned short* GetKind_Wall_Species(const string& val_marker) const; | ||
|
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 7 days ago
To fix the issue, we need to either remove the commented-out code or reinstate it as active code if it is still relevant. Since there is no context suggesting that the function is required, the best course of action is to remove the commented-out line entirely. This will improve code readability and maintainability.
@@ -4978,3 +4978,2 @@ | ||
*/ | ||
// WALL_SPECIES_TYPE* GetKind_Wall_Species(const string& val_marker) const; | ||
//unsigned short* GetKind_Wall_Species(const string& val_marker) const; |
// for (unsigned short iSpecies = 0; iSpecies < nSpecies; iSpecies++) { | ||
// checkScalarBounds(Species_Init[iSpecies], "SPECIES_INIT individual", 0.0, 1.0); | ||
// Species_Init_Sum += Species_Init[iSpecies]; | ||
// } | ||
// checkScalarBounds(Species_Init_Sum, "SPECIES_INIT sum", 0.0, 1.0); | ||
|
||
// for (iMarker = 0; iMarker < nMarker_Inlet_Species; iMarker++) { |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 7 days ago
To resolve the issue, we will remove the commented-out code entirely. This approach is appropriate because the surrounding comments and cout
statements indicate that bounds checking for species-related quantities is no longer performed. If this functionality is needed in the future, it can be reintroduced with proper testing and integration.
Steps to fix:
- Remove the commented-out code block starting from line 5644 to line 5660.
- Ensure that the removal does not affect the functionality of the remaining code.
@@ -5643,19 +5643,3 @@ | ||
cout << "warning: no bounds checked for species" << endl; | ||
// if (Kind_Species_Model == SPECIES_MODEL::SPECIES_TRANSPORT) { | ||
// su2double Species_Init_Sum = 0.0; | ||
// for (unsigned short iSpecies = 0; iSpecies < nSpecies; iSpecies++) { | ||
// checkScalarBounds(Species_Init[iSpecies], "SPECIES_INIT individual", 0.0, 1.0); | ||
// Species_Init_Sum += Species_Init[iSpecies]; | ||
// } | ||
// checkScalarBounds(Species_Init_Sum, "SPECIES_INIT sum", 0.0, 1.0); | ||
|
||
// for (iMarker = 0; iMarker < nMarker_Inlet_Species; iMarker++) { | ||
// su2double Inlet_SpeciesVal_Sum = 0.0; | ||
// for (unsigned short iSpecies = 0; iSpecies < nSpecies; iSpecies++) { | ||
// checkScalarBounds(Inlet_SpeciesVal[iMarker][iSpecies], "MARKER_INLET_SPECIES individual", 0.0, 1.0); | ||
// Inlet_SpeciesVal_Sum += Inlet_SpeciesVal[iMarker][iSpecies]; | ||
// } | ||
// checkScalarBounds(Inlet_SpeciesVal_Sum, "MARKER_INLET_SPECIES sum", 0.0, 1.0); | ||
// } | ||
// } | ||
|
} | ||
//const WALL_SPECIES_TYPE* CConfig::GetWall_SpeciesType(const string& val_marker) const { | ||
const unsigned short* CConfig::GetWall_SpeciesType(const string& val_marker) const { | ||
unsigned short iMarker_Wall_Species; |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 7 days ago
To fix the issue, we should either remove the commented-out code entirely or reinstate it if it is still relevant. In this case, since the function CConfig::GetWall_SpeciesType
is already implemented in the following lines (9163–9167), the commented-out version of the function is redundant and should be removed. This will improve code readability and maintainability.
-
Copy modified line R9162
@@ -9161,3 +9161,3 @@ | ||
} | ||
//const WALL_SPECIES_TYPE* CConfig::GetWall_SpeciesType(const string& val_marker) const { | ||
|
||
const unsigned short* CConfig::GetWall_SpeciesType(const string& val_marker) const { |
// //case WALL_SPECIES_TYPE::FLUX: | ||
// case 0: | ||
// cout << "flux" << endl; | ||
// break; | ||
// //case WALL_SPECIES_TYPE::VALUE: | ||
// case 1: | ||
// cout << "value" << endl; | ||
// break; | ||
// default: | ||
// break; | ||
// } |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 7 days ago
The best way to fix this issue is to either remove the commented-out code entirely if it is no longer needed or reinstate it if it is still relevant and should be part of the active codebase. In this case, the commented-out code appears to be an incomplete switch statement for handling different wall species types. Since there is no indication that this code is actively being used or maintained, it is better to remove it to avoid confusion.
-
Copy modified line R476
@@ -475,16 +475,3 @@ | ||
cout << "type = "<<(wallspeciestype[0]) << " " << wallspeciestype[1] << endl; | ||
// switch (config->GetWall_SpeciesType(Marker_Tag)[0]) { | ||
// /*--- incompressible conditions ---*/ | ||
|
||
// //case WALL_SPECIES_TYPE::FLUX: | ||
// case 0: | ||
// cout << "flux" << endl; | ||
// break; | ||
// //case WALL_SPECIES_TYPE::VALUE: | ||
// case 1: | ||
// cout << "value" << endl; | ||
// break; | ||
// default: | ||
// break; | ||
// } | ||
// Removed commented-out code block for clarity and maintainability. | ||
} |
solvar = list(SU2Driver.GetSolutionVector(iFLOWSOLVER, iPoint)) | ||
# the list with names | ||
solindex = getsolvar(SU2Driver) | ||
primindex = SU2Driver.GetPrimitiveIndices() |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 7 days ago
To fix the issue, we will remove the assignment to the unused variable primindex
on line 103. Since the variable is not used anywhere in the function or the provided code, its removal will not affect the functionality of the program. This change will make the code cleaner and eliminate the CodeQL warning.
-
Copy modified line R103
@@ -102,3 +102,3 @@ | ||
solindex = getsolvar(SU2Driver) | ||
primindex = SU2Driver.GetPrimitiveIndices() | ||
# (Line removed as it is unused) | ||
iTEMP = solindex.get("TEMPERATURE") |
for prim in varindex.copy(): | ||
if varindex[prim] >=nVars: | ||
del varindex[prim] | ||
varindex = dict(sorted(varindex.items(), key=lambda item: item[1])) |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 7 days ago
To fix the issue, we should remove the unused assignment to varindex
on line 212. This will eliminate the redundant code and make the program cleaner and easier to maintain. Since the variable varindex
is not used after this assignment, removing it will not impact the program's behavior.
-
Copy modified line R212
@@ -211,3 +211,3 @@ | ||
del varindex[prim] | ||
varindex = dict(sorted(varindex.items(), key=lambda item: item[1])) | ||
# (Line removed as it is unused) | ||
|
Proposed Changes
Introduce custom source terms for all solvers through the python wrapper.
PR Checklist
Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.
pre-commit run --all
to format old commits.