CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Urgent UDF Problem .... (http://www.cfd-online.com/Forums/fluent-udf/118499-urgent-udf-problem.html)

 angelicapeygo May 28, 2013 18: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 """""")

my UDF is like that:

#include "udf.h"
#define Tm 938
Domain *d;
{
real T2solid=0.;
real T2liquid=0.;
real temp=0.;
real tmax=0.;
real tmin=0.;
real y=0.;
cell_t c;
/* Loop over all cell threads in the domain */
{

/* 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....

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

 angelicapeygo May 29, 2013 06:11

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

It depends, DEFINE_ON_DEMAND or DEFINE_EXECUTE_AT_END could be an option.

 angelicapeygo May 29, 2013 06:29

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

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

 angelicapeygo May 29, 2013 06: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.;
cell_t c;
d = Get_Domain(1); /* Get the domain using Fluent utility */
/* Loop over all cell threads in the domain */
{

/* 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)
}
}

Replace
Code:

`printf`
with
Code:

`Message0`

 angelicapeygo May 29, 2013 07:01

it says:
thanks alot.

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 07:11

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

I think the UDF is fine.

 JimKnopf May 29, 2013 09: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 16:06.