CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Is my UDF correct (https://www.cfd-online.com/Forums/fluent/83605-my-udf-correct.html)

 ehooi January 5, 2011 03:56

Is my UDF correct

Hi all,
Basically, I am trying to simulate a flow tank where the outflow is pumped back into the tank via eight inlets (front1,front2,back1,back2,right1,right2,left1,lef t2). I am trying to write a UDF such that the average temperature of the outflow is the same as the temperature of each of the eight inlets. My UDF (modified from an existing code) is listed:

#include "udf.h"
/* Mean temperature at outlet is calculated */
{
#if !RP_HOST /* either serial or compute node process is involved */
face_t f;
real sum_temp=0.0;
int nfaces=0, i;
int ID_out = 67; //out
int ID_back1 = 65; //back1
int ID_back2 = 66; //back2
int ID_front1 = 59; //front1
int ID_front2 = 60; //front2
int ID_left1 = 63; //left1
int ID_left2 = 64; //left2
int ID_right1 = 61; //right1
int ID_right2 = 62; //right2
/* Determination of zone IDs */

/* Calculation of average outflow temperature and sending to other nodes. */
/* The thread on which the average temperature is calculated is on node zero. */

if(I_AM_NODE_ZERO_P)
{
{
nfaces = nfaces + 1;
}

sum_temp = sum_temp/nfaces;

/* Message("Node %d : Average exit temperature = %f\n", myid, sum_temp); */
compute_node_loop_not_zero(i)

{
PRF_CSEND_DOUBLE(i, &sum_temp, 1, myid);
}
}
/* Reception of average temperature from node zero */
if(! I_AM_NODE_ZERO_P)
{
PRF_CRECV_DOUBLE(0, &sum_temp, 1, 0);
/* Message("Node %d : Average exit temperature = %f\n", myid, sum_temp); */
}
/* User defined memory of thread_back1 are filled with sum_temp */
{
}

/* User defined memory of thread_back2 are filled with sum_temp */
{
}

/* User defined memory of thread_front1 are filled with sum_temp */
{
}

/* User defined memory of thread_front2 are filled with sum_temp */
{
}

/* User defined memory of thread_left1 are filled with sum_temp */
{
}

/* User defined memory of thread_left2 are filled with sum_temp */
{
}

/* User defined memory of thread_right1 are filled with sum_temp */
{
}

/* User defined memory of thread_right2 are filled with sum_temp */
{
}
#endif
}

/* Boundary conditions are filled from user defined memory locations */
DEFINE_PROFILE(back1,t,i)
{
#if !RP_HOST
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = F_UDMI(f,t,1);
}
end_f_loop(f,t)
#endif
}

DEFINE_PROFILE(back2,t,i)
{
#if !RP_HOST
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = F_UDMI(f,t,2);
}
end_f_loop(f,t)
#endif
}

DEFINE_PROFILE(front1,t,i)
{
#if !RP_HOST
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = F_UDMI(f,t,3);
}
end_f_loop(f,t)
#endif
}

DEFINE_PROFILE(front2,t,i)
{
#if !RP_HOST
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = F_UDMI(f,t,4);
}
end_f_loop(f,t)
#endif
}

DEFINE_PROFILE(left1,t,i)
{
#if !RP_HOST
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = F_UDMI(f,t,5);
}
end_f_loop(f,t)
#endif
}

DEFINE_PROFILE(left2,t,i)
{
#if !RP_HOST
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = F_UDMI(f,t,6);
}
end_f_loop(f,t)
#endif
}

DEFINE_PROFILE(right1,t,i)
{
#if !RP_HOST
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = F_UDMI(f,t,7);
}
end_f_loop(f,t)
#endif
}

DEFINE_PROFILE(right2,t,i)
{
#if !RP_HOST
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = F_UDMI(f,t,8);
}
end_f_loop(f,t)
#endif
}

I tried compiling this but I have not been able to get the compilation successful message mentioned in the fluent manual. I am running parallel in local machine (Win64) and not in a cluster of machines. Also, I am using FLUENT v12.

It may be possible that the error is due to the link between Microsoft Visual Studio 2008 and FLUENT but I want to make sure the code is correct before I go reinstalling Visual Studio.

If anyone can help, I will be very grateful.

Thank you.

EH

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