CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   UDF, using DEFINE_ADJUST to change a boundary condition (

Jonas Larsson March 6, 2000 11:11

UDF, using DEFINE_ADJUST to change a boundary condition
I'm computing a highly swirling 2D axisymmetric flow. The geometry is very complicated and during startup it is impossible to avoid getting backflow in a couple of the pressure outlets. When this happens the backflow will have zero swirl when it comes into the domain. This is very bad since all fluid in the domain has a very high swirl and the result is exploding turbulence and a higly viscous pocket of backflow that never dissapears, even if you set vacuum on the pressure outlet.

In order to solve this I'm trying to write a UDF to specify a backflow swirl on pressure outlets. I think that it should be possible to use the DEFINE_ADJUST function to do this. However, I have not got any examples of a similar usage of this function and the documentation isn't very helpful. What I'd like to do is simply to speicify the swirl velocity in the cells next to backflow-regions on pressure outlets. Anyone have any examples of how DEFINE_ADJUST is used? I'd appreciate any hints.

Greg Perkins March 7, 2000 01:40

Re: UDF, using DEFINE_ADJUST to change a boundary condition
Here's two possibilities:-


Presumably you know the spatial position of the cells that you wish to fix the velocity in. In this case, you can use C_CENTROID within a thread & cell loop to find out the location of the current cell, and then if its in the region you're interested in set the fixed velocity otherwise do nothing.

Within the DEFINE_ADJUST function I'd adapt the UDF example 5.5 (p84) of the December 1998 Fluent UDF manual on Solution Initization to do what I've described above.


Use DEFINE_SOURCE function which modifies the appropriate transport eqn to fix the velocities of the cells you're interested in. In the UDF manual see example 5.2.3 . I've used something like this before with no problems. This might be better than 1.



Andrew Ooi March 8, 2000 18:47

Re: UDF, using DEFINE_ADJUST to change a boundary condition
I am just wondering if you have tried to obtain an initial solution by first setting the swirl component to zero. Then slowly increase the swirl at the inlet (and getting a converged solution each time) to the desired value.

Jonas Larsson March 9, 2000 03:42

Re: UDF, using DEFINE_ADJUST to change a boundary condition
Yes, I've tried to ramp things up slowly. This helps and you can avoid problems in some outlets by doing like this. However, if you just happen to get one-single cell with back-flow once you have the full swirl up then you have to start all over again ... so it isn't very practical. Somehow specifying a back-flow swirl would help a lot.

Sung-Eun Kim March 21, 2000 19:51

Re: UDF, using DEFINE_ADJUST to change a boundary condition
Jonas, Honestly, I can't hide my skepticism about what you're trying to do. But in the spirit of "customer's always right", here's a little piece of code you can try. It's obviously a silly example (5 % of the swirl at adjacent interior cell). And I'm not quite sure whether this will work or not, because it seems the swirl is updated on the boundary before the derivative calculation, with 0 for pressure outlet.

DEFINE_ADJUST(set_nonzero_swirl, domain) { Thread *t; face_t f; real whatever_swirl;

if (!Data_Valid_P())

return; /* error check*/

thread_loop_f (t,domain)

switch (THREAD_TYPE(t))








begin_f_loop (f, t)


c0 = F_C0(f, t); /* adjacent interior cell */

t0 = t->t0; /* adjacent interior thread */

whatever_swirl = C_WSWIRL(c0,t0)*0.05;

if (F_FLUX(f,t) < 0.0) /* if backflow occurs */

F_STORAGE_R(f,t,SV_W) = whatever_swirl;


end_f_loop (f, t)

} }

All times are GMT -4. The time now is 13:42.