|
[Sponsors] |
January 21, 2019, 12:17 |
save to variable filename inside loop
|
#1 |
New Member
Frank Richter
Join Date: Oct 2018
Posts: 13
Rep Power: 8 |
Dear Community,
I'd need you kind advice. The code below opens a sequence of dat files "M:/Brandraumbeispiel/Test-03/Test-03-time_step=0001.dat" "M:/Brandraumbeispiel/Test-03/Test-03-time_step=0002.dat" and so on. This is working fine, and I see the graphics of a temperature distribution displayed on the screen. I would like to save these graphics to files "M:/Brandraumbeispiel/Test-03/Test-03-Journal-Output/Test-03-Temperatur auf Ebene z=05dm-time_step=0001.png" "M:/Brandraumbeispiel/Test-03/Test-03-Journal-Output/Test-03-Temperatur auf Ebene z=05dm-time_step=0002.png" but whatever I do - see the long section which are now commented out - I achieve only the saving of the graphics with a filename which is overwritten in each loop. Also, the filename did not have any counter in it. The filenames were "string-append.png" or "name.png", in various attempts. I spent more than a day on that and give up. Please advise me. Journal-File is preferred, alternatively a Scheme-file. Thank you so much, FrankR -------------------------------------------------------------- /file/set-tui-version "19.2" ; H:\ANSYS Product PDF DOC 192\v192\ANSYS_Fluent_Users_Guide.pdf; 3.1.8. Disabling the Overwrite Confirmation Prompt /file/confirm-overwrite? no ; (cx-gui-do cx-activate-item "MenuBar*WriteSubMenu*Start Transcript...") (cx-gui-do cx-set-file-dialog-entries "Select File" '( "M:\Brandraumbeispiel\Test-03\Test-03-Loop.txt") "Transcript Files (*.trn *.out )") ; ; ; (let loop ((times 1)) (if (= times 4) (display "stopped. ") (begin (display (format #f "\nLoop ~d: z=05dm-~04d\n" times times) ) (ti-menu-load-string (format #f "file read-data M:/Brandraumbeispiel/Test-03/Test-03-time_step=~04d.dat" times)) ; ;(ok-to-overwrite? yes) ; (cx-gui-do cx-set-list-tree-selections "NavigationPane*List_Tree1" (list "Results|Graphics|Contours")) (cx-gui-do cx-list-tree-right-click "NavigationPane*List_Tree1" ) (cx-gui-do cx-activate-item "MenuBar*PopupMenuTree-Contours*New...") (cx-gui-do cx-set-toggle-button2 "Contours*Table1*Frame1*ToggleBox1(Options)*CheckB utton3(Contour Lines)" #t) (cx-gui-do cx-activate-item "Contours*Table1*Frame1*ToggleBox1(Options)*CheckB utton3(Contour Lines)") (cx-gui-do cx-set-list-selections "Contours*Table1*Frame3*Table1*DropDownList1(Conto urs of)" '( 3)) (cx-gui-do cx-activate-item "Contours*Table1*Frame3*Table1*DropDownList1(Conto urs of)") (cx-gui-do cx-set-toggle-button2 "Contours*Table1*Frame1*ToggleBox1(Options)*CheckB utton8(Draw Mesh)" #t) (cx-gui-do cx-activate-item "Contours*Table1*Frame1*ToggleBox1(Options)*CheckB utton8(Draw Mesh)") (cx-gui-do cx-set-list-selections "Mesh Display*Table1*Frame3*List1(Surfaces)" '( 0 2 3 4 5 6)) (cx-gui-do cx-activate-item "Mesh Display*Table1*Frame3*List1(Surfaces)") (cx-gui-do cx-activate-item "Mesh Display*PanelButtons*PushButton1(OK)") (cx-gui-do cx-activate-item "Mesh Display*PanelButtons*PushButton2(Cancel)") (cx-gui-do cx-set-list-selections "Contours*Table1*Frame3*Frame2*List2(Surfaces) " '( 7)) (cx-gui-do cx-activate-item "Contours*Table1*Frame3*Frame2*List2(Surfaces) ") (cx-gui-do cx-activate-item "Contours*Table1*Frame1*PushButton4(Colormap Options)") (cx-gui-do cx-set-toggle-button2 "Colormap*Frame2(Labels)*CheckButton1(Show All)" #t) (cx-gui-do cx-activate-item "Colormap*Frame2(Labels)*CheckButton1(Show All)") (cx-gui-do cx-activate-item "Colormap*PanelButtons*PushButton1(OK)") (cx-gui-do cx-activate-item "Colormap*PanelButtons*PushButton2(Cancel)") (cx-gui-do cx-activate-item "Contours*PanelButtons*PushButton1(OK)") (cx-gui-do cx-activate-item "Contours*PanelButtons*PushButton2(Cancel)") ; (cx-gui-do cx-activate-item "MenuBar*FileMenu*Save Picture...") (cx-gui-do cx-set-toggle-button2 "Save Picture*Frame2*Frame1*Frame3(Resolution)*Table1*To ggleBox1*CheckButton1(Use Window Resolution)" #t) (cx-gui-do cx-activate-item "Save Picture*Frame2*Frame1*Frame3(Resolution)*Table1*To ggleBox1*CheckButton1(Use Window Resolution)") (cx-gui-do cx-activate-item "Save Picture*PanelButtons*PushButton1(OK)") ;(string-append "M:/Brandraumbeispiel/Test-03/Test-03-Journal-Output/Test-03-Temperatur auf Ebene z=05dm-" (number->string q 10) ) ;(string-append "M:/Brandraumbeispiel/Test-03/Test-03-Journal-Output/Test-03-Temperatur auf Ebene z=05dm-" (number->string q 10) ) ;(define name (string-append "M:/Brandraumbeispiel/Test-03/Test-03-Journal-Output/Test-03-Temperatur auf Ebene z=05dm-" (number->string q 10) )) ;(define name (append '("M:/Brandraumbeispiel/Test-03/Test-03-Journal-Output/Test-03-Temperatur auf Ebene z=05dm-") (number->string q 10) )) ;(define name (string-append "M:/Brandraumbeispiel/Test-03/Test-03-Journal-Output/Test-03-Temperatur auf Ebene z=05dm-" (substring (in-package cl-file-package wc-filename) 47 51) ) ) ;(define name (format #f "M:/Brandraumbeispiel/Test-03/Test-03-Journal-Output/Test-03-Temperatur auf Ebene z=05dm-~d.png")) ;(set! name (format #f " M:/Brandraumbeispiel/Test-03/Test-03-Journal-Output/Test-03-Temperatur auf Ebene z=05dm-~04d.png" times)) ;(display (name)) ;(cx-gui-do cx-set-file-dialog-entries "Select File" '(format #f " M:/Brandraumbeispiel/Test-03/Test-03-Journal-Output/Test-03-Temperatur auf Ebene z=05dm-~04d.png" times) "Hardcopy Files (*.png)") ;(cx-gui-do cx-set-file-dialog-entries "Select File" '((format #f " M:/Brandraumbeispiel/Test-03/z=05dm-~04d.png" times) ) "Hardcopy Files (*.png)") ;(cx-gui-do cx-set-file-dialog-entries "Select File" '("M:/Brandraumbeispiel/Test-03/z=05dm-2.png") "Hardcopy Files (*.png)") ;(define cc (format #f "~04d.png" times)) ;(cx-gui-do cx-set-file-dialog-entries "Select File" '((string-append " M:/Brandraumbeispiel/Test-03/z=05dm-" cc ".png" )) "Hardcopy Files (*.png)") ;(cx-gui-do cx-set-file-dialog-entries "Select File" (format #f " M:/Brandraumbeispiel/Test-03/z=05dm-~04d.png" times) "Hardcopy Files (*.png)") ;(cx-gui-do cx-set-file-dialog-entries (string-append "Select File" '(" M:/Brandraumbeispiel/Test-03/z=05dm-" (substring (in-package cl-file-package wc-filename) 47 51) ".png" )) "Hardcopy Files (*.png)") ; ;/display/save-picture "Select File" '(append (" M:/Brandraumbeispiel/Test-03/z=05dm-" (format #f " M:/Brandraumbeispiel/Test-03/z=05dm-~04d.png" times) ".png" )) ;/display/save-picture "Select File" '( " M:/Brandraumbeispiel/Test-03/z=05dm-" ".png" ) ; ;(cx-gui-do cx-set-file-dialog-entries "Select File" '( "M:\Brandraumbeispiel\Test-03\Test-03-Journal-Output\Test-03-Pathlines von Quelle colored by static temperature.png") "Hardcopy Files (*.png)") ; ;(cx-gui-do cx-activate-item "Save Picture*PanelButtons*PushButton2(Cancel)") ;(rename-file "M:/Brandraumbeispiel/Test-03/format.png" (format #f " M:/Brandraumbeispiel/Test-03/Test-03-Journal-Output/Test-03-Temperatur auf Ebene z=05dm-~04d.png" times) ) ; (display "Ende des Loops\n") (loop (+ times 1)) ; ); Ende der begin-Schleife ); if ); loop ; /file/confirm-overwrite? yes ; (cx-gui-do cx-activate-item "MenuBar*WriteSubMenu*Stop Transcript") (cx-gui-do cx-activate-item "MenuBar*WriteSubMenu*Stop Journal") |
|
January 22, 2019, 00:46 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
actually, i don't know how your code should exactly works.
So here is some code, which may read data and save picture, you should tune it for your case Code:
(ti-menu-load-string (format #f "display objects create contour \"temperature_contor1\" surfaces-list 7 () node-values? no field temperature filled? yes levels 20 range auto-range global-range? yes q name temperature_contor1 q\n")) (ti-menu-load-string (format #f "display contour temperature 300 400\n")) (do ((i 1 (+ i 1)))((> i 3)) (ti-menu-load-string (format #f "file read-data \"Test-03-time_step=000~a.dat\" OK \n" i)) (ti-menu-load-string (format #f "display views restore-view view-2 \n")) (ti-menu-load-string (format #f "display views a-s \n")) (ti-menu-load-string (format #f "display set contours c-t-r no")) (ti-menu-load-string (format #f "display set filled-mesh? no")) (ti-menu-load-string (format #f "display set render-mesh? yes")) (ti-menu-load-string (format #f "display set mesh-surfaces (0 2 3 4 5 6) ")) (ti-menu-load-string (format #f "display set rendering-options s-e-v yes no yes no")) (ti-menu-load-string (format #f "display set picture color-mode color")) (ti-menu-load-string (format #f "display set picture driver png ")) (ti-menu-load-string (format #f "display views camera projection orthographic")) (ti-menu-load-string (format #f "display objects display temperature_contor1")) (ti-menu-load-string (format #f "display contour temperature 300 400")) (ti-menu-load-string (format #f "display save-picture \"temperature_surface_case000~a.png\" " i)) ) it will create an object, which you will see in graphic window read data from file read view (rotation settings of 3d model, you should create and save this view, in code name of view is VIEW-2 finally it will save picture best regards |
|
January 22, 2019, 10:33 |
|
#3 |
New Member
Frank Richter
Join Date: Oct 2018
Posts: 13
Rep Power: 8 |
Dear Alexander
thank you so much. I was unaware that each of these lines has to be begun with "format f" inside a loop. The code, attached underneath, is run as a journal file now. I prefer journal file because a transcript file records the commands carried out. Important for documentation in case the code processing my simulation output is altered later on. Nevertheless, a couple of issues remain: The modifications that do not cause problems: a) I deleted auto-scale because the graphics moved in the pngs from time step 1 to time step 2, but remained immobile from time step 2 to time step 3. Now the graphis remains immobile. b) I picked global range because the temperature range should be constant over the entire series of figures to be generated. c) Every time I modified the code and ran it again and got a warning stating that "temperature_contor1" already exists. Now I delete it at the top of the code, prior to re-defining it during a new run. Could you also adivse me on the couple of issues still remaining ? 1) Contour lines could not be achieved, I get the message display set titles graphicstitleinvalid command [graphicstitle] 2) The mesh is lost. It did work in your version, but I am unable to have it displayed again. I'd need an overlay of the two graphics in the pdf attached. 3) I could not find the command "name" in the "ANSYS Fluent Text Command List" in the section on "display" or elsewhere. To which section does it pertain ? 4) In your version "q" appears twice. What is it for ? 5) On "display set rendering-options s-e-v yes no yes no": I find the command "rendering-options" and "set-rendering-options". But under Tree, Results, Graphics, Options that are more than 4 parameters. The User's Guide, chapter "33.2.7. Modifying the Rendering Options" also lists more options. What do they stand for, and where is that documented ? 6) How can I insert a graphics title ? The User's guide was not so helpful on that, too. 7) How can I generate free output ? I am thinking of something like "Now working on time step 1" "Now working on time step 2"... Thank you so much once more, FrankR ------------------------------------------------------------------------------ /file/set-tui-version "19.2" ; H:\ANSYS Product PDF DOC 192\v192\ANSYS_Fluent_Users_Guide.pdf; 3.1.8. Disabling the Overwrite Confirmation Prompt /file/confirm-overwrite? no ; (cx-gui-do cx-activate-item "MenuBar*WriteSubMenu*Start Transcript...") (cx-gui-do cx-set-file-dialog-entries "Select File" '( "M:\Brandraumbeispiel\Test-03\Test-03-Loop.txt") "Transcript Files (*.trn *.out )") ; ; ; (ti-menu-load-string (format #f "display objects delete temperature_contor6")) (ti-menu-load-string (format #f "display objects create contour "temperature_contor6" field temperature filled-contours? yes name temperature_contor6 q\n")) (do ((i 1 (+ i 1)))((> i 3)) (newline) (ti-menu-load-string (format #f "file read-data "M:/Brandraumbeispiel/Test-03/Test-03-time_step=000~a.dat" OK \n" i)) ;(newline) ;(ti-menu-load-string (format #f "views auto-scale")) (newline) (ti-menu-load-string (format #f "display set contours clip-to-range no")) (newline) (ti-menu-load-string (format #f "display set contours n-contour 20")) (newline) (ti-menu-load-string (format #f "display set contours surfaces 6")) (newline) (ti-menu-load-string (format #f "display set contours global-range? yes")) (newline) ; ; The next 3 lines enable contour-lines. (ti-menu-load-string (format #f "display set render-mesh? yes")) (newline) (ti-menu-load-string (format #f "display set contours filled-contours? yes")) (newline) (ti-menu-load-string (format #f "display set contours node-values? yes")) (newline) (ti-menu-load-string (format #f "display set contours contour-lines? yes")) (newline) ; (newline) (ti-menu-load-string (format #f "display set filled-mesh? no")) (newline) (ti-menu-load-string (format #f "display set render-mesh? yes")) (newline) (ti-menu-load-string (format #f "display set mesh-surfaces (0 2 3 4 5 6) ")) (newline) (ti-menu-load-string (format #f "display set rendering-options s-e-v yes no yes no")) (newline) (ti-menu-load-string (format #f "display set picture color-mode color")) (newline) (ti-menu-load-string (format #f "display set picture driver png ")) (newline) (ti-menu-load-string (format #f "display objects display temperature_contor6")) (newline) ; ; title: User's Guide 33.2.3.1. Controlling the Titles, Axes, Ruler, Logo, and Colormap (ti-menu-load-string (format #f "display set windows text company? yes")) (newline) (ti-menu-load-string (format #f "display set titles graphicstitle")) (newline) (ti-menu-load-string (format #f "display set windows text company? yes")) (newline) (ti-menu-load-string (format #f "display re-render")) (newline) (ti-menu-load-string (format #f "display set mesh-surfaces (0 2 3 4 5 6) ")); (newline) (ti-menu-load-string (format #f "display set render-mesh? yes")) (newline) ; (ti-menu-load-string (format #f "display views camera projection orthographic")) (newline) (ti-menu-load-string (format #f "display save-picture "M:/Brandraumbeispiel/Test-03/Test-03-Temperatur auf Ebene x=center/Test-03-Temperatur auf Ebene x=center-time_step=000~a.png" " i)) (newline) ) ; /file/confirm-overwrite? yes ; (cx-gui-do cx-activate-item "MenuBar*WriteSubMenu*Stop Transcript") (cx-gui-do cx-activate-item "MenuBar*WriteSubMenu*Stop Journal") |
|
January 23, 2019, 04:08 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
1.
display set titles than you should select the location of title (left-bottom right-bottom right-top left-top right-middle) and finally title Code:
(ti-menu-load-string (format #f "display set titles left-bottom \"My_title\" ")) 4. q is quit. Quit function 6. See question 1. 7. Code:
(format #t "Now working on time step ~a \n" i) regarding questions 2 and 5: TUI functionality covers most of GUI functions (or vice versa) you should find yourself combination of settings, which works for you You may start with GUI, step by step create view you want, than move to TUI commands and make the same using only TUI Finally put it in code best regards |
|
January 23, 2019, 05:45 |
|
#5 |
New Member
Frank Richter
Join Date: Oct 2018
Posts: 13
Rep Power: 8 |
Dear Alexander
great, thank you. I will be at work only on Friday, but reply today already. I don't want you to get the impression that I absorb your advice and do not respond. Having little time in office on Friday I may possibly work on the code only next week. Regards Frank |
|
January 30, 2019, 12:16 |
|
#6 |
New Member
Frank Richter
Join Date: Oct 2018
Posts: 13
Rep Power: 8 |
Dear Alexander
thank you for your advice. I am at work again only today. Can I please have your kind assistance one more time ? I did achieve to place a file name right onto the graphics, see attached picture, and this also for a series of time steps. But I spent one more day, in vain, trying to combine the picture of the temperature on the plane with the geometry of the room, see second picture. The views are different, the colored plane is in the middle of the room. I experimented with the command (ti-menu-load-string (format #f "display set mesh-surfaces (0 2 3 4 5 6) ")) and with 'mesh outline', in TUI and GUI, but whatever I do, I end up only with the single plane or with the geometry, but never with the two combined. I did get the desired result earlier , when I did not code a loop over different time steps. What is wrong ? Do the "render"-commands erase earlier commands ? Thank you again dearly, Frank ------------------------------------------------------------- /file/set-tui-version "19.2" ; H:\ANSYS Product PDF DOC 192\v192\ANSYS_Fluent_Users_Guide.pdf; 3.1.8. Disabling the Overwrite Confirmation Prompt /file/confirm-overwrite? no ; (cx-gui-do cx-activate-item "MenuBar*WriteSubMenu*Start Transcript...") (cx-gui-do cx-set-file-dialog-entries "Select File" '( "M:/Brandraumbeispiel/Test-03/Test-03-Temperatur auf Ebene x=center/Test-03-Temperatur auf Ebene x=center-Loop.txt") "Transcript Files (*.trn *.out )") ; ; ; ; Turn view in order to inspect the plane x=center (cx-gui-do cx-activate-item "ToolBar*Pointer Tools*rotate") (cx-use-window-id 1) (cx-set-camera-relative '(-19.9417 -21.6539 2.52853) '(0 0 0) '(1.17039 -0.571296 1.22949) 0 0) ; (ti-menu-load-string (format #f "display objects create contour "temperature_contour8" field temperature name temperature_contour8 q\n")) ; ; ; (do ((i 1 (+ i 1)))((> i 3)) (newline) (format #t "################################################# ###") (newline) (format #t "Now working on time step ~a" i) (newline) (ti-menu-load-string (format #f "file read-data "M:/Brandraumbeispiel/Test-03/Test-03-time_step=-1-0000~a.dat" \n" i)) (newline) ; ; ;(ti-menu-load-string (format #f "views auto-scale")) (newline) ; Time step is not correctly shown if this command is placed immediately before "save-picture" (ti-menu-load-string (format #f "display set titles left-bottom "M:/Brandraumbeispiel/Test-03/Test-03-Temperatur auf Ebene x=center/Test-03-Temperatur auf Ebene x=center-time_step=000~a.png" " i)) (newline) (ti-menu-load-string (format #f "display set contours clip-to-range no")) (newline) (ti-menu-load-string (format #f "display set contours n-contour 20")) (newline) (ti-menu-load-string (format #f "display set contours surfaces 6")) (newline) (ti-menu-load-string (format #f "display set contours global-range? yes")) ; ; The next 3 lines enable contour-lines. (newline) (ti-menu-load-string (format #f "display set filled-mesh? no")) (newline) (ti-menu-load-string (format #f "display set render-mesh? yes")) (newline) (ti-menu-load-string (format #f "display set contours filled-contours? no")) (newline) (ti-menu-load-string (format #f "display set contours node-values? yes")) (newline) (ti-menu-load-string (format #f "display set contours line-contours? yes")) (newline) (ti-menu-load-string (format #f "display set filled-mesh? no")) (newline) (ti-menu-load-string (format #f "display set render-mesh? yes")) (newline) (ti-menu-load-string (format #f "display set mesh-surfaces (0 2 3 4 5 6) ")) (newline) (ti-menu-load-string (format #f "display set rendering-options s-e-v yes no yes no")) (newline) (ti-menu-load-string (format #f "display set picture color-mode color")) (newline) (ti-menu-load-string (format #f "display set picture driver png ")) (newline) (ti-menu-load-string (format #f "display objects display temperature_contour8")) (newline) ; ; title: User's Guide 33.2.3.1. Controlling the Titles, Axes, Ruler, Logo, and Colormap (ti-menu-load-string (format #f "display set windows text company? yes")) (newline) (ti-menu-load-string (format #f "display re-render")) (newline) (ti-menu-load-string (format #f "display set mesh-surfaces (0 2 3 4 5 6) ")); (newline) (ti-menu-load-string (format #f "display set render-mesh? yes")) (newline) ; (ti-menu-load-string (format #f "display views camera projection orthographic")) (newline) (ti-menu-load-string (format #f "display save-picture "M:/Brandraumbeispiel/Test-03/Test-03-Temperatur auf Ebene x=center/Test-03-Temperatur auf Ebene x=center-time_step=000~a.png" " i)) (newline) ) ; /file/confirm-overwrite? yes ; (cx-gui-do cx-activate-item "MenuBar*WriteSubMenu*Stop Transcript") (cx-gui-do cx-activate-item "MenuBar*WriteSubMenu*Stop Journal") |
|
Tags |
loop, scheme programming, variable filename |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field | lakeat | OpenFOAM Community Contributions | 58 | December 23, 2021 03:36 |
[Other] refineWallLayer Error | Yuby | OpenFOAM Meshing & Mesh Conversion | 2 | November 11, 2021 12:04 |
Pressure distribution on a wall | darazsbence | CFX | 17 | October 6, 2015 11:38 |
Create a loop to open .cas and save images | ld1305 | FLUENT | 2 | July 26, 2013 03:38 |
Save variable in DEFINE_EXECUTE_AT_END | tim.sonderby | Fluent UDF and Scheme Programming | 2 | November 23, 2012 10:22 |