|
[Sponsors] |
![]() |
![]() |
#1 |
Member
Join Date: Aug 2009
Posts: 67
Rep Power: 17 ![]() |
Hi guys,
I need help!!! I'm not familiar with UDF. I compiled the Udf of cavitation rate which is found at udf manual. I add the last line (Message...) and everything is ok. I can see the values of cavitation mass transfer rate at fluent window. But i want to save these values in a .txt file. How can i do this? Thanks a lot! #include"udf.h" #define c_evap 1.0 #define c_con 0.1 DEFINE_CAVITATION_RATE(user_cav_rate, c, t, p, rhoV, rhoL, mafV, p_v, cigma, f_gas, m_dot) { real p_vapor = *p_v; real dp, dp0, source; p_vapor += MIN(0.195*C_R(c,t)*C_K(c,t), 5.0*p_vapor); dp = p_vapor - ABS_P(p[c], op_pres); dp0 = MAX(0.1, ABS(dp)); source = sqrt(2.0/3.0*rhoL[c])*dp0; if(dp > 0.0) *m_dot = c_evap*rhoV[c]*source; else *m_dot = -c_con*rhoL[c]*source; Message("Cavitation Mass Transfer Rate: %g\n",m_dot); } |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 ![]() |
Code:
#include"udf.h" #define c_evap 1.0 #define c_con 0.1 DEFINE_CAVITATION_RATE(user_cav_rate, c, t, p, rhoV, rhoL, mafV, p_v, cigma, f_gas, m_dot) { FILE *pf; real p_vapor = *p_v; real dp, dp0, source; p_vapor += MIN(0.195*C_R(c,t)*C_K(c,t), 5.0*p_vapor); dp = p_vapor - ABS_P(p[c], op_pres); dp0 = MAX(0.1, ABS(dp)); source = sqrt(2.0/3.0*rhoL[c])*dp0; if(dp > 0.0) *m_dot = c_evap*rhoV[c]*source; else *m_dot = -c_con*rhoL[c]*source; Message("Cavitation Mass Transfer Rate: %g\n",m_dot); if(NULL == (pf = fopen("bubu.txt","a"))) Error("Could not open file for append!\n"); fprintf(pf,"%e\n",m_dot); fclose(pf); } |
|
![]() |
![]() |
![]() |
![]() |
#3 |
Member
Join Date: Aug 2009
Posts: 67
Rep Power: 17 ![]() |
Thanks friend!!!
It works!!! ![]() |
|
![]() |
![]() |
![]() |
![]() |
#4 |
Member
Ivan
Join Date: Aug 2009
Posts: 63
Rep Power: 17 ![]() |
Hi dmoroian,
I'd like to use a UDF to save velocity field data on 50 cross-section planes (p-1, p-2,..., p-50) of my domain after every time step of an unsteady Fluent simulation. Would you please let me know how? Thanks a lot beforehand, Ivan. |
|
![]() |
![]() |
![]() |
![]() |
#5 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 ![]() |
Hello Ivan,
For that purpose, I would use macros (scheme scripts) instead of udf's. You can set fluent to export the data in those planes in many different formats (my preferate is DX format for the OpenDX postprocessor). |
|
![]() |
![]() |
![]() |
![]() |
#6 |
Member
Ivan
Join Date: Aug 2009
Posts: 63
Rep Power: 17 ![]() |
Hi Dragos,
I see. However, I heard that using macros Fluent overwrites the existing file so in the end what I would have stored would be the information at the last time step. I'd like to have velocity data on several planes at every time step, for me to be able to make time marching analysis. I'd like to export the data in ASCII and then imported them into Matlab, which is what I'm familiar with. Any suggestion? Thanks a lot, Ivan. |
|
![]() |
![]() |
![]() |
![]() |
#7 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 ![]() |
Well, one of the facilities is that you can automatically change the name of the output file every iteration or every time step.
|
|
![]() |
![]() |
![]() |
![]() |
#8 |
Member
Ivan
Join Date: Aug 2009
Posts: 63
Rep Power: 17 ![]() |
Really?
can you let me know how? I mean, I want to save velocity data on 50 planes and I'd need to have every plane velocity data in one single file because that eases me a lot my life later when post-processing. Thanks, Ivan. |
|
![]() |
![]() |
![]() |
![]() |
#9 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 ![]() |
Hi Ivan,
Check chapter 4.1.7 in the user manual for automatic numbering of files, and 4.13 for exporting solution data (I think you're interested in the ASCII format). The simplest way is to record a macro (check chap. 4.10.1) that exports data from your planes into ASCII format with automatic file naming, and run it periodically into "Calculation activities". |
|
![]() |
![]() |
![]() |
![]() |
#10 |
Member
Ivan
Join Date: Aug 2009
Posts: 63
Rep Power: 17 ![]() |
Hi Dragos,
thanks a lot for that post, you explained just what I need. I've checked the sections you has recommended me and they look promising. In section 40.10.1 the creation of transcript is explained. It says that between "start transcript" and "end transcript" everything that is done is recorder. I'm wondering if Fluent executes that transcript after every time step. By the way, I can't find anything named as "Calculation activities" on Chapter 4. I'll have a got up to what I've understand and let you know. Thanks a lot, Ivan. |
|
![]() |
![]() |
![]() |
![]() |
#11 | ||
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 ![]() |
Quote:
1. In the GUI, chose from the menu: File->Read->Scheme or File->Read->Journal This will run once the chosen script 2. In the GUI, chose from menu: Solve->Calculation Activities... Here you can specify one or several scripts to be run periodically, on an iteration or time step basis. In version 6.3 the item "Calculation Activities..." is called "Execute Commands...". 3. In the TUI you can do the same thing as in above, both periodically and one time, but I let you the challenge to find out how. Quote:
Dragos |
|||
![]() |
![]() |
![]() |
![]() |
#12 |
Member
Ivan
Join Date: Aug 2009
Posts: 63
Rep Power: 17 ![]() |
I see.
I know about the existence of Execute Commands. Actually, before you told me your solution, I was trying to create macros through the Execute Command window. Unfortunately, I don't know what I do wrong but when I create a macro, it just doesn't want to run. OK, following your instructions, which I've liked much, once I open the Execute Command window, what sort of command do I have to type to call the script just created? I've been surfing on the Internet looking for some examples, but no luck. I did a silly thing - typing in the command field the name of the file that contains my transcript, but it just didn't work. By the way, the file auto-naming works fine. Looking forward to hearing from you. Ivan. |
|
![]() |
![]() |
![]() |
![]() |
#13 |
New Member
hameurlaine
Join Date: Jul 2009
Posts: 27
Rep Power: 17 ![]() |
Hi
I try to modeled arc burning discharge, and i didn't know how to introduce two temperature or energy equation, one for electrons and for heavey species. if you have any suggestion answer me. Thant's louiza |
|
![]() |
![]() |
![]() |
![]() |
#14 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 ![]() |
To Ivan:
If you check the help page for the "Execute Commands" dialog box, you'll find out that it can run commands defined using the button "Define Macro.." or text commands. In your case, the command should be something like: Code:
/file/read-macros Ivan_macro.scm To Louiza: Hi Louiza, please respect a bit of discipline on the threads. If you stump like this on a thrread with a completely different subject, and that is not finished, you will just annoy the participants. As a suggestion for the future: if you have a question that was not asked before, put the question in a new thread or one that is related to it. |
|
![]() |
![]() |
![]() |
![]() |
#15 |
Member
Ivan
Join Date: Aug 2009
Posts: 63
Rep Power: 17 ![]() |
Hi Dragos,
thanks a lot for that info. I tried what you said and didn't work because for some reason Fluent couldn't identify my transcript file as a macro one. Therefore I created a journal (file attached) the same way you've told me to create a transcript, and then I specified its execution through Execute Commands (file attached). Unfortunately, when I run the simulatio and it passes from one time step to the following it gives an error message (file attached). Strangely, when I click 'ok' on the error message, the simulation continues (it doesn't do it until I hit the 'ok') and if I cancel iterating Fluent just blows away and disappear. I have saved the journal file in the same folder where the .cas and .dat files are and when exporting the ASCII files they also should be stored in the same folder (see journal file). I don't know what I'm doing badly... |
|
![]() |
![]() |
![]() |
![]() |
#16 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 ![]() |
You'll have to experiment with this, but for the moment try changing:
Code:
(cx-gui-do cx-set-text-entry "Select File*FilterText" "e:\3_re_fluent_with_actuator\active\1hz\\*") (cx-gui-do cx-activate-item "Select File*Apply") (cx-gui-do cx-set-text-entry "Select File*Text" "x1_%6t.dat") (cx-gui-do cx-activate-item "Select File*OK") Code:
(cx-gui-do cx-set-text-entry "Select File*FilterText" "e:\3_re_fluent_with_actuator\active\1hz\*") (cx-gui-do cx-set-text-entry "Select File*Text" "x1_%6t.dat") (cx-gui-do cx-activate-item "Select File*OK") |
|
![]() |
![]() |
![]() |
![]() |
#17 |
Member
Ivan
Join Date: Aug 2009
Posts: 63
Rep Power: 17 ![]() |
Hi Dragos,
thanks it works. Well, it works half-way... At least I don't get that error any more. However, it doesn't behave as expected for 2 reasons: 1) Even though in the journal is clearly said (see attached file) that the data as to be saved here: E:\3_RE_FLUENT_WITH_ACTUATOR\ACTIVE\1Hz\DATA_OUTPU T it saves here: E:\3_RE_FLUENT_WITH_ACTUATOR\ACTIVE\1Hz (see attached picture) 2) Once Fluent saves the data and go for the next time step, the programme crashes due to out of memory (see attached picture). This is curious because before, when I wasn't running the journal (and therefore not saving data files), Fluent kept working normally from one step to ther next one, over and over, without complaining about out of memory. Do you have any clue? Thanks a lot. Ivan. |
|
![]() |
![]() |
![]() |
![]() |
#18 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 ![]() |
Here come some comments:
1. The "Apply" line should not be removed (although it was my previous suggestion). This should fix the path for the output data. 2. In the picture you present there is a last command involving the stop of macro recording, which should not be there (and your archive doesn't contain it). I suspect this may be the cause of fluent crash (although it shouldn't). 3. I think it is time for you to go further and try the TUI instead of GUI. The whole script should be: Code:
/file/export ascii data_output/bubu.txt 13 () no pressure () no This is just a starting point, and I'm sure you can take it from here. |
|
![]() |
![]() |
![]() |
![]() |
#19 |
Member
Ivan
Join Date: Aug 2009
Posts: 63
Rep Power: 17 ![]() |
Hi Dragos,
thanks for your comments. There's something weird going on... As you say, on Fluent's screenshot it is said: > (cx-gui-do cx-activate-item "Export*PanelButtons*PushButton2(Cancel)") > (cx-gui-do cx-activate-item "MenuBar*WriteSubMenu*Stop Journal") However,the actual journal file just contains: (cx-gui-do cx-activate-item "MenuBar*FileMenu*Export...") (cx-gui-do cx-set-toggle-button "Export*Frame1*Table1*Frame8(Delimiter)*ToggleBox8 (Delimiter)*Space" #f) (cx-gui-do cx-activate-item "Export*Frame1*Table1*Frame8(Delimiter)*ToggleBox8 (Delimiter)*Space") (cx-gui-do cx-set-list-selections "Export*Frame1*Table1*Frame2*List2(Surfaces)" '( 13)) (cx-gui-do cx-activate-item "Export*Frame1*Table1*Frame2*List2(Surfaces)") (cx-gui-do cx-activate-item "Export*PanelButtons*PushButton1(OK)") (cx-gui-do cx-set-text-entry "Select File*FilterText" "e:\3_re_fluent_with_actuator\active\1hz\data_outp ut\\*") (cx-gui-do cx-set-text-entry "Select File*Text" "x1_%6t.dat") (cx-gui-do cx-activate-item "Select File*OK") Therefore, there's nothing in the journal file related to a previous version of the journal file. But I can guarantee you that I smashed the former journal file. Besides, Fluent complains about malloc out of memory... ![]() |
|
![]() |
![]() |
![]() |
![]() |
#20 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 ![]() |
Most likely you run a journal file that is different from what you think it has inside. Did you try my version of script?
|
|
![]() |
![]() |
![]() |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Working directory via command line | Luiz | CFX | 4 | March 6, 2011 20:02 |
UDF Getting data from file | jreig | FLUENT | 0 | July 10, 2009 08:07 |
Smallest binary file format to save large data | Zonexo | Main CFD Forum | 2 | June 2, 2008 20:25 |
[blockMesh] Axisymmetrical mesh | Rasmus Gjesing (Gjesing) | OpenFOAM Meshing & Mesh Conversion | 10 | April 2, 2007 14:00 |
UDF (write a data file) problem | lichun Dong | FLUENT | 2 | July 29, 2005 11:39 |