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/)
-   -   problem with UDF compile (https://www.cfd-online.com/Forums/fluent-udf/179185-problem-udf-compile.html)

sridhar palla October 25, 2016 01:07

problem with UDF compile
 
Hello everyone,

I'm trying to compile UDF in the fluent but at the time of compiling it is showing the following error to each UDF at assigning the function everytime.

UDF 1 for n = no * exp(-(R*T/(Alpha+(beta*T))^2)*ln(p_o/p)^2)

#include "udf.h"

DEFINE_ADJUST(ads,domain)
{
Thread *t;
real E,A,P;
cell_t c;

thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
real tem = C_T(c,t);

P=C_P(c,t)+RP_Get_Real("operating-pressure");
E=3080+18.9*tem;
A=8.314*tem*log(1.47E9/P);

C_UDSI(c, t, ads) = 71.6*(exp(-((A*A) / (E*E)))); error is in this line

}
end_c_loop (c,t)
}
}

error in compiling this file is
error C2296: '*' : illegal, left operand has type 'void (*)(Domain *)'

Can anyone please help me with this?

Bruno Machado October 25, 2016 05:39

have you defined the UDS? If yes, try to assign this value in DEFINE_EXECUTE_AT_END and see if it works.

sridhar palla October 25, 2016 07:46

i don't understand the defining UDS here,
ads is the function name i'm using to define 'n' and in C_UDSI macro im assigning it.
And how to assign the value in DEFINE_EXECUTE_AT_END ?

Thank you.

Bruno Machado October 25, 2016 08:36

Quote:

Originally Posted by sridhar palla (Post 622887)
i don't understand the defining UDS here,
ads is the function name i'm using to define 'n' and in C_UDSI macro im assigning it.
And how to assign the value in DEFINE_EXECUTE_AT_END ?

Thank you.

ads is the name of the scalar you are defining, but you have not declared it. you need to declare the number/name of your scalars.

All the information I am writing is in the manual...

sridhar palla October 26, 2016 00:22

This is the complete UDF i'm doing for mass source term
it is (mass source term) Sm = X* d(n,t)
the first code i posted for n only
in this udf i'm adding to it calls the n every calculating Sm here

#include "udf.h"
DEFINE_ADJUST(ads,domain)
{
Thread *t;
real E,A,P,ads;
cell_t c;

thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
real tem = C_T(c,t);

P=C_P(c,t)+RP_Get_Real("operating-pressure");

E=3080+18.9*tem;

A=8.314*tem*log(1.47E9/P);

C_UDSI(c, t, ads) = 71.6*(exp(-((A*A) / (E*E)))); "error C2296 in this line"

}
end_c_loop (c,t)
}
}


DEFINE_ADJUST(q_ads,domain)
{
Thread *t;
cell_t c;
real dt,q_ads;
thread_loop_c(t,domain)
begin_c_loop (c,t)
{

dt=RP_Get_Real("physical-time-step");

C_UDSI(c,t,q_ads)=C_UDSI_M1(c,t,q_ads)+0.15*dt*(C_ UDSI_M1(c,t,ads)-C_UDSI_M1(c,t,q_ads)); "error C2296 in this line"
}
end_c_loop(c,t)
}

DEFINE_ADJUST(d_ads, domain)
{
Thread *t;
cell_t c;
real d_ads;
thread_loop_c(t, domain)
{
begin_c_loop(c, t)
{


C_UDSI(c, t, d_ads) = -0.532224*0.15*(C_UDSI(c, t, ads) - C_UDSI(c, t, q_ads)); "error C2296 in this line"
}
end_c_loop(c, t)
}
}

DEFINE_SOURCE(m_src,c,t,dS,eqn)
{

dS[eqn]=0.0;


return C_UDSI_M1(c, t, d_ads); "error C2296 in this line"

}

error in compiling this file is
error C2296: '*' : illegal, left operand has type 'void (*)(Domain *)' this is coming in each time assigning functions.

Can you please check this once ?

Bruno Machado October 26, 2016 04:39

Quote:

Originally Posted by sridhar palla (Post 622971)
This is the complete UDF i'm doing for mass source term
it is (mass source term) Sm = X* d(n,t)
the first code i posted for n only
in this udf i'm adding to it calls the n every calculating Sm here

#include "udf.h"
DEFINE_ADJUST(ads,domain)
{
Thread *t;
real E,A,P,ads;
cell_t c;

thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
real tem = C_T(c,t);

P=C_P(c,t)+RP_Get_Real("operating-pressure");

E=3080+18.9*tem;

A=8.314*tem*log(1.47E9/P);

C_UDSI(c, t, ads) = 71.6*(exp(-((A*A) / (E*E)))); "error C2296 in this line"

}
end_c_loop (c,t)
}
}


DEFINE_ADJUST(q_ads,domain)
{
Thread *t;
cell_t c;
real dt,q_ads;
thread_loop_c(t,domain)
begin_c_loop (c,t)
{

dt=RP_Get_Real("physical-time-step");

C_UDSI(c,t,q_ads)=C_UDSI_M1(c,t,q_ads)+0.15*dt*(C_ UDSI_M1(c,t,ads)-C_UDSI_M1(c,t,q_ads)); "error C2296 in this line"
}
end_c_loop(c,t)
}

DEFINE_ADJUST(d_ads, domain)
{
Thread *t;
cell_t c;
real d_ads;
thread_loop_c(t, domain)
{
begin_c_loop(c, t)
{


C_UDSI(c, t, d_ads) = -0.532224*0.15*(C_UDSI(c, t, ads) - C_UDSI(c, t, q_ads)); "error C2296 in this line"
}
end_c_loop(c, t)
}
}

DEFINE_SOURCE(m_src,c,t,dS,eqn)
{

dS[eqn]=0.0;


return C_UDSI_M1(c, t, d_ads); "error C2296 in this line"

}

error in compiling this file is
error C2296: '*' : illegal, left operand has type 'void (*)(Domain *)' this is coming in each time assigning functions.

Can you please check this once ?

As I mentioned before, you need to define ads and q_ads. Fluent defines the name of the UDS as 0,1,2... If you do not tell fluent that ads and q_ads are your UDS, he wont be able to know.

add this at the begging of you code

enum /* UDSs */
{
ads,
q_ads,
NUM_UDS
};

upeksa October 26, 2016 04:42

#include "udf.h"

enum
{
ads,
q_ads,
d_ads,
};

DEFINE_ADJUST(define_ads,domain)
{
Thread *t;
real E,A,P;
cell_t c;
real tem;

thread_loop_c(t,domain)
{
begin_c_loop(c,t)
{
tem = C_T(c,t);

P=C_P(c,t)+RP_Get_Real("operating-pressure");

E=3080.0+18.9*tem;

A=8.314*tem*log(1.47e9/P);

C_UDSI(c,t,0) = 71.6*(exp(-((A*A) / (E*E))));

}
end_c_loop(c,t)
}
}



DEFINE_ADJUST(define_q_ads,domain)
{
Thread *t;
cell_t c;
real dt;

thread_loop_c(t,domain)
{
begin_c_loop(c,t)
{
dt=RP_Get_Real("physical-time-step");
C_UDSI(c,t,q_ads)=C_UDSI_M1(c,t,q_ads)+0.15*dt*(C_ UDSI_M1(c,t,ads)-C_UDSI_M1(c,t,q_ads));
}
end_c_loop(c,t)
}
}

DEFINE_ADJUST(define_d_ads, domain)
{
Thread *t;
cell_t c;

thread_loop_c(t, domain)
{
begin_c_loop(c,t)
{
C_UDSI(c, t, d_ads) = -0.532224*0.15*(C_UDSI(c, t, ads) - C_UDSI(c, t, q_ads));
}
end_c_loop(c,t)
}
}


DEFINE_SOURCE(m_src,c,t,dS,eqn)
{

dS[eqn]=0.0;

return C_UDSI_M1(c, t, d_ads);
}


Here is your code, it compiles now. You had many issues, for example ads, q_ads and d_ads must be integer numbers, not real numbers. Moreover, they cannot be at the same time the name of the macro itself (I have change the name of the macro "define_ads" and so on.

Check the code, since I don't know what do you want to do and I might have made some modifications that don't work in your case.

Regards

sridhar palla November 3, 2016 06:08

error received a fatal signal (Segmentation fault)
 
Thank you for the reply now my UDF is compiling but while intializing the model showing below error

" received a fatal signal (Segmentation fault)"

Can you please help me with this what might be the problem ?

Bruno Machado November 3, 2016 07:19

Quote:

Originally Posted by sridhar palla (Post 623959)
Thank you for the reply now my UDF is compiling but while intializing the model showing below error

" received a fatal signal (Segmentation fault)"

Can you please help me with this what might be the problem ?

this usually is associated with the fact fluent is trying to obtain something is not available. Check is all your variables are properly assigned.

You can add messages to your code, so you will be able to see where it stops. use something like

Message("1");
.
YOUR CODE
.
Message("2");


All times are GMT -4. The time now is 23:02.