CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

An UDF programming problem

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 10, 2013, 00:45
Default An UDF programming problem
  #1
New Member
 
李弘扬
Join Date: Jan 2012
Posts: 12
Rep Power: 14
lihongyang0 is on a distinguished road
I am an UDF new learner. I am dealing with a 2D, transient, two-phase, cavitation problem. I need to capture the interface between the two phase every iteration. And make the heat flux through a part of the interface constant. The following is my code:
#include "udf.h"
DEFINE_ADJUST(my_adjust,d)
{
Domain *mixture_domain;
cell_t c;
int phase_domain_index=1;
int temp1;
int temp2;
int K;
face_t f;
Thread *mixture_thread;
Thread *subthread=THREAD_SUB_THREAD(mixture_thread,phase_ domain_index);
real xc[ND_ND];
thread_loop_c(c,subthread)
{
C_CENTROID(xc,c,subthread);
if(xc[0]<0.04586)
{
temp=C_T(c,subthread);
K=C_K_L(c,subthread);

C_T_G(c,subthread)[1]=300000000/K;
}
}
}


The code has been interpreted. But FLUENT cannot go on the calculation. Please help me correct the code. Thank you very much!!!
lihongyang0 is offline   Reply With Quote

Old   March 13, 2013, 05:34
Default
  #2
Senior Member
 
Paritosh Vasava
Join Date: Oct 2012
Location: Lappeenranta, Finland
Posts: 732
Rep Power: 23
vasava will become famous soon enough
Did you try compiling the code instead of interpret?

The fluent manual suggest that UDF with DEFINE_ADJUST works only after compiling.
vasava is offline   Reply With Quote

Old   March 20, 2013, 18:40
Default
  #3
Member
 
Join Date: Dec 2012
Posts: 92
Rep Power: 14
beer is on a distinguished road
Hi
I will try to help a little bit.
First, mixture thread is the thread you should use for your loop. The THREAD_SUB_THREAD have to be inside this looping operation. In this case you give subthread a phase-level thread of a mixture thread which isn't defined.
Second, I'm not 100% sure about this, but I think it isn't possible to set a temperature gradient, because it is a derived value in your flow field.
At least your looping macro uses the wrong input and you have to loop over the cells in every thread, too. (Domain->Loop Thread-> Loop Cells -> Cell Operations). Check out the UDF Manual about this.
However good luck with your solution.
Greetings
beer is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM Rizwan Fluent UDF and Scheme Programming 40 March 18, 2018 07:05
Problem with my udf july Fluent UDF and Scheme Programming 3 June 20, 2010 07:56
problem with udf programming in fluent saranyasimi Main CFD Forum 0 December 1, 2009 13:19
UDF problem mansha goraya FLUENT 0 October 29, 2007 01:31
udf compiling problem akr FLUENT 3 August 22, 2007 08:14


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