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] pywrapper - custom source terms for all solvers #2388

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from

Conversation

bigfooted
Copy link
Contributor

@bigfooted bigfooted commented Dec 3, 2024

Proposed Changes

Introduce custom source terms for all solvers through the python wrapper.

  • reproduces the laminar buoyancy driven cavity testcase
  • can simulate a turbulent premixed flame using turbulent flamespeed closure (TFC)

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.

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I used the pre-commit hook to prevent dirty commits and used pre-commit run --all to format old commits.
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.

bigfooted and others added 2 commits December 3, 2024 16:18
… type in loop condition

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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 value of type double is implicitly converted to unsigned long.
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

Return value of type double is implicitly converted to unsigned long.
@@ -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

Return value of type double is implicitly converted to unsigned long.
#print("indices of primitives=",primindex)
#print("number of primitives:",len(primindex))

nElem = driver.GetNumberElements()

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable nElem is not used.

Copilot Autofix AI 4 days ago

The best way to fix the problem is to remove the assignment of the nElem variable since it is not used anywhere in the code. This will clean up the code and eliminate the unnecessary variable. The change should be made in the main function of the TestCases/py_wrapper/custom_source/run.py file.

Suggested changeset 1
TestCases/py_wrapper/custom_source/run.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/TestCases/py_wrapper/custom_source/run.py b/TestCases/py_wrapper/custom_source/run.py
--- a/TestCases/py_wrapper/custom_source/run.py
+++ b/TestCases/py_wrapper/custom_source/run.py
@@ -60,4 +60,3 @@
 
-  nElem = driver.GetNumberElements()
-  #print("number of elements:",nElem)
+  #print("number of elements:",driver.GetNumberElements())
 
EOF
@@ -60,4 +60,3 @@

nElem = driver.GetNumberElements()
#print("number of elements:",nElem)
#print("number of elements:",driver.GetNumberElements())

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
iDENSITY = primindex.get("DENSITY")
#print("index of density = ",iDENSITY)

index_Vel = varindex.get("VELOCITY_X")

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable index_Vel is not used.

Copilot Autofix AI 4 days ago

The best way to fix the problem is to remove the assignment of the unused variable index_Vel. This will clean up the code and remove any potential confusion about the purpose of the variable. Since the right-hand side of the assignment does not have any side effects, it is safe to remove the entire line.

Suggested changeset 1
TestCases/py_wrapper/custom_source/run.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/TestCases/py_wrapper/custom_source/run.py b/TestCases/py_wrapper/custom_source/run.py
--- a/TestCases/py_wrapper/custom_source/run.py
+++ b/TestCases/py_wrapper/custom_source/run.py
@@ -77,3 +77,3 @@
 
-  index_Vel = varindex.get("VELOCITY_X")
+  #index_Vel = varindex.get("VELOCITY_X")
   #print("index of velocity = ",index_Vel)
EOF
@@ -77,3 +77,3 @@

index_Vel = varindex.get("VELOCITY_X")
#index_Vel = varindex.get("VELOCITY_X")
#print("index of velocity = ",index_Vel)
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
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

Variable primindex is not used.

Copilot Autofix AI 4 days ago

The best way to fix the problem is to remove the assignment of the unused variable primindex. This will clean up the code and remove any potential confusion about the purpose of the variable. Since the right-hand side of the assignment does not have any side effects, it is safe to remove the entire line.

Suggested changeset 1
TestCases/py_wrapper/turbulent_premixed_psi/run.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/TestCases/py_wrapper/turbulent_premixed_psi/run.py b/TestCases/py_wrapper/turbulent_premixed_psi/run.py
--- a/TestCases/py_wrapper/turbulent_premixed_psi/run.py
+++ b/TestCases/py_wrapper/turbulent_premixed_psi/run.py
@@ -104,3 +104,2 @@
     solindex = getsolvar(SU2Driver)
-    primindex = SU2Driver.GetPrimitiveIndices()
     iTEMP = solindex.get("TEMPERATURE")
EOF
@@ -104,3 +104,2 @@
solindex = getsolvar(SU2Driver)
primindex = SU2Driver.GetPrimitiveIndices()
iTEMP = solindex.get("TEMPERATURE")
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
#

#print("solver variable names:",varindex)
iDENSITY = primindex.get("DENSITY")

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable iDENSITY is not used.

Copilot Autofix AI 4 days 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.

Suggested changeset 1
TestCases/py_wrapper/turbulent_premixed_psi/run.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/TestCases/py_wrapper/turbulent_premixed_psi/run.py b/TestCases/py_wrapper/turbulent_premixed_psi/run.py
--- a/TestCases/py_wrapper/turbulent_premixed_psi/run.py
+++ b/TestCases/py_wrapper/turbulent_premixed_psi/run.py
@@ -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"))
 
EOF
@@ -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"))

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
iDENSITY = primindex.get("DENSITY")
#print("index of density = ",iDENSITY)

index_Vel = varindex.get("VELOCITY_X")

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable index_Vel is not used.

Copilot Autofix AI 4 days 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.

Suggested changeset 1
TestCases/py_wrapper/turbulent_premixed_psi/run.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/TestCases/py_wrapper/turbulent_premixed_psi/run.py b/TestCases/py_wrapper/turbulent_premixed_psi/run.py
--- a/TestCases/py_wrapper/turbulent_premixed_psi/run.py
+++ b/TestCases/py_wrapper/turbulent_premixed_psi/run.py
@@ -228,4 +228,3 @@
 
-  index_Vel = varindex.get("VELOCITY_X")
-  #print("index of velocity = ",index_Vel)
+
 
EOF
@@ -228,4 +228,3 @@

index_Vel = varindex.get("VELOCITY_X")
#print("index of velocity = ",index_Vel)


Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
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

Variable custom_source_vector is not used.

Copilot Autofix AI 4 days ago

To fix the problem, we need 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 eliminate the unnecessary variable. The change should be made in the file TestCases/py_wrapper/turbulent_premixed_psi/run.py on line 232.

Suggested changeset 1
TestCases/py_wrapper/turbulent_premixed_psi/run.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/TestCases/py_wrapper/turbulent_premixed_psi/run.py b/TestCases/py_wrapper/turbulent_premixed_psi/run.py
--- a/TestCases/py_wrapper/turbulent_premixed_psi/run.py
+++ b/TestCases/py_wrapper/turbulent_premixed_psi/run.py
@@ -231,3 +231,2 @@
 
-  custom_source_vector = [0.0 for i in range(nVars)]
   #print("custom source vector = ", custom_source_vector)
EOF
@@ -231,3 +231,2 @@

custom_source_vector = [0.0 for i in range(nVars)]
#print("custom source vector = ", custom_source_vector)
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant