CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   Modify inlet B.C. (http://www.cfd-online.com/Forums/fluent/93630-modify-inlet-b-c.html)

ypchen October 21, 2011 03:23

Modify inlet B.C.
 
Hi, everybody.
I want to get some position's data to be using at the inlet, for example, I take the temperature value at x = 0.01 m(my model is 2D), and the inlet temperature is also the value at x = 0.01m. I know I should use the UDF, but how can I do it by using UDF code ?

Thank you very much.

Amir October 21, 2011 04:03

Hi,
you can use DEFINE_PROFILE macro!
There, you can provide your temperature as a function of space. (it's more efficient to fit a curve with your data)

Bests,

ypchen October 21, 2011 09:17

Hi,Amir
I had used DEFINE_PROFILE macro in my code, actually, my original inlet BC is dT/dX=0, but I don't know how to set it, so I want to get temperature value that near the inlet, creating a small temperature difference.

Amir October 21, 2011 13:04

Quote:

Originally Posted by ypchen (Post 328902)
Hi,Amir
I had used DEFINE_PROFILE macro in my code, actually, my original inlet BC is dT/dX=0, but I don't know how to set it, so I want to get temperature value that near the inlet, creating a small temperature difference.

Hi,

I know 3 procedures for your purpose:

1) the easiest one is to use UDS equation instead of energy equation (there are similar with some modifications); then you can easily set d/dn over boundaries.
2) use a UDF with DEFINE_PROFILE macro for your inlet and set temperature of each face equal to adjacent cell center value; it would be accurate for fine mesh near inlet.
3) you can also write a UDF for heat flux over your boundary; as you know, @ your inlet, heat flux is consist of convective and diffusive flux; with dT/dX=0, you have ignored diffusive flux, so you can set heat flux to convective one.

Bests,

ypchen October 23, 2011 21:27

Thank for your help, Amir.

I'll try your ways, it seems very helpful for me.

Thank you again !

ypchen October 24, 2011 23:40

Hi, Amir, I have some question about your suggestion :


2) use a UDF with DEFINE_PROFILE macro for your inlet and set temperature of each face equal to adjacent cell center value; it would be accurate for fine mesh near inlet.
---- How to get the adjacent cell value in UDF code ?
3) you can also write a UDF for heat flux over your boundary; as you know, @ your inlet, heat flux is consist of convective and diffusive flux; with dT/dX=0, you have ignored diffusive flux, so you can set heat flux to convective one.

---- My B.C. type is pressure inlet, can I use DEFINE_HEAT_FLUX at the inlet ? If it can work, how to ignored diffusive flux in UDF code ?


thank you very much !

Amir October 25, 2011 03:50

Quote:

Originally Posted by ypchen (Post 329266)
How to get the adjacent cell value in UDF code ?

use:
F_C0(f,t) , THREAD_T0(t) to access cell and its thread index. (refer to UDF manual table 3.2.24-25).

Quote:

Originally Posted by ypchen (Post 329266)
My B.C. type is pressure inlet, can I use DEFINE_HEAT_FLUX at the inlet ? If it can work, how to ignored diffusive flux in UDF code ?

Oops! you're right; this can be done over wall boundaries. So you can use suggestions 1 or 2.

Bests,

ypchen October 31, 2011 10:51

Hi,Amir
I follow your suggestion to useF_C0(f,t) and THREAD_T0(t) to access cell and its thread index. When I interpreted my udf, it's OK, but the error occured after I initialize my system. I post my code below :


DEFINE_PROFILE(inlet_temp,thread,position)
{
real temp_in ;
Thread *t ;
cell_t c0 ;
Thread *t0 ;
face_t f ;
begin_f_loop(f,thread)
{
c0 = F_C0(f,t);
t0 = THREAD_T0(f,t);
temp_in = C_T(c0,t0);
F_PROFILE(f,thread,position) =temp_in;
}
end_f_loop(f,thread)

}

can you see something wrong in my code ? thank you !

Amir October 31, 2011 11:05

Hi,

check this and inform me:

Code:

DEFINE_PROFILE(inlet_temp,thread,position)
{
 real temp_in;
 cell_t c0;
 Thread *t0;
 face_t f;
 begin_f_loop(f,thread)
 {
 c0 = F_C0(f,thread);
 t0 = THREAD_T0(f,thread);
 temp_in = C_T(c0,t0);
 F_PROFILE(f,thread,position) =temp_in;
 }
 end_f_loop(f,thread)
}

Bests,

ypchen October 31, 2011 12:03

Hi, Amir

I try the new code, but the same error still happend. The error was :

Code:


FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.


Amir November 1, 2011 03:07

Quote:

Originally Posted by ypchen (Post 330178)
Hi, Amir

I try the new code, but the same error still happend. The error was :

Code:


FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.


Dear friend,

you have a bug in your code; I correct it for you but you said that ther is not any problem in compilation before!!!
try this code: (I checked that as compiled UDF) .... there was extra argument for THREAD_T0. Also ensure you've activated energy equation and initialize that.
Code:

# include "udf.h"
DEFINE_PROFILE(inlet_temp,thread,position)
{
 real temp_in;
 cell_t c0;
 Thread *t0;
 face_t f;
 begin_f_loop(f,thread)
 {
 c0 = F_C0(f,thread);
 t0 = THREAD_T0(thread);
 temp_in = C_T(c0,t0);
 F_PROFILE(f,thread,position) =temp_in;
 }
 end_f_loop(f,thread)
}

Bests,


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