CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > FLUENT

Problem accessing Temp. Gradient . . .

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

Reply
 
LinkBack Thread Tools Display Modes
Old   December 9, 2003, 19:43
Default Problem accessing Temp. Gradient . . .
  #1
Satish
Guest
 
Posts: n/a
Hi

I have a problem accessing the temperature gradient in a UDF.

I have a heat flux acting on the walls.I am writing using DEFINE_PROFILE. My bc is a function of temperature gradient.

In the tutorials, they gave the macro as C_T_G(c,t)[0].

but when i try to use this it is giving me a error. I even set the "solve/set/expert ", but i could not get it.

Can anyone help me in this

Thanks Satish

The path of it is --> \Fluent.Inc\fluent6.1.22\help\html\udf\node107.htm
  Reply With Quote

Old   December 10, 2003, 04:10
Default Re: Problem accessing Temp. Gradient . . .
  #2
ccc
Guest
 
Posts: n/a
hi Satish,

Did you use a coupled solver?

good luck.
  Reply With Quote

Old   December 10, 2003, 16:21
Default Re: Problem accessing Temp. Gradient . . .
  #3
ap
Guest
 
Posts: n/a
Which kind of error do you obtain?

Do you check gradients definition before using the macro. See the utilities section of UDF manual for that.

Hi

ap
  Reply With Quote

Old   December 10, 2003, 18:56
Default Re: Problem accessing Temp. Gradient . . .
  #4
Satish
Guest
 
Posts: n/a
I am not getting even with coupled solver.

The error is : Error: 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.

Error Object: ()

Thanks Satish
  Reply With Quote

Old   December 11, 2003, 13:59
Default Re: Problem accessing Temp. Gradient . . .
  #5
ap
Guest
 
Posts: n/a
Nothing to do with the solver. Your problem is that gradients are not defined on the first iteration, so it's impossible to read them.

Insert this line

if (!Data_Valid_P()) return;

before accessing gradients and answer YES to the question "Keep memory solver from being freed?" which will be asked you if you type the command /solve/set/expert.

Hi

ap
  Reply With Quote

Old   December 11, 2003, 17:54
Default Re: Problem accessing Temp. Gradient . . .
  #6
Satish
Guest
 
Posts: n/a
Thanks for ur help, now i am able to compile but gives a error when running.

i am giving a sample prog. ofcourse my profile is very big eqn. i am also applying flux on the walls.

even this is not working, i also tried with complied udf.

can u help me . . .

#include "udf.h"

DEFINE_PROFILE(test_profile1, t, i)

{ real x[ND_ND];

cell_t c;

begin_c_loop(c, t)

{

if (!Data_Valid_P()) return;

F_PROFILE(c, t, i) = (1.1*C_T_G(c,t)[0]);

} end_c_loop(c, t)

}
  Reply With Quote

Old   December 12, 2003, 05:48
Default Re: Problem accessing Temp. Gradient . . .
  #7
Andrew Garrard
Guest
 
Posts: n/a
Are you hooking this profile into a boundary such as a wall. If you are then I think you want to be using a face loop rather than a cell loop. If you applying a source term to a flow domain then you can use a DEFINE_SOURCE macro. What is it that you are trying to achieve?
  Reply With Quote

Old   December 12, 2003, 12:32
Default Re: Problem accessing Temp. Gradient . . .
  #8
Satish
Guest
 
Posts: n/a
Thanks for ur reply. Well i am hooking it up. for my model i have a heat flux. This should generate the C_T_G(c,t)[0] term.

I also have a udf for heat flux. its working. In the given udf below i wanna set the wall shear (Specified Shear)as follows

DEFINE_PROFILE(shear_profile,t,i)

{

real term1,term2;

cell_t c;

begin_c_loop (c,t)

term1 = 5*C_R(c,t)*sqrt(2*M_PI*UNIVERSAL_GAS_CONSTANT*C_T( c,t)/28.0134)/16;

term2 = (3.*0.0000185)/(4.*C_R(c,t)*C_T(c,t));

if (!Data_Valid_P()) return;

F_PROFILE(c,t1,i) = term1*(C_U(c,t)+term2*C_T_G(c,t)[0]);

end_c_loop(c,t1)

}

In this when i remove the gradient term it is successfully running. Can u help me out in this . . .

Thanks

Satish
  Reply With Quote

Old   December 12, 2003, 15:47
Default Re: Problem accessing Temp. Gradient . . .
  #9
ap
Guest
 
Posts: n/a
As said by Andrew Garrard, if you want to loop over a boundary, replace the begin_c_loop with a begin_f_loop (same for the end_c_loop).
Also, you should use F_ macros instead of C_ macros.
If you need to have access to cells value of some variable, you can retrieve the cell corresponding to the current face using F_C0(face, thread) macro.

Here there is an example of DEFINE_PROFILE on a wall.


DEFINE_PROFILE (wall_profile, t, position)
{
face_t f;
cell_t c0;
Thread *t0 = t->t0 /* t0 -> cell thread */
real rho;

begin_f_loop(f,t)
{
c0 = F_C0(f,t);

...

rho = C_R(c0,t0); /*Read density in the cell: use c0 and t0 to access cell values, use f and t for face value*/
F_PROFILE(f,t,position) = /*your profile function*/
}
end_f_loop{f,t,position}
}



P.S.
There seems to be some error in your code, maybe due to cut and paste: you start looping on cells with thread t and end the loop with the thread t1:

begin_c_loop (c,t)
...
end_c_loop(c,t1)

Also in the F_PROFILE you use t1 instead of t.

Hi

ap
  Reply With Quote

Old   December 12, 2003, 17:30
Default Re: Problem accessing Temp. Gradient . . .
  #10
Satish
Guest
 
Posts: n/a
Hi i am sorry, but the pointer line gives me error. THe line Thread *t0 = t->t0 is giving error like "structure reference not implemented". My udf is

DEFINE_PROFILE(shear_profile,t,i) {

real term1,term2,slip,rho;

real vel,tc,tp,dt,den,dtdxw;

cell_t c,c0;

face_t f;

Thread *t0 = t->t0;

if (!Data_Valid_P()) return;

begin_f_loop (f,t)

c0 = F_C0(f,t);

vel = F_U(f,t);

tc = F_T(f,t);

if (!Data_Valid_P()) return;

dtdxw = C_T_G(c0,t0)[0];

rho = 28.0134*F_P(f,t)/(F_T(f,t)* UNIVERSAL_GAS_CONSTANT);

if(tc <= 0.)

{

term1 = 0.;

}

else

{

term1 = 5*rho*sqrt(2*M_PI*UNIVERSAL_GAS_CONSTANT*F_T(f,t)/28.0134)/16;

}

term2 = 0;

if(rho == 0. || tc == 0.)

{

term2 = 0.;

}

else

{

term2 = (3.*0.0000185)/(4.*rho*tc);

}

slip = term1*(vel+dtdxw*term2);

F_PROFILE(f,t,i) = slip;

end_f_loop(f,t)

}

Any help w'd be appreciated...

Thanks

Satish
  Reply With Quote

Old   December 13, 2003, 08:54
Default Re: Problem accessing Temp. Gradient . . .
  #11
ap
Guest
 
Posts: n/a
You're trying to use this UDF as interpreted, but you have to compile it.

I succesfully compiled your udf (I just had to put the first { on a new line, because it gave me an error message).

If you're using FLUENT 6.1, compiling the UDF is really easy. If you work under Windows, you need Microsoft Visual C++, while under Linux you already have the C compiler.

1) Put the source file in the same directory of the case file.

2) Go to Define->User-Defined->Functions->Compiled

3) Click on Add and look for your source file

4) Click on Build

5) Click on Load

Use your UDF as usual.

Under FLUENT 6.0 it's a bit more difficult, but the manual contains the step by step procedure.

Hi

ap
  Reply With Quote

Old   December 13, 2003, 16:46
Default Re: Problem accessing Temp. Gradient . . .
  #12
Satish
Guest
 
Posts: n/a
Hi

Thanks for ur valuble reply, now i am able to compile it but when initializing the prob, it is giving the same error.

Thank u very much

Satish
  Reply With Quote

Old   December 15, 2003, 09:03
Default Re: Problem accessing Temp. Gradient . . .
  #13
ap
Guest
 
Posts: n/a
Are you using a user defined initialization function?

If you use UDM or UDS, make sure to properly set them in FLUENT.

Hi

ap
  Reply With Quote

Old   December 15, 2003, 13:58
Default Re: Problem accessing Temp. Gradient . . .
  #14
Satish
Guest
 
Posts: n/a
Hi

I am not using any UDS or UDM or Init function. I just need to set the profile to the walls. mine is a pressure inlet and pressure outlet. with flux acting on walls and i need to set the shear profile on the walls.

Thanks

Satish
  Reply With Quote

Old   December 15, 2003, 17:03
Default Re: Problem accessing Temp. Gradient . . .
  #15
ap
Guest
 
Posts: n/a
Ok. Try this function. I tested it and it works. I just added a check to see if gradient have been stored. If so, it does calculations, else it gives a null profile.

I tested it putting a "Message("Working")" command in the first if, and it gives a null profile during first iteration, then it properly calculates.


if (NULL != THREAD_STORAGE(t0,SV_T_G))
{
//code
}
else
{
//Profile = 0
}



The complete function is the following:


#include "udf.h"

DEFINE_PROFILE(shear_profile,t,i)
{

real term1,term2,slip,rho;
real vel,tc,tp,dt,den,dtdxw;
cell_t c,c0;
face_t f;
Thread *t0 = t->t0;

if (!Data_Valid_P()) return;

begin_f_loop (f,t)
{

if (NULL != THREAD_STORAGE(t0,SV_T_G))
{

c0 = F_C0(f,t);
vel = F_U(f,t);
tc = F_T(f,t);
dtdxw = C_T_G(c0,t0)[0];

rho = 28.0134*F_P(f,t)/(F_T(f,t)* UNIVERSAL_GAS_CONSTANT);
if(tc <= 0.)
{
term1 = 0.;
}
else
{
term1 = 5*rho*sqrt(2*M_PI*UNIVERSAL_GAS_CONSTANT*F_T(f,t)/28.0134)/16;
}

term2 = 0;

if(rho == 0. || tc == 0.)
{
term2 = 0.;
}
else
{
term2 = (3.*0.0000185)/(4.*rho*tc);
}
F_PROFILE(f,t,i) = term1*(vel+dtdxw*term2);
}
else
{
F_PROFILE(f,t,i) = 0.; }
}
end_f_loop(f,t)

}



P.S. The check on negative temperature can be avoided. FLUENT uses Kelvin, so T >= 0 always.

Hope it works.

Hi

ap
  Reply With Quote

Old   December 16, 2003, 14:42
Default Re: Problem accessing Temp. Gradient . . .
  #16
Satish
Guest
 
Posts: n/a
Hi,

Thank you very much...I got it. . .

Thanks

Satish
  Reply With Quote

Old   December 16, 2003, 14:44
Default Re: Problem accessing Temp. Gradient . . .
  #17
ap
Guest
 
Posts: n/a
You're welcome.

ap
  Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
temperature gradient problem in udf Souviktor Fluent UDF and Scheme Programming 3 July 11, 2015 15:49
UDF - accessing face variable problem argeus FLUENT 2 February 9, 2011 05:08
Problem of mass conservation in multispecies flow in porous media and T gradient pilou FLUENT 0 January 31, 2011 09:19
static temperature is higher than total temp. in buoyancy problem amirbahador FLUENT 2 October 24, 2010 07:21
UDF help (about temp gradient) Jihwan FLUENT 10 January 31, 2007 01:02


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