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

UDF HELP!!!!!!!

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

Reply
 
LinkBack Thread Tools Display Modes
Old   April 22, 2004, 06:05
Default UDF HELP!!!!!!!
  #1
paul
Guest
 
Posts: n/a
Hi,

I'm tryin to model a wall flux at the wall of a pipe. The flux is modelled as a constant multiplied by the temp of the wall. I've tried modeling this with a UDF by way of the ADJUST and PROFILE functions as shown:

#include "udf.h"

#define ALPHA 0.005

real temp;

DEFINE_ADJUST(adjust,d)

{

real ID_WALL = 3;

Thread *t = Lookup_Thread(d,ID_WALL);

face_t f;

begin_f_loop(f,d)

{

F_UDMI(F_C0(f,d),THREAD_T0(d),0)=F_T(f,d);

}

end_f_loop(f,d) }

DEFINE_PROFILE(wall_flux,t,i) {

face_t f;

begin_f_loop(f,t)

{

temp=F_UDMI(F_C0(f,t),THREAD_T0(t),0);

F_PROFILE(f,t,i)=ALPHA*(temp);

}

end_f_loop(f,tf) }

The UDF compiles and the model runs. The problem seems to be with my ADJUST function. When I go to post-process the results, I am getting no values stored in the UDM. As I'm not totally familiar with UFD's I was hoping that somebody would be able to give me advice on where I may be going wrong.

Thanks in advance,

Paul

Ps. I was previously in contact with Thomas on this forum. Sorry for not getting back to you. I've been busy with another project. Thanks for you previous help and if you have another advice I'd really appreciate it.
  Reply With Quote

Old   April 22, 2004, 09:33
Default Re: UDF HELP!!!!!!!
  #2
ap
Guest
 
Posts: n/a
You don't need the DEFINE_ADJUST macro to implement your flux function.

You just have to write the following DEFINE_PROFILE macro and to hook it to your wall BC in the Wall Boundary Condition panel.


#include "udf.h"

#define ALPHA 0.005

DEFINE_PROFILE(wall_flux,t,i)
{
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=ALPHA*F_T(f,t);
}
end_f_loop(f,tf)
}


You also don't need the user defined memory for post processing because the UDM in your code just store the temperature at the wall, which is already available by selecting the wall in the plot panel, and by choosing Temperature as variable in the drop down menu.

Hope this helps

Hi

ap
  Reply With Quote

Old   April 22, 2004, 10:27
Default Re: UDF HELP!!!!!!!
  #3
co2
Guest
 
Posts: n/a
in the above code given by ap does F_T(f,t) give temperature at the previous time step ? how can we use F_T(f,t) when it is being solved ? what if i want to get temperature at 2 time steps before ?
  Reply With Quote

Old   April 22, 2004, 23:26
Default Re: UDF HELP!!!!!!!
  #4
FJ
Guest
 
Posts: n/a
Hi,

Some expressions are invalid .

--For DEFINE_ADJUST--

begin_f_loop(f,t)

{

F_UDMI(f,t ,0)=F_T(f,t);

}

end_f_loop(f,t) }

-- For DEFINE_PROFILE--

begin_f_loop(f,t)

{

temp=F_UDMI(f, t,0);

F_PROFILE(f,t,i)=ALPHA*(temp);

}

end_f_loop(f,t) }

--

"F_C0()" and "THREAD_T0()" get the adjacent cell value of specified thread. If you want to get the face value, this macro should not be called in face roop.

FJ
  Reply With Quote

Old   April 23, 2004, 04:12
Default Re: UDF HELP!!!!!!!
  #5
ap
Guest
 
Posts: n/a
It isn't the temperature of the previous time step, it is the temperature at the current time step.

When you solve a PDE, you apply boundary conditions which can be function of the same variable you solver for, it's not a problem. The solver solves the equation and applies the boundary conditions by repeatedly iterating, so it can use the current value of the variable.

If you need previous time steps data, for cells you can use:

C_T_M1(cell, thread) - for previous time step

C_T_M2(cell, thread) - for the time step before the previous one. You can use this macro only if a UDS is defined.

For faces, I don't know if similar macros are available, because the manual doesn't tell anything.

However you can store the previous time step value in a UDM, then move it in another UDM at the next time step using a cycle. So the first UDM contains the value at the previous time step, and the second one the value at two time steps before.

Hi

ap
  Reply With Quote

Old   April 23, 2004, 04:18
Default Re: UDF HELP!!!!!!!
  #6
paul
Guest
 
Posts: n/a
Thanks for all your help. I think I've got the flux to work

all the best

Paul
  Reply With Quote

Old   April 23, 2004, 09:58
Default Re: UDF HELP!!!!!!!
  #7
paul
Guest
 
Posts: n/a
Hi ap,

Thanks a lot for the help with the flux UDF. I am actually modelling species transport and have got the flux UDF to work with the species.

As I try to increase the complexity of the flux bc, I want to include a flux bc that is dependant on the shear stress at the wall. I have tried to write the UDF as follows, using C_U_G.

DEFINE_PROFILE(wall_flux,t,i)

{

cell_t c; face_t f;

begin_f_loop(f,t)

{

if (!Data_Valid_P()) return;

F_PROFILE(f,t,i)=BETA*0.0035*sqrt(pow(C_U_G(c,t)[1],2))*F_YI(f,t,1);

}

end_f_loop(f,t)

}

The "if (!Data_Valid_P()) return;" is from a previous correspondance of yours on this forum. However, I am still getting the following 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: ()

The UDF compiles without a problem and I am able to initialize the problem. However, at iterating I get the error above.

I was wondering if there is any obvious mistake I'm making.

Any help would be greatly appreciated.

All the best

Paul

  Reply With Quote

Old   April 23, 2004, 10:32
Default Re: UDF HELP!!!!!!!
  #8
ap
Guest
 
Posts: n/a
The problem is in the line containing C_U_G(c,t)[1]. You're passing to a cell macro, a face thread, and this gives you the problem.

You should recover the cell thread of the cells adjacent to your faces using

t0 = THREAD_T0(f,t); to recover the cell thread

c0 = F_C0(f,t); to recover the adjacent cell to your face

and passing c0 and t0 to C_U_G.

See the example in the FLUENT manual, in the section where the DEFINE_UDS_FLUX is presented for a code sample where these commands are used.

Hi

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
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 21:38
Dynamic Mesh UDF Qureshi FLUENT 1 December 2, 2009 01:27
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 05:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


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