Get Node Value
Ansys Fluent store value on cell centroid and face centroid, therefore no value on nodes. Here an unelegant but useful method was introduced. That is getting the value from Fluent postprocessing.
#include "udf.h"
#include "dx.h"
#include "mem.h"
#define ID 3 /* Zone ID (in boundary condition panel) on which node data is to be obtained */
char *what = "pressure"; /* field variable name for which data is to be extracted */
/* For single phase cases, the names of the field variables can be obtained from FLUENT TUI mode.
Example: /display/contours/ => this lists all the field variables that are available. */
/* For multi phase cases, the names of the field variables can be obtained from FLUENT TUI mode.
Example: /display/contours/phase-x => this lists all the field variables (y) that are available.
The filed variable name = "phase-x-y" => x = phase number ( 1, 2 etc.), y = variable name displayed in TUI. */
DEFINE_ADJUST(N_UDMI_get_value,d)
{
face_t f;
Thread *tf;
Node *v;
Node *v_shadow;
int n;
tf = Lookup_Thread(d, WALLID);
Node_Function_Values(d, what);
begin_f_loop(f,tf)
{
f_node_loop(f,tf,n)
{
v=F_NODE(f,tf,n);
v_shadow = F_NODE_SHADOW(f,tf,n);
N_UDMI(v,0) = NODE_VALUE(v);
N_UDMI(v_shadow,0) = N_UDMI(v,0);
//Message("\nx=%g, y=%g, z=%g, N_UDMI=%g",node_x, node_y, node_z, N_UDMI(v,0));
}
}
end_f_loop(f,tf)
}