CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

problem with UDF compile

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Bruno Machado

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 25, 2016, 01:07
Default problem with UDF compile
  #1
New Member
 
Tamilnadu
Join Date: Oct 2016
Posts: 7
Rep Power: 9
sridhar palla is on a distinguished road
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?
sridhar palla is offline   Reply With Quote

Old   October 25, 2016, 05:39
Default
  #2
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 12
Bruno Machado is on a distinguished road
have you defined the UDS? If yes, try to assign this value in DEFINE_EXECUTE_AT_END and see if it works.
Bruno Machado is offline   Reply With Quote

Old   October 25, 2016, 07:46
Default
  #3
New Member
 
Tamilnadu
Join Date: Oct 2016
Posts: 7
Rep Power: 9
sridhar palla is on a distinguished road
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.
sridhar palla is offline   Reply With Quote

Old   October 25, 2016, 08:36
Default
  #4
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 12
Bruno Machado is on a distinguished road
Quote:
Originally Posted by sridhar palla View Post
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...
Bruno Machado is offline   Reply With Quote

Old   October 26, 2016, 00:22
Default
  #5
New Member
 
Tamilnadu
Join Date: Oct 2016
Posts: 7
Rep Power: 9
sridhar palla is on a distinguished road
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 ?
sridhar palla is offline   Reply With Quote

Old   October 26, 2016, 04:39
Default
  #6
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 12
Bruno Machado is on a distinguished road
Quote:
Originally Posted by sridhar palla View Post
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
};
Bruno Machado is offline   Reply With Quote

Old   October 26, 2016, 04:42
Default
  #7
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 12
upeksa is on a distinguished road
#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
upeksa is offline   Reply With Quote

Old   November 3, 2016, 06:08
Default error received a fatal signal (Segmentation fault)
  #8
New Member
 
Tamilnadu
Join Date: Oct 2016
Posts: 7
Rep Power: 9
sridhar palla is on a distinguished road
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 ?
sridhar palla is offline   Reply With Quote

Old   November 3, 2016, 07:19
Default
  #9
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 12
Bruno Machado is on a distinguished road
Quote:
Originally Posted by sridhar palla View Post
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");
alinik likes this.
Bruno Machado is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fluent 6.3.26 on Linux does not compile an UDF Entwistle Fluent UDF and Scheme Programming 1 March 4, 2014 14:49
Mesh UDF problem kornetka Fluent UDF and Scheme Programming 4 July 25, 2013 06:54
compile a udf or interpret it? ndabir Fluent UDF and Scheme Programming 1 July 14, 2012 02:49
Help! Compiled UDF problem 4 Wave tank tutorial Shane FLUENT 1 September 3, 2010 02:32
udf compile in parallel system tahereh FLUENT 1 December 9, 2008 09:48


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