|
[Sponsors] |
January 11, 2012, 14:04 |
Averaged C_FMEAN UDF
|
#1 |
New Member
Jenny
Join Date: Jan 2012
Posts: 11
Rep Power: 14 |
Hi Everyone,
I've written a UDF code to time-average the mean mixture fraction values computed in FLUENT after each iteration. However, I received "SEMENTATION VIOLATION" error. I think it is becuase of C_FMEAN. When I use other macro, the averaging code works fine. thread_loop_c(ct,d) { begin_c_loop(c,ct) { C_UDMI(c,ct,0) = C_FMEAN(c,ct)+C_UDMI(c,ct,0); C_UDMI(c,ct,1) = C_UDMI(c,ct,0)/count ; } end_c_loop(c,ct) } If anyone knows the solution to this problem, please kindly advise me. I will really appreciate it. Thank you very much. Jenny |
|
January 14, 2012, 21:48 |
|
#2 |
Senior Member
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16 |
Can you post the rest of the code? You could always test the code by replacing C_FMEAN with a constant (say, 0.0) to see if that's causing the error.
Do you have the premixed combustion model turned on? ComputerGuy |
|
January 16, 2012, 18:24 |
Averaged C_FMEAN UDF
|
#3 |
New Member
Jenny
Join Date: Jan 2012
Posts: 11
Rep Power: 14 |
Dear ComputerGuy,
Thank you for your reply. The premixed combustion model wasn't turned on. I used the non-premixed model. I tried replacing C_FMEAN with a constant as you suggested and the code worked perfectly. Thanks again, Jenny Here's my code: #include "udf.h" int count = 0; real start_avg = 0.001; DEFINE_EXECUTE_AT_END(avg) { if(CURRENT_TIME > start_avg) { Domain *d; Thread *ct; cell_t c; d=Get_Domain(1); count = count+1; thread_loop_c(ct,d) { begin_c_loop(c,ct) { C_UDMI(c,ct,0) = C_FMEAN+C_UDMI(c,ct,0); C_UDMI(c,ct,1) = C_UDMI(c,ct,udm_offset)/count ; } end_c_loop(c,ct) } } } |
|
January 17, 2012, 00:11 |
|
#4 | |
Senior Member
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16 |
The code should be something similar to:
Code:
#include "udf.h" #include "sg_mem.h" int count = 0; real start_avg = 0.001; DEFINE_EXECUTE_AT_END(avg) { if(CURRENT_TIME > start_avg) { Domain *d; Thread *ct; cell_t c; d=Get_Domain(1); count = count+1; thread_loop_c(ct,d) { begin_c_loop(c,ct) { C_UDMI(c,ct,0) = C_FMEAN(c,ct)+C_UDMI(c,ct,0); C_UDMI(c,ct,1) = C_UDMI(c,ct,udm_offset)/count ; } end_c_loop(c,ct) } } } Let me know ComputerGuy Quote:
|
||
January 17, 2012, 11:48 |
Averaged C_FMEAN UDF
|
#5 |
New Member
Jenny
Join Date: Jan 2012
Posts: 11
Rep Power: 14 |
Dear ComputerGuy,
I'm sorry I made a mistake. I did use C_FMEAN(c,ct) in the code and replace udm_offset with 0. I have added include "sg_mem.h" as you recommended but still FLUENT gave the same SEGMENTATION VIOLATION error. I saw in 1 forum, C_FMEAN was used like this fmean = C_FMEAN(c,ct); a = fmean + b; So, I tried this in my code too but it didn't work either. Now, I'm trying to just print the C_FMEAN values and see if it reads the values alone. Please kindly advise if you know what is wrong. Thank you again for your help. Jenny |
|
January 17, 2012, 14:50 |
|
#6 | |
Senior Member
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16 |
Try the code below...The user-defined memory is valid everywhere, but the C_FMEAN is likely to be only valid if the cell thread is a fluid thread.
Code:
#include "udf.h" #include "sg_mem.h" int count = 0; real start_avg = 0.001; DEFINE_EXECUTE_AT_END(avg) { if(CURRENT_TIME > start_avg) { Domain *d; Thread *ct; cell_t c; d=Get_Domain(1); count = count+1; thread_loop_c(ct,d) { if (FLUID_THREAD_P(ct)) { begin_c_loop(c,ct) { C_UDMI(c,ct,0) = C_FMEAN(c,ct)+C_UDMI(c,ct,0); C_UDMI(c,ct,1) = C_UDMI(c,ct,udm_offset)/count ; } end_c_loop(c,ct) } } } } ComputerGuy Quote:
|
||
January 18, 2012, 07:45 |
Averaged C_FMEAN UDF
|
#7 |
New Member
Jenny
Join Date: Jan 2012
Posts: 11
Rep Power: 14 |
Dear ComputerGuy,
You are right. The code works very well now with no SEGMENTATION VIOLATION error. I have been struggling with this problem for 2 months and now I am very happy. Thank you very much, Jenny |
|
January 18, 2012, 12:46 |
|
#8 |
Senior Member
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16 |
||
January 14, 2015, 22:20 |
|
#9 |
New Member
Howard Zhang
Join Date: Oct 2014
Posts: 12
Rep Power: 12 |
could you tell me some usefulness about the head file "sg_mem.h", many thanks!
|
|
Tags |
c_fmean, fluent error, mean mixture fraction, segmentation violation, udf error |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dynamic Mesh UDF | Qureshi | FLUENT | 7 | March 23, 2017 08:37 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 23:14 |
How to add a UDF to a compiled UDF library | kim | FLUENT | 3 | October 26, 2011 22:38 |
UDF...UDF...UDF...UDF | Luc SEMINEL | FLUENT | 0 | November 25, 2002 05:03 |
UDF, UDF, UDF, UDF | Luc SEMINEL | Main CFD Forum | 0 | November 25, 2002 05:01 |