Face temperatures F_T(face,thread) are not available in UDF for interior faces. If required, it should be reconstructed.

The UDF example reconstructs the face value based on cell temperature and cell temperature gradient stored on each side of the face.
This value is copied in UDM-0 in each cell located on each side of the face.
The temperature profile on interior-12 is also written in a file.

UDF example:

#include "udf.h"
# include <stdio.h>
#define INTERIOR_ID 12
#define filename "temperature_int12.out"

DEFINE_ON_DEMAND(face_temperature)
{

/* variable declarations*/
Domain *domain=Get_Domain(1);
FILE *temp_file;
real x, y, z;
real x0[ND_ND],x1[ND_ND],xf[ND_ND];
real T0,T1,T_surface;
real ds0[ND_ND],ds1[ND_ND];
Thread *tc0, *tc1;
face_t f;
cell_t c0,c1;

/* lookup face thread of interior-12 */
Thread *tf = Lookup_Thread(domain, INTERIOR_ID);

/* Alloc_Storage_Vars memory for reconstructed gradient(RG)
and gradient(G) NOTE: must get RG to get G
T_derivatives computes RG and G
Free_Storage_Vars frees memory that was used for RG */
Alloc_Storage_Vars(domain, SV_T_RG, SV_T_G, SV_NULL);
T_derivatives(domain);
Free_Storage_Vars(domain, SV_T_RG, SV_NULL);

temp_file = fopen(filename, "w");
fprintf(temp_file,"(%10s %10s %10s %10s)n",
"X","Y","Z","T");

begin_f_loop(f, tf)
{
/* Definition */
/* get index of cells next to INTERIOR_ID */
c0=F_C0(f,tf);
c1=F_C1(f,tf);
/* get index of thread next to INTERIOR_ID */
tc0=THREAD_T0(tf);
tc1=THREAD_T1(tf);

/* get cell and face centroids */
C_CENTROID(x0,c0,tc0);
C_CENTROID(x1,c1,tc1);
F_CENTROID(xf,f,tf);

/* Operations */

/* NV_VV is a macro for vectorA = vectorB +- vectorC
NV_VV(A, =, B, +or-, C) returns vectorA */
/* ds0 is coordinate distance between face and cell center */

NV_VV(ds0,=,xf,-,x0);
NV_VV(ds1,=,xf,-,x1);

/* Calcul */

/*C_T_G gets cell temperature gradient */

T0 = C_T(c0,tc0) + NV_DOT(C_T_G(c0,tc0),ds0);
T1 = C_T(c1,tc1) + NV_DOT(C_T_G(c1,tc1),ds1);
T_surface = (T0+T1)/2.;
C_UDMI(c0,tc0,0)=C_UDMI(c1,tc1,0)=T_surface;
/* print to file in table format x y z T_surface
where x, y, and z are face coordinates*/
fprintf(temp_file, "%10.3e %10.3e %10.3e %10.3en", xf[0], xf[1], xf[2], T_surface);
}
end_f_loop(f, tf)
fclose(temp_file);

Free_Storage_Vars(domain, SV_T_G, SV_NULL);
}





Show Form
No comments yet. Be the first to add a comment!