-
Notifications
You must be signed in to change notification settings - Fork 866
[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 4 days 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 about 1 month ago
To fix the problem, we should remove the unused variable primindex
from the function update_temperature
. This will clean up the code and remove any potential confusion about the purpose of the variable. Since the variable is not used anywhere in the function, we can safely delete the line where it is assigned without affecting the existing functionality.
@@ -105,3 +105,2 @@ | ||
solindex = getsolvar(SU2Driver) | ||
primindex = SU2Driver.GetPrimitiveIndices() | ||
iTEMP = solindex.get("TEMPERATURE") |
# | ||
|
||
#print("solver variable names:",varindex) | ||
iDENSITY = primindex.get("DENSITY") |
Check notice
Code scanning / CodeQL
Unused local variable Note
This autofix suggestion was applied.
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 months ago
The best way to fix the problem is to remove the unused variable iDENSITY
. Since the assignment of iDENSITY
does not have any side effects, we can safely delete the entire line where iDENSITY
is assigned. This will clean up the code and remove any potential confusion about the purpose of the variable.
-
Copy modified line R226
@@ -225,4 +225,3 @@ | ||
#print("solver variable names:",varindex) | ||
iDENSITY = primindex.get("DENSITY") | ||
#print("index of density = ",iDENSITY) | ||
#print("index of density = ",primindex.get("DENSITY")) | ||
|
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
The best way to fix the problem is to remove the assignment of the index_Vel
variable since it is not used anywhere in the code. This will clean up the code and remove any potential confusion about the purpose of the variable.
To implement this fix, we need to delete the line where index_Vel
is assigned a value. This change should be made in the file TestCases/py_wrapper/turbulent_premixed_psi/run.py
on line 229.
-
Copy modified line R229
@@ -228,4 +228,3 @@ | ||
|
||
index_Vel = varindex.get("VELOCITY_X") | ||
#print("index of velocity = ",index_Vel) | ||
|
||
|
index_Vel = varindex.get("VELOCITY_X") | ||
#print("index of velocity = ",index_Vel) | ||
|
||
custom_source_vector = [0.0 for i in range(nVars)] |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
The best way to fix the problem is to remove the assignment of the custom_source_vector
variable since it is not used anywhere in the code. This will clean up the code and remove any potential confusion about the purpose of the variable.
- Locate the assignment of the
custom_source_vector
variable on line 232. - Remove the entire line where
custom_source_vector
is assigned a value.
@@ -231,3 +231,2 @@ | ||
|
||
custom_source_vector = [0.0 for i in range(nVars)] | ||
#print("custom source vector = ", custom_source_vector) |
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>
#if (norm_gradc > 1.): | ||
# print(tke," ",rho_u," Ut=",Ut," , |grad(c)| = ",norm_gradc, " ",gradc[0]," ",gradc[1]) |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To fix the problem, we should remove the commented-out code entirely. This will make the code cleaner and less confusing for future developers. Specifically, we need to remove lines 138 and 139 from the file TestCases/py_wrapper/turbulent_premixed_psi/run.py
.
-
Copy modified lines R138-R139
@@ -137,4 +137,4 @@ | ||
norm_gradc = np.sqrt(gradc[0]*gradc[0] + gradc[1]*gradc[1]) | ||
#if (norm_gradc > 1.): | ||
# print(tke," ",rho_u," Ut=",Ut," , |grad(c)| = ",norm_gradc, " ",gradc[0]," ",gradc[1]) | ||
|
||
|
||
Sc = rho_u * Ut * norm_gradc |
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 4 days ago
To fix the issue, we will remove the assignment to the primindex
variable on line 106. This ensures that the code is cleaner and avoids confusion about the purpose of the unused variable. Since the variable is not used anywhere in the function or the provided code snippet, its removal will not affect the functionality of the program.
@@ -105,3 +105,2 @@ | ||
solindex = getsolvar(SU2Driver) | ||
primindex = SU2Driver.GetPrimitiveIndices() | ||
iTEMP = solindex.get("TEMPERATURE") |
#if (norm_gradc > 1.): | ||
# print(tke," ",rho_u," Ut=",Ut," , |grad(c)| = ",norm_gradc, " ",gradc[0]," ",gradc[1]) |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 days ago
The best way to fix the problem is to either remove the commented-out code entirely or reinstate it if it is still relevant. In this case, the commented-out code appears to be a debugging statement that is no longer needed, as the surrounding code does not depend on it. Therefore, the appropriate fix is to remove the commented-out code on line 138 and the associated comment on line 139.
-
Copy modified lines R138-R139
@@ -137,4 +137,4 @@ | ||
norm_gradc = np.sqrt(gradc[0]*gradc[0] + gradc[1]*gradc[1]) | ||
#if (norm_gradc > 1.): | ||
# print(tke," ",rho_u," Ut=",Ut," , |grad(c)| = ",norm_gradc, " ",gradc[0]," ",gradc[1]) | ||
|
||
|
||
Sc = rho_u * Ut * norm_gradc |
# | ||
|
||
#print("solver variable names:",varindex) | ||
iDENSITY = primindex.get("DENSITY") |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 days ago
To fix the issue, we will remove the assignment to iDENSITY
on line 226 since it is not used anywhere in the code. This will eliminate the unused variable and clean up the code. Care will be taken not to remove any code with side effects, but in this case, the primindex.get("DENSITY")
call does not appear to have side effects, so it is safe to remove.
-
Copy modified line R226
@@ -225,4 +225,3 @@ | ||
#print("solver variable names:",varindex) | ||
iDENSITY = primindex.get("DENSITY") | ||
#print("index of density = ",iDENSITY) | ||
#print("index of density = ",primindex.get('DENSITY')) | ||
|
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 4 days ago
To fix the issue, we should remove the assignment of the unused variable index_Vel
entirely, as it serves no purpose in the current code. This will clean up the code and improve readability. If the assignment has side effects (e.g., if varindex.get
performs some operation), we need to ensure that removing it does not affect the program's behavior. However, in this case, varindex.get
is a dictionary-like operation that does not have side effects, so it is safe to remove.
-
Copy modified line R229
@@ -228,4 +228,3 @@ | ||
|
||
index_Vel = varindex.get("VELOCITY_X") | ||
#print("index of velocity = ",index_Vel) | ||
#print("index of velocity = ",varindex.get('VELOCITY_X')) | ||
|
index_Vel = varindex.get("VELOCITY_X") | ||
#print("index of velocity = ",index_Vel) | ||
|
||
custom_source_vector = [0.0 for i in range(nVars)] |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 days ago
To fix the issue, we should remove the assignment to custom_source_vector
entirely, as it serves no purpose in the current code. This will clean up the code and eliminate the unused variable. Care should be taken to ensure that removing this line does not affect any side effects, but since the right-hand side of the assignment is a simple list comprehension with no external dependencies, there are no side effects to consider.
-
Copy modified line R232
@@ -231,4 +231,3 @@ | ||
|
||
custom_source_vector = [0.0 for i in range(nVars)] | ||
#print("custom source vector = ", custom_source_vector) | ||
#print("custom source vector = ", [0.0 for i in range(nVars)]) | ||
|
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.