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

Particle property UDF

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 20, 2019, 04:36
Default Particle property UDF
  #1
New Member
 
Lesego
Join Date: Mar 2019
Posts: 2
Rep Power: 0
LesegoM is on a distinguished road
Hi guys, I am trying to use a UDF to represent particle scattering but I am getting this error in fluent.

Node 0: Process 1828: Received signal SIGSEGV.

I understand that this means something is wrong with my code. Can I kindly get some assistance. My code is like this:

DEFINE_DPM_PROPERTY(coal_scattering, c, t, tp, T)
{
real mp0;
real mp;
real cf, vf;
real *f;

if (NULLP(tp->pp) ||
NULLP(TP_CELL_THREAD(tp)))
*f = 0.9; /* initial value */

mp0 = TP_INIT_MASS(tp);
mp = TP_MASS(tp);

/* get the original char and volatile fractions
/* and store them in vf and cf:*/
vf = DPM_VOLATILE_FRACTION(tp);
cf = DPM_CHAR_FRACTION(tp);
*f = 0.9*vf - 0.6*(1-vf);

if (!(((mp / mp0) >= 1) ||
((mp / mp0) <= 0)))
{

if ((mp / mp0) < (1 - vf - cf))
{
/* only ash left */
/* vf = cf = 0 */

*f = 0.9*vf - 0.6*(1-vf);
return *f; /*use ash scattering*/
}
else if ((mp / mp0) < (1 - vf))
{
/* only ash and char left */
/* cf = 1 - (1 - vf - cf) / (mp / mp0) */
/* vf = 0 */
*f = 0.9*vf - 0.6*(1-vf);
return *f; /*use char scattering*/
}
else
{
/* volatiles, char, and ash left */
/* cf = cf / (mp / mp0) */
/* vf = 1 - (1 - vf) / (mp / mp0) */
*f = 0.9*vf - 0.6*(1-vf);
return *f; /*use coal scattering*/
}
}
return 0.9;
}
LesegoM is offline   Reply With Quote

Old   March 20, 2019, 21:42
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
I recommend you to use Message macro to find, which line leads to error (analog of printf )

Code:
Message("i'm here 1");
best regards
AlexanderZ is offline   Reply With Quote

Old   March 21, 2019, 04:57
Default
  #3
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
I would be highly suspicious of your use of pointers.
Why do you use *f? As far as I see, you never use it as a pointer.


When you initialize it as "real *f", pointer f points to a random memory address. When you then do "*f = 0.9;", you set the value of that random address to 0.9.


I don't know if you had a reason to use pointers, but my first guess would be that replacing "*f" by "f" would not hurt your program, and might solve the problem.
pakk is offline   Reply With Quote

Old   March 21, 2019, 23:46
Default
  #4
New Member
 
Lesego
Join Date: Mar 2019
Posts: 2
Rep Power: 0
LesegoM is on a distinguished road
Quote:
Originally Posted by pakk View Post
I would be highly suspicious of your use of pointers.
Why do you use *f? As far as I see, you never use it as a pointer.


When you initialize it as "real *f", pointer f points to a random memory address. When you then do "*f = 0.9;", you set the value of that random address to 0.9.


I don't know if you had a reason to use pointers, but my first guess would be that replacing "*f" by "f" would not hurt your program, and might solve the problem.
Thank you, I am very new to UDFs and C coding in general. I had seen the *f on the Fluent UDF manual. I did replace *f with just f and the code is now working. Thank you very much.
LesegoM is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trapped Particle coordinates UDF Saidul FLUENT 0 December 8, 2014 18:07
Particle cooling rate - UDF papteo Fluent UDF and Scheme Programming 9 January 29, 2012 09:28
Problem with a simple UDF to calculate cell-averaged particle values kmayank FLUENT 1 January 18, 2011 01:40
URGENT custom property for UDF Sandilya Garimella FLUENT 0 May 19, 2008 12:35
udf about particle concentration--who can help me? zhaoh FLUENT 1 January 17, 2007 11:46


All times are GMT -4. The time now is 10:01.