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

UDF print results into .dat file more than once per time step? how to fix it?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 26, 2019, 10:38
Default UDF print results into .dat file more than once per time step? how to fix it?
  #1
New Member
 
xuwenhua
Join Date: Mar 2019
Posts: 4
Rep Power: 7
xuwenhua625 is on a distinguished road
fluent 19.2 , UDF in parallel
Using Compute_Force_And_Moment micro to calculate the force of a flapping foil, then printing the results into a .dat file. I found that the UDF output the same results into the .dat file 1~3 times per time step, so how can I fix the problem to print the same results in the .dat file only once in every timestep?

Thanks!
xuwenhua625 is offline   Reply With Quote

Old   April 26, 2019, 21:18
Default Another solution
  #2
New Member
 
xuwenhua
Join Date: Mar 2019
Posts: 4
Rep Power: 7
xuwenhua625 is on a distinguished road
I find MATLAB ‘unique’ function can solve the problem~~
xuwenhua625 is offline   Reply With Quote

Old   April 27, 2019, 04:40
Default
  #3
New Member
 
Join Date: Nov 2018
Posts: 14
Rep Power: 7
pianaCFD is on a distinguished road
I don't understand the problem. Do you mean that you have more iteration per time step and you want to print the results just for the last iteration of each time step? In this case you can use DEFINE_EXECUTE_AT_END macro and print from there.



If the problem is that you are working in parallel and fluent is printing the results for each node then you can try to add something like this:


FILE *try;
#ifPARALLEL
if(I_AM_NODE_ZERO_P)
#endif
{
try=fopen("youfile.dat","w+");
fprintf(try, ....... );
fclose(try);
}
pianaCFD is offline   Reply With Quote

Old   April 27, 2019, 21:32
Default
  #4
New Member
 
xuwenhua
Join Date: Mar 2019
Posts: 4
Rep Power: 7
xuwenhua625 is on a distinguished road
Quote:
Originally Posted by pianaCFD View Post
I don't understand the problem. Do you mean that you have more iteration per time step and you want to print the results just for the last iteration of each time step? In this case you can use DEFINE_EXECUTE_AT_END macro and print from there.



If the problem is that you are working in parallel and fluent is printing the results for each node then you can try to add something like this:


FILE *try;
#ifPARALLEL
if(I_AM_NODE_ZERO_P)
#endif
{
try=fopen("youfile.dat","w+");
fprintf(try, ....... );
fclose(try);
}
thanks! I'll have a try.
xuwenhua625 is offline   Reply With Quote

Old   April 29, 2019, 01:31
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
you should write to file from HOST
more details you may find in Ansys Fluent Customization manual
it contains pretty clear example chapter Writing Files in Parallel

best regards
AlexanderZ is offline   Reply With Quote

Old   May 15, 2019, 05:33
Default
  #6
New Member
 
Join Date: Nov 2018
Posts: 14
Rep Power: 7
pianaCFD is on a distinguished road
..................

Last edited by pianaCFD; May 15, 2019 at 05:35. Reason: I set in the wrong place
pianaCFD is offline   Reply With Quote

Reply

Tags
parallel calculation, udf code


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
Custom Thermophysical Properties wsmith02 OpenFOAM 4 June 1, 2023 14:30
[Other] Tabulated thermophysicalProperties library chriss85 OpenFOAM Community Contributions 62 October 2, 2022 03:50
[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
[OpenFOAM.org] Error creating ParaView-4.1.0 OpenFOAM 2.3.0 tlcoons OpenFOAM Installation 13 April 20, 2016 17:34
ParaView Compilation jakaranda OpenFOAM Installation 3 October 27, 2008 11:46


All times are GMT -4. The time now is 06:24.