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 correct udf (https://www.cfd-online.com/Forums/fluent-udf/222058-help-correct-udf.html)

smilingwl November 10, 2019 03:37

Help correct udf
 
I want to find the interface of the VOF model.
My code as follows:
DEFINE_EXECUTE_AT_END(climbing_high)
{ real cymax = 0.0;
cell_t c;
real z[ND_ND];
Domain *subdomain= Get_Domain(3);
Thread *t;
FILE *fout1;
thread_loop_c(t,subdomain)
{
begin_c_loop(c,t)
{
if (C_VOF(c,t) ==0.9)
{
C_CENTROID(z,c,t);
if (cymax < z[1])
cymax = z[1];
}
}
end_c_loop(c, t)
}
fout1 = fopen("Vertex on Y axis.txt", "a");
fprintf(fout1, "%g,%g\n", CURRENT_TIME, cymax);
fclose(fout1);
Message("\n Vertex on Y axis = %g\n", cymax);
The result as follow:
Vertex on Y axis = 0
I don't know what's wrong.Please help me.

AlexanderZ November 10, 2019 23:21

if (C_VOF(c,t) ==0.9) statement is not efficient, I believe you will never have exactly 0.9 in any cell

that's why your cymax is always 0

on the other hand, you are trying to access cymax from outside of the loop -> so you will have only 1 (last) value, which is 0

smilingwl November 11, 2019 03:01

Dear AlexanderZ:
Thank you for your answer and your help again.I am so luck to get your help.
Best wishes!
WangLu


All times are GMT -4. The time now is 12:47.