CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF problem (https://www.cfd-online.com/Forums/fluent/30873-udf-problem.html)

Thomas January 30, 2003 12:35

UDF problem
 
I have this UDF (interpented) in order to add a source in a porous medium region.

------------------------------------------------

#include "udf.h"

DEFINE_SOURCE(cell_x_source, c, t, dS, eqn)

{

real T1; real T2; real source;

if (FLUID_THREAD_P(t) && THREAD_VAR(t).fluid.porous)

{

C_T(c,t) = T1;

} else

{

C_T(c,t) = T2;

}

source = T1-T2;

dS[eqn] = 0; return source;

}

----------------------------------------- But when I compile it I take the following message: ....... line 7: structure reference not implement (the line 7 is the line with the IF sentence)

Thanks in advance for any help

Greg Perkins February 4, 2003 20:01

Re: UDF problem
 
you cannot set the C_T(c,t) = value;

C_T is the temperature and this is the output of the energy balance. It cannot be set by the user!

Also, in your if, only one C_T = T1, T2 will be executed, thus defining a source by the difference doesn't make much sense!

What are you trying to accomplish. If you wish to fix the temperature in some cells then your source should look a bit like:

source = 1.0e10*(value - C(T(c,t)); dS[eqn] = -1.0e10;

Try reading the book by Patankar - Numerical heat Transfer 1980, - its easy to understand and a great help when setting source terms for C.V. models like Fluent.

Greg

Thomas February 6, 2003 08:51

Re: UDF problem
 
Thanks for the answer. In fact what am I try to do is to add a heat source in a porous medium. This source will be a fuction of the temperature difference between the porous medium and its surrounding air. Its somehow familiar with one of your subrutines you have posted here where you calculate the heat transfer between the solid and gas. In my problem there is porous and air.

Any help will appreciated

Regards Thomas

Greg Perkins February 6, 2003 17:22

Re: UDF problem
 
To do that in Fluent, you will need to model the solid temperature yourself using a UDS and not use the inbuilt porous media model. Why?

Well, Fluent assumes that the porous media and surrounding fluid are at thermal equilibrium and hence there can be no heat transfer between the two - it just uses a single temperature! In order to model heat transfer you will need to have separate energy equations for the gas and solid. For the solid you can modify my udf code which does that.Then you can write your source term as a function of the temperature difference. In fact the code I posted does all this, you can just modify the heat transfer co-efficient for your application.

Note you will need two source terms - one for each energy equation and they will need to be consistent!

Greg

Thomas February 7, 2003 02:49

Re: UDF problem
 
Thank you very much! I will try it

Regards Thomas

Thomas February 7, 2003 08:49

Re: UDF problem (clarification)
 
Does the proposed UDF valid only for 4.5x version?

I try to implement in 6.02 and I took the followning message during the compilation:

line (250) redefinition; different basic types

The line (250) corresponds to the routine for the diffusivity

Thanks again

Thomas

Greg Perkins February 9, 2003 16:51

Re: UDF problem (clarification)
 
Yeah I remember that - it was originally written for v5 but to get it to work in v6 you need to rename that diffusivity function. It turns out that Fluent 6 includes a new function with the same name as my original udf, and hence doesn't like it.

I found that a few times, in my udfs.

Greg



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