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

wrong format in writing results to a file

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 25, 2021, 02:21
Default wrong format in writing results to a file
  #1
New Member
 
radin hosseini
Join Date: Nov 2017
Posts: 6
Rep Power: 8
radin_85 is on a distinguished road
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
radin_85 is offline   Reply With Quote

Old   August 26, 2021, 02:43
Default
  #2
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,682
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
By chance are you running in parallel on 2 cores?
LuckyTran is offline   Reply With Quote

Old   August 26, 2021, 02:44
Default
  #3
New Member
 
radin hosseini
Join Date: Nov 2017
Posts: 6
Rep Power: 8
radin_85 is on a distinguished road
That was my first guess. but no this is not a parallel simulation.
radin_85 is offline   Reply With Quote

Old   August 26, 2021, 16:21
Default
  #4
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,682
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
Then... are you running a dynamic mesh?
LuckyTran is offline   Reply With Quote

Old   August 27, 2021, 03:57
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
AlexanderZ is offline   Reply With Quote

Old   August 27, 2021, 04:08
Default
  #6
New Member
 
radin hosseini
Join Date: Nov 2017
Posts: 6
Rep Power: 8
radin_85 is on a distinguished road
I see. Well, I am using 2021. So what can I do to avoid this problem?
radin_85 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
[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


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