|
[Sponsors] |
March 20, 2019, 05:36 |
Particle property UDF
|
#1 |
New Member
Lesego
Join Date: Mar 2019
Posts: 2
Rep Power: 0 |
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; } |
|
March 20, 2019, 22:42 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
I recommend you to use Message macro to find, which line leads to error (analog of printf )
Code:
Message("i'm here 1"); |
|
March 21, 2019, 05:57 |
|
#3 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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. |
|
March 22, 2019, 00:46 |
|
#4 | |
New Member
Lesego
Join Date: Mar 2019
Posts: 2
Rep Power: 0 |
Quote:
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Trapped Particle coordinates UDF | Saidul | FLUENT | 0 | December 8, 2014 19:07 |
Particle cooling rate - UDF | papteo | Fluent UDF and Scheme Programming | 9 | January 29, 2012 10:28 |
Problem with a simple UDF to calculate cell-averaged particle values | kmayank | FLUENT | 1 | January 18, 2011 02:40 |
URGENT custom property for UDF | Sandilya Garimella | FLUENT | 0 | May 19, 2008 13:35 |
udf about particle concentration--who can help me? | zhaoh | FLUENT | 1 | January 17, 2007 12:46 |