# map outlet boundary profile as an inlet condition using UDF

 Register Blogs Members List Search Today's Posts Mark Forums Read

December 18, 2014, 19:21
map outlet boundary profile as an inlet condition using UDF
#1
Senior Member

Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21
Hello to all

I have a channel with arbitrary cross section and I need a fully developed velocity profile for the inlet.

I know that I can use write/read profile options in fluent, however I need to manipulate data as I need to know u/u_mean ratio for the cross section in fully developed condition.

Then I use the calculated ratio for the real transient boundary condition in my UDF.

So I have created a straight channel with the same cross section. Then I have used write profile option for velocity magnitude at the outlet.

After that, I have manually calculated velocity ratio.

I have two different input file:

1) mean transient velocity magnitude

2) velocity ratio

At the end, I need to apply transient fully developed velocity profile for the inlet. Here is the code:

Code:
#include "udf.h"

int size = 0;
float u_mean[1201];
float *u_ratio;

{
#if !RP_HOST
int i = 0;

for (i=0;i<1201;i++)
{
u_mean[i] = 0.0;
}

{
for (i=0;i<1201;i++)
{
}
Message("\n");
}
else
{
Message("\nError opening file");
Message("\n");
exit(EXIT_FAILURE);
}
Message("First mean velocity: %.9f", u_mean[0]);
Message("\n");
#endif
}

{
#if !RP_HOST
int j = 0;
FILE *fp;
Domain *d;
d = Get_Domain(1);

u_ratio = (float *)malloc(size * sizeof(float));

for (j=0;j<size;j++)
{
u_ratio[j] = 0.0;
}

fp = fopen("outlet_velocity_ratio.txt","r");

if (fp!=NULL)
{
for (j=0;j<size;j++)
{
fscanf(fp, "%f\n", &u_ratio[j]);
}
Message("\n");
}
else
{
Message("\nError opening file");
Message("\n");
exit(EXIT_FAILURE);
}
fclose(fp);
Message("First ratio: %.9f", u_ratio[0]);
Message("\n");
#endif
}

{
#if !RP_HOST
real current_time;
int counter;

current_time = CURRENT_TIME;

counter = (current_time - steady_offset) / CURRENT_TIMESTEP;

{
}
#endif
}

{
#if !RP_HOST

{
}
#endif
}
The problem is inconsistent order between faces in the thread and velocity ratio file which results in disordered velocity distribution at the inlet as you can see in the attached pictures.

I know the problem is here, when I use f_steady for the array index which means the written data and current face indexing is inconsistent:

Code:
Attached Images
 correct_one.JPG (25.6 KB, 21 views) result.JPG (30.9 KB, 19 views)

 December 19, 2014, 03:34 #2 Senior Member   Daniel Join Date: Mar 2013 Location: Noshahr, Iran Posts: 348 Rep Power: 21 To further illustrate the problem, I want to know whether it is possible to do the following in a udf: 1) I have a file containing x,y,z and velocity magnitude for the outlet of a straight tube. 2) I want to map this velocity at the inlet of another case using a UDF ( I know I can read the profile using fluent itself but I need to do the same thing in my UDF)

 June 20, 2016, 11:53 #3 New Member   Join Date: May 2012 Posts: 2 Rep Power: 0 Hi, have you achieved any success? If yes, I would highly appreciate if you could explain your final workflow. Thanks in advance!