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/)
-   -   Urgent UDF Problem .... (https://www.cfd-online.com/Forums/fluent-udf/118499-urgent-udf-problem.html)

angelicapeygo May 28, 2013 19:40

Urgent UDF Problem ....
 
Friends,
I have a proble with my UDF. There is no problem about compilation and interpreting but I can not apply my udf to the boundaries. I get error message:

Error: cx-set-real-entry: wta[2] (float)
Error Object : ((constant .1) (profile """""")

Could you please help me about the case?
my UDF is like that:




#include "udf.h"
#define Tm 938
Domain *d;
DEFINE_PROFILE(wall_temp, thread, nv)
{
real T2solid=0.;
real T2liquid=0.;
real temp=0.;
real tmax=0.;
real tmin=0.;
real y=0.;
Thread *t;
cell_t c;
/* Loop over all cell threads in the domain */
thread_loop_c(t,d)
{

/* Compute max, min, volume-averaged temperature */

/* Loop over all cells */
begin_c_loop(c,t)
{
temp = C_T(c,t); /* get cell temperature */

if (temp < tmin || tmin == 0.) tmin = temp;
if (temp > tmax || tmax == 0.) tmax = temp;


}
end_c_loop(c,t)
printf("\n Tmin = %g Tmax = %g",tmin,tmax);
T2solid=Tm+100.0*y ;
T2liquid=Tm+40.0*y ;
begin_c_loop(c,t)
{
temp = C_T(c,t);
}
end_c_loop(c,t)
}
}

thanks alot....

blackmask May 28, 2013 21:42

Why do you use DEFINE_PROFILE(name, thread, nv) if your functions body does not involve 'thread' at all?

angelicapeygo May 29, 2013 07:11

what do you advise me to do? I am new with the UDFs ..

blackmask May 29, 2013 07:16

It depends, DEFINE_ON_DEMAND or DEFINE_EXECUTE_AT_END could be an option.

angelicapeygo May 29, 2013 07:29

I changed it to DEFINE_ON_DEMAND but the result is same. what can be the other reason :S

blackmask May 29, 2013 07:36

You Domain pointer are not initialized. Add a line
d = Get_Domain(1);

angelicapeygo May 29, 2013 07:49

I realized it and add it but nothing changed.
/************************************************** *********************
vprofile.c
UDF for specifying steady-state temperature profile boundary condition
************************************************** **********************/
#include "udf.h"
#define Tm 938
Domain *d;
DEFINE_ON_DEMAND(wall_temp)
{
real T2solid=0.;
real T2liquid=0.;
real temp=0.;
real tmax=0.;
real tmin=0.;
real y=0.;
Thread *t;
cell_t c;
d = Get_Domain(1); /* Get the domain using Fluent utility */
/* Loop over all cell threads in the domain */
thread_loop_c(t,d)
{

/* Compute max, min, volume-averaged temperature */

/* Loop over all cells */
begin_c_loop(c,t)
{
temp = C_T(c,t); /* get cell temperature */

if (temp < tmin || tmin == 0.) tmin = temp;
if (temp > tmax || tmax == 0.) tmax = temp;


}
end_c_loop(c,t)
printf("\n Tmin = %g Tmax = %g",tmin,tmax);
T2solid=Tm+100.0*y ;
T2liquid=Tm+40.0*y ;
begin_c_loop(c,t)
{
temp = C_T(c,t);
}
end_c_loop(c,t)
}
}

blackmask May 29, 2013 07:53

Replace
Code:

printf
with
Code:

Message0

angelicapeygo May 29, 2013 08:01

it says:
CX_message not found. Do you know the reason?
thanks alot.

blackmask May 29, 2013 08:06

Then simply comment out that line and try again. If the error still persist, then I suggest you save you case, restart FLUENT and reread the case file.

angelicapeygo May 29, 2013 08:11

it still does not work ..
do you think the other parts of my UDF is correct?
thanks alot.

blackmask May 29, 2013 10:27

I think the UDF is fine.

JimKnopf May 29, 2013 10:29

What is the current error?

Printing is done via:
Code:

double var = 0.;
Message("text %g",var);

found one:

Code:

#define TM 938
is not really the same then defining a global variable. If you really sure that you what to define a global constant you should use:
Code:

static const double var = 4.5;
But still remind that global variables are bad and evil

Greetz
Jim


All times are GMT -4. The time now is 04:15.