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 15 commits into
base: develop
Choose a base branch
from

Conversation

bigfooted
Copy link
Contributor

Proposed Changes

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

current status:
First proof of concept, reproduces the laminar buoyancy driven cavity testcase

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.

TestCases/py_wrapper/custom_source/run.py Fixed Show fixed Hide fixed
TestCases/py_wrapper/custom_source/run.py Fixed Show fixed Hide fixed
TestCases/py_wrapper/custom_source/run.py Fixed Show fixed Hide fixed
TestCases/py_wrapper/custom_source/run.py Fixed Show fixed Hide fixed
TestCases/py_wrapper/custom_source/run.py Fixed Show fixed Hide fixed
TestCases/py_wrapper/custom_source/run.py Fixed Show fixed Hide fixed
TestCases/py_wrapper/custom_source/run.py Fixed Show fixed Hide fixed
TestCases/py_wrapper/custom_source/run.py Fixed Show fixed Hide fixed
TestCases/py_wrapper/custom_source/run.py Fixed Show fixed Hide fixed
TestCases/py_wrapper/custom_source/run.py Fixed Show fixed Hide fixed
SU2_CFD/include/drivers/CDriverBase.hpp Fixed Show fixed Hide fixed
SU2_CFD/src/drivers/CDriverBase.cpp Fixed Show fixed Hide fixed
SU2_CFD/src/numerics/flow/flow_sources.cpp Fixed Show fixed Hide fixed
unsigned long CDriver::GetNumberInnerIter() const { return config_container[selected_zone]->GetnInner_Iter(); }
unsigned long CDriver::GetNumberOuterIter() const { return config_container[selected_zone]->GetnOuter_Iter(); }

unsigned long CDriver::GetDensity_FreeStreamND() const { return 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.
unsigned long CDriver::GetNumberOuterIter() const { return config_container[selected_zone]->GetnOuter_Iter(); }

unsigned long CDriver::GetDensity_FreeStreamND() const { return config_container[selected_zone]->GetDensity_FreeStreamND(); }
unsigned long CDriver::GetForce_Ref() const { return 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 +72,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 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.
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>
# ################################################################## #
def initC(coord):
x = coord[0]
y = coord[1]

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable y is not used.
y = coord[1]
#z = coord[2]
#print("x,y = ",x," ",y)
C = 0.0

Check warning

Code scanning / CodeQL

Variable defined multiple times Warning

This assignment to 'C' is unnecessary as it is
redefined
before this value is used.
This assignment to 'C' is unnecessary as it is
redefined
before this value is used.
R = 8.314
# kg/kmol
M = 28.5
RHO = P0/(R*T/M)

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable RHO is not used.
RHO = P0/(R*T/M)
iFLOWSOLVER = SU2Driver.GetSolverIndices()['INC.FLOW']
solvar = list(SU2Driver.GetSolutionVector(iFLOWSOLVER, iPoint))
primvar = list(SU2Driver.GetPrimitiveVector(iFLOWSOLVER, iPoint))

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable primvar is not used.
#print("primvar = ",primvar)
#print("solvar=",solvar)
iTEMP = solindex.get("TEMPERATURE")
iDENSITY = primindex.get("DENSITY")

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable iDENSITY is not used.
nu=mu/rho
tke, dissipation = SU2Driver.GetSolutionVector(iSSTSOLVER,iPoint)
gradc = SU2Driver.GetGradient(iSPECIESSOLVER,iPoint,0)
norm_gradc = np.sqrt(gradc[0]*gradc[0] + gradc[1]*gradc[1])

Check warning

Code scanning / CodeQL

Variable defined multiple times Warning

This assignment to 'norm_gradc' is unnecessary as it is
redefined
before this value is used.
print("\n------------------------------ Begin Solver -----------------------------")
sys.stdout.flush()

nDim = driver.GetNumberDimensions()

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable nDim is not used.
unsigned short nVar = GetNumberSolverVars(iSolver);
if (nVar != solutionVector.size() )
SU2_MPI::Error("Solution Vector size is not equal to Solver size.", CURRENT_FUNCTION);
//cout << "setting solution vector " << nodes->GetSolution(iPoint,0) << " " << solutionVector[0] << ", "<< nVar<< endl;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
auto* nodes = solver->GetNodes();
auto nPrimvar = GetNumberPrimitiveVars(iSolver);
vector<passivedouble> solutionvector(nPrimvar, 0.0);
//cout << "setting primitive vector " << nodes->GetPrimitive(iPoint,0) << " " << primitiveVector[0] << ", "<< nPrimvar<< endl;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
vector<passivedouble> val_source) final {
/*--- Since this call can be accessed indirectly using python, do some error
* checking to prevent segmentation faults ---*/
//cout << "flow" << endl;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
vector<passivedouble> val_source) final {
/*--- Since this call can be accessed indirectly using python, do some error
* checking to prevent segmentation faults ---*/
//cout << "***** set custom point source species *****" << endl;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

/*--- Compute the residual for this control volume and subtract. ---*/
for (iVar = 0; iVar < nVar; iVar++) {
//cout << iPoint << " " << iVar << ",S="<< PointSource[iPoint][iVar]<< endl;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
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