CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   3D rectangular velocity profile UDF (https://www.cfd-online.com/Forums/fluent-udf/144751-3d-rectangular-velocity-profile-udf.html)

Chalke06 November 20, 2014 13:54

3D rectangular velocity profile UDF
 
Hi guys,

I am quite inexperienced with UDFs and was wondering if anyone could help me, I am trying to create a UDF for a fluent simulation. It is a 3D domain (cuboid) with an inlet face that needs to have a boundary layer conforming to the law:
U=((y/d)^(1/7))*Ufree


Where U is the inlet velocity at a given point, y is the vertical coordinate, d (delta) is the boundary layer thickness and Ufree is the freestream velocity.

When y=d (top of boundary layer) then U=Ufree


When I try to interpret the file in fluent I get several errors, but I can't see where the code is wrong. The fluent UDF manual only has one a code for a 2D velocity profile. The code I've been trying is below:


#include "udf.h"

#define P 1./7. //power law n value 7//
#define del 0.005 // boundary layer thickness value//
#define ufree 0.05 //freestream velocity value//


DEFINE_PROFILE(x_velocity,thread,position)
{
real x[ND_ND], real y, real z;


{
face_t f;
begin_f_loop(f, thread)
}

{
F_CENTROID(x, f, thread);
y=x[1];
z=x[2];
if (y<=del)
F_PROFILE(f, thread, position) = ufree*pow(y/del,P);
else
F_PROFILE(f, thread, position) = ufree;
}

end_f_loop(f, thread)
}

Does anyone have a working 3D velocity profile UDF that is similar I could use? Or if anyone could help me I'd really appreciate it.

upeksa November 21, 2014 03:17

#include "udf.h"

#define P 1./7. //power law n value 7//
#define del 0.005 // boundary layer thickness value//
#define ufree 0.05 //freestream velocity value//


DEFINE_PROFILE(x_velocity,thread,position)
{
real x[ND_ND], y;
face_t f;

begin_f_loop(f, thread)
{
F_CENTROID(x, f, thread);
y=x[1];

if (y<=del)
F_PROFILE(f, thread, position) = ufree*pow(y/del,P);
else
F_PROFILE(f, thread, position) = ufree;
}
end_f_loop(f, thread)
}

//Cheers

Chalke06 November 21, 2014 07:49

Eureka!! It works perfectly!

Thank you so much, really appreciate it!

:)

Torante August 6, 2016 13:37

This is over a year later, but I wanted to add that Upeksa's answer helped me a lot also. I modified it to apply to 2D duct flow (ie, walls at both top and bottom of domain, instead of flow over a flat plate). The modified code reads as follows:

#include "udf.h"

#define P 1./7. //power law n value 7//
#define del 0.0061 // boundary layer thickness value//
#define ufree 17.8778 //freestream velocity value//
#define ymin -0.0381
#define ymax 0.0381

DEFINE_PROFILE(x_velocity,thread,position)
{
real x[ND_ND], y;
face_t f;

begin_f_loop(f, thread)
{
F_CENTROID(x, f, thread);
y=x[1];

if (y >= ymax-del)
F_PROFILE(f, thread, position) = ufree*pow((ymax-y)/del,P);
else if (y <= del+ymin)
F_PROFILE(f, thread, position) = ufree*pow((y-ymin)/del,P);
else
F_PROFILE(f, thread, position) = ufree;
}
end_f_loop(f, thread)
}


I spent a great deal of time struggling to find another case of a double power law profile in duct flow, so I'm adding this here in case it can help someone else.


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