|
[Sponsors] |
August 25, 2021, 02:21 |
wrong format in writing results to a file
|
#1 |
New Member
radin hosseini
Join Date: Nov 2017
Posts: 6
Rep Power: 8 |
Hi everyone,
I have a weird problem is writing the results from DEFINE_EXECUTE_AT_END to a file. As you can see below, I have written a UDF to calculate the kinetic energy during my simulation and write it in a file at each time step: DEFINE_EXECUTE_AT_END(EK) { Domain *d; real Ek=0.0; Thread *t; cell_t c; d = Get_Domain(3); /* returns phase with ID=3 domain pointer*/ thread_loop_c(t,d) { begin_c_loop(c,t) { Ek += 0.5 * C_R(c,t) * C_VOLUME(c,t) * (pow(C_U(c,t),2) + pow(C_V(c,t),2) + pow(C_W(c,t),2) ); } end_c_loop(c,t) } { FILE *fp; fp = fopen("Ek.dat","a"); fprintf(fp,"%f %f\n",CURRENT_TIME, Ek); fclose(fp); } } The code works file however in my Ek.dat file for each time step I get to rows one with 0 values and the other one is the actual results: 0.000000 0.000000 0.000000 0.000000 0.000100 0.000000 0.000100 0.000005 0.000220 0.000000 0.000220 0.000022 0.000364 0.000000 0.000364 0.000060 0.000537 0.000000 0.000537 0.000132 0.000744 0.000000 0.000744 0.000255 0.000993 0.000000 0.000993 0.000457 0.001292 0.000000 0.001292 0.000777 0.001650 0.000000 0.001650 0.001273 Does anyone have any suggestions to get rid of those zero values at each time step?? Many thanks |
|
August 26, 2021, 02:43 |
|
#2 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,682
Rep Power: 66 |
By chance are you running in parallel on 2 cores?
|
|
August 26, 2021, 02:44 |
|
#3 |
New Member
radin hosseini
Join Date: Nov 2017
Posts: 6
Rep Power: 8 |
That was my first guess. but no this is not a parallel simulation.
|
|
August 26, 2021, 16:21 |
|
#4 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,682
Rep Power: 66 |
Then... are you running a dynamic mesh?
|
|
August 27, 2021, 03:57 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
what fluent version are you using?
starting from v20 fluent starts in parallel by default (even it says 1 core, it uses 1 computational node and host node)
__________________
best regards ****************************** press LIKE if this message was helpful |
|
August 27, 2021, 04:08 |
|
#6 |
New Member
radin hosseini
Join Date: Nov 2017
Posts: 6
Rep Power: 8 |
I see. Well, I am using 2021. So what can I do to avoid this problem?
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] Tabulated thermophysicalProperties library | chriss85 | OpenFOAM Community Contributions | 62 | October 2, 2022 03:50 |
[swak4Foam] swak4foam for OpenFOAM 4.0 | mnikku | OpenFOAM Community Contributions | 80 | May 17, 2022 08:06 |
[foam-extend.org] Problems installing foam-extend-4.0 on openSUSE 42.2 and Ubuntu 16.04 | ordinary | OpenFOAM Installation | 19 | September 3, 2019 18:13 |
[foam-extend.org] problem when installing foam-extend-1.6 | Thomas pan | OpenFOAM Installation | 7 | September 9, 2015 21:53 |
SparceImage v1.7.x Issue on MAC OS X | rcarmi | OpenFOAM Installation | 4 | August 14, 2014 06:42 |