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/)
-   -   Node UDF (https://www.cfd-online.com/Forums/fluent-udf/85339-node-udf.html)

EdiVaD February 23, 2011 10:40

Node UDF
 
Hi to everybody,

i want to know if it possible to read nodes coordinate once a time.

this is part of my udf code:
----------------------------------------------------------------------------------------------------------------
fprintf(fout,"thread id %d\n", id);
begin_f_loop(f,t)
{
f_node_loop(f,t,n)
{
v = F_NODE(f,t,n);
pos_x = NODE_X(v);
pos_y = NODE_Y(v);
fprintf(fout, "f%d %g %g\n", v, pos_x, pos_y);
}
}
end_f_loop(f,t)
fprintf(fout, "\n");
----------------------------------------------------------------------------------------------------------------
in this way i have obtained the same nodes more than one time, due to the nodes on the same faces. Can somebody help me?

Thank's in advance

gearboy February 23, 2011 20:04

Quote:

Originally Posted by EdiVaD (Post 296578)
Hi to everybody,

i want to know if it possible to read nodes coordinate once a time.

this is part of my udf code:
----------------------------------------------------------------------------------------------------------------
fprintf(fout,"thread id %d\n", id);
begin_f_loop(f,t)
{
f_node_loop(f,t,n)
{
v = F_NODE(f,t,n);
pos_x = NODE_X(v);
pos_y = NODE_Y(v);
fprintf(fout, "f%d %g %g\n", v, pos_x, pos_y);
}
}
end_f_loop(f,t)
fprintf(fout, "\n");
----------------------------------------------------------------------------------------------------------------
in this way i have obtained the same nodes more than one time, due to the nodes on the same faces. Can somebody help me?

Thank's in advance


/* Initalize all node marks on the thread to 0 */
begin_f_loop(f, t)
{
f_node_loop(f, t, n)
{
v=F_NODE(f,t,n);
NODE_MARK(v) = 0;
}
}
end_f_loop(f, t);

begin_f_loop(f, t)
{
f_node_loop(f, t, n)
{
v = F_NODE(f,t,n);
pos_x = NODE_X(v);
pos_y = NODE_Y(v);
if(NODE_MARK(v) == 0) /* if not already visited */
fprintf(fout, "f%d %g %g\n", v, pos_x, pos_y);

NODE_MARK(v) = 1;
}
}
end_f_loop(f, t);
fclose(fout);

EdiVaD February 24, 2011 04:43

Thank you GearBoy ,

it works fine.

I want to underline that to use the macro NODE_MARK(), the udf must be compiled and not interpreted...

where i can find some reference on this and other similar macro?
in the UDF ug there aren't info...

trantoan2008 September 20, 2012 09:13

Quote:

Originally Posted by gearboy (Post 296635)
/* Initalize all node marks on the thread to 0 */
begin_f_loop(f, t)
{
f_node_loop(f, t, n)
{
v=F_NODE(f,t,n);
NODE_MARK(v) = 0;
}
}
end_f_loop(f, t);

begin_f_loop(f, t)
{
f_node_loop(f, t, n)
{
v = F_NODE(f,t,n);
pos_x = NODE_X(v);
pos_y = NODE_Y(v);
if(NODE_MARK(v) == 0) /* if not already visited */
fprintf(fout, "f%d %g %g\n", v, pos_x, pos_y);

NODE_MARK(v) = 1;
}
}
end_f_loop(f, t);
fclose(fout);



Hi GearBoy!

I followed your code as shown as above. It works very well. I succeeded to output node data. However, I faced some problem. Could you help me?

I tested DEFINE_CG_MOTION macro with a rotation of a box about x-axis according to "cos(x)" function . I exported several node in this box. When I checked output data from selected node, I compare it to my "cos(x)" function value. I realized that there are slightly different between them.

I really appreciate your help.

Best regards


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