CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   HELP:Fluent UDF (https://www.cfd-online.com/Forums/fluent-udf/74073-help-fluent-udf.html)

zhaoxinyu March 23, 2010 22:02

HELP:Fluent UDF
 
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);
}

Micael March 24, 2010 14:14

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);
}

zhaoxinyu March 25, 2010 21:20

Quote:

Originally Posted by Micael (Post 251498)
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.

Micael March 26, 2010 09:21

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?


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