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

HELP:Fluent UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 23, 2010, 21:02
Default HELP:Fluent UDF
  #1
New Member
 
xinyu zhao
Join Date: Sep 2009
Posts: 19
Rep Power: 16
zhaoxinyu is on a distinguished road
The fluent udf manuall has a example "DEFINE_ON_DEMAND(get_coords)".When I use it, it can compile, but confronts error after execute on demand. As follow:

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: ()
I don't know why,please tell me if you know it. Thank you!

The programm as follow:

#include "udf.h"
FILE *fout;
void Print_Thread_Face_Centroids(Domain *domain, int id)
{
real FC[2];
face_t f;
Thread *t=Lookup_Thread(domain,id);
fprintf(fout,"thread id %d\n",id);
begin_f_loop(f,t)
{
F_CENTROID(FC,f,t);
fprintf(fout,"f%d %g %g %g\n",f,FC[0],FC[1],FC[2]);
}
end_f_loop(f,t)
fprintf(fout,"\n");
}

DEFINE_ON_DEMAND(get_coords)
{
Domain *domain;
fout=fopen("faces.out","w");
Print_Thread_Face_Centroids(domain,4);
Print_Thread_Face_Centroids(domain,5);
fclose(fout);
}
zhaoxinyu is offline   Reply With Quote

Old   March 24, 2010, 13:14
Default
  #2
Senior Member
 
Micael
Join Date: Mar 2009
Location: Canada
Posts: 156
Rep Power: 18
Micael is on a distinguished road
There is missing something in the function "get_coords"

The domaine variable should be assigned a value. You can add that line below the declaration of domain:
domain = Get_Domain(1);

So it becomes:

DEFINE_ON_DEMAND(get_coords)
{
Domain *domain;
domain = Get_Domain(1);
fout = fopen("faces.out", "w");
Print_Thread_Face_Centroids(domain, 2);
Print_Thread_Face_Centroids(domain, 4);
fclose(fout);
}
Micael is offline   Reply With Quote

Old   March 25, 2010, 20:20
Default
  #3
New Member
 
xinyu zhao
Join Date: Sep 2009
Posts: 19
Rep Power: 16
zhaoxinyu is on a distinguished road
Quote:
Originally Posted by Micael View Post
There is missing something in the function "get_coords"

The domaine variable should be assigned a value. You can add that line below the declaration of domain:
domain = Get_Domain(1);

So it becomes:

DEFINE_ON_DEMAND(get_coords)
{
Domain *domain;
domain = Get_Domain(1);
fout = fopen("faces.out", "w");
Print_Thread_Face_Centroids(domain, 2);
Print_Thread_Face_Centroids(domain, 4);
fclose(fout);

}
Thanks Micael very much.
But I have another problem. When I execute it ,the result is only one face centroid. And the thread 2 have 100 faces in my example.Why not all face centroids of the thread 2 ? I hope your reply.
zhaoxinyu is offline   Reply With Quote

Old   March 26, 2010, 08:21
Default
  #4
Senior Member
 
Micael
Join Date: Mar 2009
Location: Canada
Posts: 156
Rep Power: 18
Micael is on a distinguished road
You previously wrote:
Print_Thread_Face_Centroids(domain,4);
Print_Thread_Face_Centroids(domain,5);

but I did not copy it correctly and wrote
Print_Thread_Face_Centroids(domain,2);
Print_Thread_Face_Centroids(domain,4);

Can this be the problem?
Micael 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
Dynamic Mesh UDF Qureshi FLUENT 7 March 23, 2017 07:37
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 22:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 21:38
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 04:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 04:01


All times are GMT -4. The time now is 23:43.