CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   SU2 (https://www.cfd-online.com/Forums/su2/)
-   -   Custom source term in incompressible fluid flow simulation (https://www.cfd-online.com/Forums/su2/236602-custom-source-term-incompressible-fluid-flow-simulation.html)

jw-89 June 6, 2021 17:31

Custom source term in incompressible fluid flow simulation
 
Dear SU2 Users,

I am a very beginner at using SU2 and need more detailed instructions on how to implement a user-defined source term in an incompressible fluid flow simulation. More precisely, I am not completely sure how to set the gradient of my own source term, which is a function of the flow velocity, fluid density, and some cell-defined external quantities that I provide to the solver via a text file. I implemented a specialized CNumerics class, and overwritten the definition of the method 'ComputeResidual'. Here I compute my special momentum- (in N) and energy-source term (in W) and an approximation of the Jacobian (diagonal values) with respect to the conservative variables.

So far so good, I am using INC_RANS solver with active INC_ENERGY_EQUATION, SST turbulence model, and INC_IDEAL_GAS fluid model. For small geometries, the defined solver converges (in temperature residual) and returns a reasonable solution. However, I have the impression that the gradient information of the new source term has only a little effect (if any at all). I would expect that by providing the correct gradient (or at least a good approximation) of the main ingredient that drives the simulation we reduce the required number of iterations. This is not the case in my example. No matter if I define the gradients or not, the solution process looks the same.

For larger geometries (with several thousands of nodes), it is not likely to converge at all. Furthermore, updating the global Jacobian with the diagonal entries of the true Jacobian of my source term does not help. This observation prompts me to ask the following questions:
What is the correct way of defining the Jacobian for a custom source term?
Is there a configuration parameter that controls whether the user-defined gradients are used in the solver?

I believe it is worth mentioning that a similar approach works in Fluent with the use of user-defined functions.

I appreciate your help.

Sprotte June 7, 2021 06:37

Hi,

Quote:

Originally Posted by jw-89 (Post 805429)
Dear SU2 Users,

I would expect that by providing the correct gradient (or at least a good approximation) of the main ingredient that drives the simulation we reduce the required number of iterations.

It should, assuming you've checked that the routine you've overwritten is called (?)

You could check your residual implementation first by using an explicit time stepping and if everything's fine, you go back to the Jacobian issue.

Best, Ole

jw-89 June 7, 2021 08:11

Many thanks for replying to my post.

Quote:

Originally Posted by Sprotte (Post 805461)
It should, assuming you've checked that the routine you've overwritten is called (?)

This is already verified and I am sure that the routine I implemented is called. The computed residual looks fine and it contributes to LinSysRes of CIncEulerSolver. I update also the Jacobian in an analogous way but it has a very minor effect on the simulation. Any idea what can be wrong?

Regards, Jaroslaw

pcg June 7, 2021 17:17

Join the developers meeting https://meet.jit.si/SU2_DevMeeting Wednesday at 15h UK and show us the code.

Sprotte June 8, 2021 07:37

Sounds like some SetTime_Step thing though. See you tomorrow maybe!

jw-89 June 8, 2021 09:33

Quote:

Originally Posted by pcg (Post 805512)
Join the developers meeting https://meet.jit.si/SU2_DevMeeting Wednesday at 15h UK and show us the code.

Thank you guys, I will gladly join the meeting.


All times are GMT -4. The time now is 12:34.