CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   SU2 (https://www.cfd-online.com/Forums/su2/)
-   -   Reading Source-term Data From a Text File (https://www.cfd-online.com/Forums/su2/242295-reading-source-term-data-text-file.html)

gaurav11 April 14, 2022 03:54

Reading Source-term Data From a Text File
 
Hi. I am working on a research project. I need to add a spatially varying source term in the X-momentum equation, for incompressible Navier-Stokes simulation. What I want to do is to run a loop over all the points and add a different source term at each point. The source term data has to be read from a file. Could anyone please help me to understand what part of SU2 code I need to modify to achieve this? Thank You.

TKatt April 14, 2022 10:55

Hi gaurav11,


do you try to model fully developed flow (or: streamwise periodic flow) by any chance? That feature would already exist.


But otherwise, source terms are implemented in flow_sources.cpp and are called in CIncEulerSolver.cpp::Source_Residual. A loop goes over all points in the domain and calls a ComputeResidual function (which is implemented in flow_sources.cpp) that computes the Residual contribution for that specific point. For a quick proof-of-concept you might want to read your file in that CIncEulerSolver.cpp::Source_Residual and just compute and set the Residual contribution right there without the flow_sources stuff.. might make it bit easier to handle as a first try.


Hope that helps a little bit, Tobi

gaurav11 May 30, 2022 04:17

Changes Made in SU2 Source-Code
 
1 Attachment(s)
Hi Tobi,

I have made some changes to the SU2 source code for solving my problem. I have attached here a file containing the changes. Regarding the loop over all points in the domain in CIncEulerSolver.cpp, should I get the global point index?

My understanding is that the loop is running over all the volume and "iPoint" refers to the index of the volume in the ongoing loop iteration, so distribution over the processor will still refer to the right index. Is it correct?

Also, is it possible to use the new source-term values in the adjoint solver? I need to optimize the source-term values at each grid point using the following procedure.

1. Guess source values at grid points.
2. Run a RANS solution
3. Compare the RANS velocity field with the measured field
4. Use loss function = (u_rans-u_measure)^2
5. Use adjoint optimization to get the updated source field
6. Repeat 2-5 until convergence (Loss<set_threshold)

Thank You


All times are GMT -4. The time now is 09:56.