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

Problem with UDF

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 23, 2001, 21:47
Default Problem with UDF
  #1
murthy
Guest
 
Posts: n/a
Hi, I have developed a code for finding the centroids of each individual cells in a fluid zone.But I run into the error when i try to print out the centroids of the cells, if remove that part from the code the code runs fine.If any body could help me with tis problem would greatly be appreciated. The code runs this way: # include "udf.h" FILE *fout; int id =5;//id of the fluid domain extern Domain *domain; DEFINE_ON_DEMAND(get_coords) {

cell_t c;

face_t f;

real x[ND_ND];

double vol;

int i;

Thread *thread = Lookup_Thread(domain,id);

fout = fopen("coordinate.out","w");

i=0;

fprintf(fout,"thread id %d\n",id);

/*if(fout==NULL)

{

printf("error");

}*/

thread_loop_c(thread,domain)

{

i = i+1;

begin_c_loop(c,thread)

{

C_CENTROID(x,c,thread);

fprintf(fout,"%d %g \n",i,x[0]);

i =i+1;

}

end_c_loop(c,thread)

}

fclose(fout); } Thanks in advance, Murthy

  Reply With Quote

Old   October 24, 2001, 10:02
Default Re: Problem with UDF
  #2
keith
Guest
 
Posts: n/a
A simple workaround might be to copy the centroid x,y, and z values into the u,v,w velocity arrays:

thread_loop_c(thread,domain)

{

begin_c_loop(c,thread)

{

C_CENTROID(x,c,thread);

C_U(c,thread) = x[0];

C_V(c,thread) = x[1];

C_W(c,thread) = x[2];

}

end_c_loop(c,thread)

}

Then just export the "velocity" field. This might not be exactly what you're looking for.

Regards,

Keith
  Reply With Quote

Old   October 24, 2001, 14:12
Default Re: Problem with UDF
  #3
murthy
Guest
 
Posts: n/a
Hi, The function runs fine with the C_CENTROID(x,c,thread) part,but when I assign an value of x[0] to another variable, it shows me an error called segmentation violation when this program is run as an compiled/interpreted code.The domain consists of 90 2D quadrilateral cells and Iam able to loop through all the cells.The variable x is defined as real x[2]. Thanks in advance, Murthy
  Reply With Quote

Old   October 24, 2001, 14:53
Default Re: Problem with UDF
  #4
keith
Guest
 
Posts: n/a
Just to check, are you initializing the flowfield before you run your ON DEMAND function? It may not have any arrays for u and v yet. I usually get seg faults when I try and assign something that has not been initialized yet.

  Reply With Quote

Old   October 24, 2001, 19:08
Default Re: Problem with UDF
  #5
murthy
Guest
 
Posts: n/a
Hi, Thanks for the reply.Apart from the aforesaid I had to include the metric.h header file and sg.h header file to get the results.Once agin thanks for every one who has contributed to my problem. Murthy
  Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 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 06:05
Problem with my udf july Fluent UDF and Scheme Programming 3 June 20, 2010 06:56
UDF problem mansha goraya FLUENT 0 October 29, 2007 00:31
udf compiling problem akr FLUENT 3 August 22, 2007 07:14
UDF problem chiseung FLUENT 4 January 10, 2002 09:58


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