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

Fluent journal - do loop

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 26, 2017, 20:18
Default Fluent journal - do loop
  #1
Member
 
Marcin
Join Date: Jun 2016
Posts: 98
Rep Power: 10
destroy is on a distinguished road
Hello!

I need to create a code that will load case&data into ANSYS Fluent, then create a surface, and then - calculate medium pressure on that surface.
These three actions have to be repeated 100 times.
I write a do loop, which you can see below, but in doesn't work with these three action. It work for only one action (any of these 3). Please tell me, where my mistake is, and how to change the code.
Is there even a possibility of making multiple commands in do loop?

Regards


(Do ((x 1 (+ x 1))) ((> x 100))
(Ti-menu-load-string (format #f "file read-case-data K:\USERS\mnowak\artykulzautosavemnaprawa\postproce ssing\caseanddatadoanalizy\Fluentmesh14-58-0000~a.cas.gz" x))
(Ti-menu-load-string (format #f "surface plane-surf-aligned ooooo~a outlet2 -0.0291707 -0.0056188 0.13" x))
(Ti-menu-load-string (format #f "report surface-integrals area-weighted-avg ooooo~a () pressure y pressure1" x))
)
destroy is offline   Reply With Quote

Old   November 26, 2017, 21:03
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Quote:
Originally Posted by destroy View Post
Hello!

I need to create a code that will load case&data into ANSYS Fluent, then create a surface, and then - calculate medium pressure on that surface.
These three actions have to be repeated 100 times.
I write a do loop, which you can see below, but in doesn't work with these three action. It work for only one action (any of these 3). Please tell me, where my mistake is, and how to change the code.
Is there even a possibility of making multiple commands in do loop?

Regards


(Do ((x 1 (+ x 1))) ((> x 100))
(Ti-menu-load-string (format #f "file read-case-data K:\USERS\mnowak\artykulzautosavemnaprawa\postproce ssing\caseanddatadoanalizy\Fluentmesh14-58-0000~a.cas.gz" x))
(Ti-menu-load-string (format #f "surface plane-surf-aligned ooooo~a outlet2 -0.0291707 -0.0056188 0.13" x))
(Ti-menu-load-string (format #f "report surface-integrals area-weighted-avg ooooo~a () pressure y pressure1" x))
)
You may try to read scheme language tutorials in future.
For this problem I suggest you to try this code:

Code:
(Do ((x 1 (+ x 1))) ((> x 100))
(begin
(Ti-menu-load-string (format #f "file read-case-data K:\USERS\mnowak\artykulzautosavemnaprawa\postprocessing\caseanddatadoanalizy\Fluentmesh14-58-0000~a.cas.gz" x))
(Ti-menu-load-string (format #f "surface plane-surf-aligned ooooo~a outlet2 -0.0291707 -0.0056188 0.13" x))
(Ti-menu-load-string (format #f "report surface-integrals area-weighted-avg ooooo~a () pressure y pressure1" x))
))
Best regards
AlexanderZ is offline   Reply With Quote

Old   November 26, 2017, 21:10
Default
  #3
Member
 
Marcin
Join Date: Jun 2016
Posts: 98
Rep Power: 10
destroy is on a distinguished road
Thanks for reply,

I read these tutorials but I still had the problem.
The solution that you sent me still doesn't work.
In Fluent output I get (just a fragment):


file read-case-data K:\USERS\mnowak\artykulzautosavemnaprawa\postproce ssing\caseanddatadoanalizy\Fluentmesh14-58-00001.cas.gzsurface plane-surf-aligned ooooo1 Invalid new surface.
outlet2 Invalid new surface.
-0.0291707
Surface name should start with alphabet or underscore.
Setting default name.

I think that the program can't see the interval between two commands. I get this error all the time when trying to solve it - that was the reason why I asked about mulpitle commands in do loop.

Regards
Destroy
destroy is offline   Reply With Quote

Old   November 26, 2017, 23:58
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
(Ti-menu-load-string (format #f "file read-case-data K:\USERS\mnowak\artykulzautosavemnaprawa\postproce ssing\caseanddatadoanalizy\Fluentmesh14-58-0000~a.cas.gz" x))

why do you have space here?

also you may try to use \n at the end of each command, for instance:

Code:
(Ti-menu-load-string (format #f "file read-case-data K:\USERS\mnowak\artykulzautosavemnaprawa\postprocessing\caseanddatadoanalizy\Fluentmesh14-58-0000~a.cas.gz\n" x))
Best regards
destroy likes this.
AlexanderZ is offline   Reply With Quote

Old   November 27, 2017, 03:36
Default
  #5
Member
 
Marcin
Join Date: Jun 2016
Posts: 98
Rep Power: 10
destroy is on a distinguished road
Good point, but - I made a mistake only here, copying code to my query. As I said previously - the code works for the every command, but not all or two commands in the one loop.
The proposed \n doesn't help.

PS The program still can't see the gap between commands - I think that we can focus on that point.

Regards
destroy is offline   Reply With Quote

Old   November 27, 2017, 05:55
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
No, it has nothing to do with 'gap between commands'.

The problem is probably that your surface ooooo1 already exists in the file.
Try deleting it first:

Code:
(Do ((x 1 (+ x 1))) ((> x 100))
(begin
(ti-menu-load-string (format #f "file read-case-data K:\USERS\mnowak\artykulzautosavemnaprawa\postprocessing\caseanddatadoanalizy\Fluentmesh14-58-0000~a.cas.gz" x))
(ti-menu-load-string (format #f "surface plane-surf-aligned delete-surface ooooo~a" x))
(ti-menu-load-string (format #f "surface plane-surf-aligned ooooo~a outlet2 -0.0291707 -0.0056188 0.13" x))
(ti-menu-load-string (format #f "report surface-integrals area-weighted-avg ooooo~a () pressure y pressure1" x))
))
pakk is offline   Reply With Quote

Old   November 27, 2017, 06:01
Default
  #7
Member
 
Marcin
Join Date: Jun 2016
Posts: 98
Rep Power: 10
destroy is on a distinguished road
Unfortunately - doesn't help. The same error as earlier:

"file read-case-data K:\USERS\mnowak\artykulzautosavemnaprawa\postproce ssing\caseanddatadoanalizy\Fluentmesh14-58-00001.cas.gzsurface plane-surf-aligned delete-surface ooooo1surface plane-surf-aligned ooooo1 Invalid new surface.
outlet2 Invalid new surface.
-0.0291707
Surface name should start with alphabet or underscore.
Setting default name.
(...)"
destroy is offline   Reply With Quote

Old   November 27, 2017, 07:34
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Open your file (the first one), and try to add the surface ooooo1 using the text interface. Do you get the same error message?
pakk is offline   Reply With Quote

Old   November 27, 2017, 07:35
Default
  #9
Member
 
Marcin
Join Date: Jun 2016
Posts: 98
Rep Power: 10
destroy is on a distinguished road
I tried. I didn't get any error message.
destroy is offline   Reply With Quote

Old   November 27, 2017, 08:32
Default
  #10
Member
 
Marcin
Join Date: Jun 2016
Posts: 98
Rep Power: 10
destroy is on a distinguished road
I changed the code as:

(Do ((x 1 (+ x 1))) ((> x 3))
(ti-menu-load-string (format #f "file read-case-data K:\USERS\mnowak\artykulzautosavemnaprawa\postproce ssing\caseanddatadoanalizy\Fluentmesh14-58-0000~a.cas.gz" x)) (newline)
;(ti-menu-load-string (format #f "surface delete-surface avyyyzzzzz~a" x)) (newline)
(ti-menu-load-string (format #f "surface plane-surf-aligned avyyyzzzzz~a outlet2 -0.0291707 -0.0056188 0.13" x)) (newline)
(ti-menu-load-string (format #f "report surface-integrals area-weighted-avg avyyyzzzzz~a () pressure y pressure~a" x x)) (newline)
)


It still doesn't work as I wish; firstly, it loads the first case&data (Fluentmesh14-58-00001.cas.gz), then the Fluent TUI output suggest, that the code is OK, but it does not load the next case&data files. The end of the Fluent TUI output is:

(...)

surface plane-surf-aligned avyyyzzzzz1 outlet2 -0.0291707 -0.0056188 0.13
report surface-integrals area-weighted-avg avyyyzzzzz1 () pressure y pressure1
file read-case-data K:\USERS\mnowak\artykulzautosavemnaprawa\postproce ssing\caseanddatadoanalizy\Fluentmesh14-58-00002.cas.gz
surface plane-surf-aligned avyyyzzzzz2 outlet2 -0.0291707 -0.0056188 0.13
report surface-integrals area-weighted-avg avyyyzzzzz2 () pressure y pressure2
file read-case-data K:\USERS\mnowak\artykulzautosavemnaprawa\postproce ssing\caseanddatadoanalizy\Fluentmesh14-58-00003.cas.gz
surface plane-surf-aligned avyyyzzzzz3 outlet2 -0.0291707 -0.0056188 0.13
report surface-integrals area-weighted-avg avyyyzzzzz3 () pressure y pressure3
#f
destroy is offline   Reply With Quote

Old   November 27, 2017, 09:46
Default
  #11
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
I don't know...
pakk is offline   Reply With Quote

Old   November 27, 2017, 22:07
Default
  #12
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Once you use DO and multiple functions inside, you have to use BEGIN.

How do you read journal file? I've never tried it but you may ask fluent to read journal from fluent launcher window.

I believe, once you read new case, everything inside fluent had lost (and journals also) So you need external source to execute journal. However, this is just my thought

Best regards
AlexanderZ is offline   Reply With Quote

Old   November 28, 2017, 10:18
Default
  #13
Member
 
Marcin
Join Date: Jun 2016
Posts: 98
Rep Power: 10
destroy is on a distinguished road
Thank you for all your replies.
The problem was mainly the lack of decision (o - OK, c - cancel) indicating to write or not the changes made by loop (i.e. new surface).

The final makro is:

(Do ((x 1 (+ x 1))) ((> x 9))
(ti-menu-load-string (format #f "file read-case-data K:\USERS\mnowak\artykulzautosavemnaprawa\postproce ssing\caseanddatadoanalizy\Fluentmesh14-58-0000~a.cas.gz o" x)); (newline)
;(ti-menu-load-string (format #f "surface delete-surface iiiii~a" x)) (newline)
(ti-menu-load-string (format #f "surface plane-surf-aligned iiiii~a outlet2 -0.0291707 -0.0056188 0.13" x)) (newline)
(ti-menu-load-string (format #f "report surface-integrals area-weighted-avg iiiii~a () pressure y pressure" x)) (newline)
)

(Do ((x 10 (+ x 1))) ((> x 99))
(ti-menu-load-string (format #f "file read-case-data K:\USERS\mnowak\artykulzautosavemnaprawa\postproce ssing\caseanddatadoanalizy\Fluentmesh14-58-000~a.cas.gz o" x)); (newline)
;(ti-menu-load-string (format #f "surface delete-surface iiiii~a" x)) (newline)
(ti-menu-load-string (format #f "surface plane-surf-aligned iiiii~a outlet2 -0.0291707 -0.0056188 0.13" x)) (newline)
(ti-menu-load-string (format #f "report surface-integrals area-weighted-avg iiiii~a () pressure y pressure" x)) (newline)
)

(Do ((x 100 (+ x 1))) ((> x 110))
(ti-menu-load-string (format #f "file read-case-data K:\USERS\mnowak\artykulzautosavemnaprawa\postproce ssing\caseanddatadoanalizy\Fluentmesh14-58-00~a.cas.gz o" x)); (newline)
;(ti-menu-load-string (format #f "surface delete-surface iiiii~a" x)) (newline)
(ti-menu-load-string (format #f "surface plane-surf-aligned iiiii~a outlet2 -0.0291707 -0.0056188 0.13" x)) (newline)
(ti-menu-load-string (format #f "report surface-integrals area-weighted-avg iiiii~a () pressure y pressure" x)) (newline)
)


PS. I have no idea why in above code the word "postprocessing" seems "postproce ssing" - it's just here, in my code I don't have any gap inside this word. I tried to edit this post but after it still displays "postproce ssing".

Regards
roi247 likes this.
destroy is offline   Reply With Quote

Old   December 1, 2017, 10:30
Default
  #14
Member
 
Marcin
Join Date: Jun 2016
Posts: 98
Rep Power: 10
destroy is on a distinguished road
The code is working fine, but after 72 timesteps I get this error all the time:

Error: sopenoutputfile: unable to open file for output Error Object: "K:\USERS\mnowak\monitory\monitory_files\dp0\FLU\F luent\K:\USERS\mnowak\artykulzautosavemnaprawa\pos tprocessing\caseanddatadoanalizy\Fluentmesh14-58-00073.set"

I found some solutions:
- close and run again Fluent
- open Workbench as administrator
- change the localization of the files
None of them helped.
I ran this macro on other computer, still the same problem.


Have you got any idea, what the problem is? I found that people ask about this error message over the years, and they didn't find the solution many times.
destroy is offline   Reply With Quote

Old   December 4, 2017, 06:53
Default
  #15
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
You have to turn into a detective, and investigate what is the problem.

First clue: Fluent complains that there is a problem with a specific file:Fluentmesh14-58-00073.set. Do you recognize this file? Why is Fluent trying to write this file?

Second clue: It works for 71 time steps, but it fails after 72. What is the difference? Why was there no problem with Fluentmesh14-58-0070.set? Can you find this file? What is in it?

To be clear: I don't know the answer to your problem. But I can see some logical things to investigate.
pakk is offline   Reply With Quote

Old   January 15, 2018, 14:51
Default do loop with journal
  #16
Member
 
Muhammad Ali Uzair
Join Date: Sep 2017
Posts: 44
Rep Power: 9
m.uzair is on a distinguished road
Hi,
I am trying to read data files using do loop (scheme) and then export solution data on a surface using journal. its not working, always giving errors. Can please somebody help what is wrong with it. I am new to scheme programming and journals ..
following is the program

(do ((x 1 (+ x 1))) ((> x 5))
(ti-menu-load-string (format #f "file read-data check-1-000~a0.dat" x))
)

(cx-gui-do cx-activate-item "MenuBar*ExportSubMenu*Solution Data...")
(cx-gui-do cx-set-list-selections "Export*Table1*Table2*DropDownList1(File Type)" '( 1))
(cx-gui-do cx-activate-item "Export*Table1*Table2*DropDownList1(File Type)")
(cx-gui-do cx-set-list-selections "Export*Table1*List4(Surfaces)" '( 2))
(cx-gui-do cx-activate-item "Export*Table1*List4(Surfaces)")
(cx-gui-do cx-set-list-selections "Export*Table1*List5(Quantities)" '( 61))
(cx-gui-do cx-activate-item "Export*Table1*List5(Quantities)")
(cx-gui-do cx-activate-item "Export*PanelButtons*PushButton1(OK)")
(cx-gui-do cx-set-file-dialog-entries "Select File" '( "check-1-000~a0") "ASCII Files ()")
(cx-gui-do cx-activate-item "Export*PanelButtons*PushButton2(Cancel)")


)
m.uzair is offline   Reply With Quote

Old   January 15, 2018, 18:38
Default
  #17
Member
 
Marcin
Join Date: Jun 2016
Posts: 98
Rep Power: 10
destroy is on a distinguished road
I think that you were registering a journal and then you were editing it into that code.
In my opinion if you want to use scheme programming, you have to use commands that you are typing into TUI. Firstly test how to achieve the tasks that you've got, by using TUI, and then write new program.
m.uzair likes this.
destroy is offline   Reply With Quote

Old   January 15, 2018, 21:07
Default
  #18
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
(cx-gui-do cx-set-file-dialog-entries "Select File" '( "check-1-000~a0") "ASCII Files ()")

what is a here?
AlexanderZ is offline   Reply With Quote

Old   January 16, 2018, 06:13
Default
  #19
Member
 
Muhammad Ali Uzair
Join Date: Sep 2017
Posts: 44
Rep Power: 9
m.uzair is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
(cx-gui-do cx-set-file-dialog-entries "Select File" '( "check-1-000~a0") "ASCII Files ()")

what is a here?
the data files are check-1-00010, check-1-00020, check-1-00030 and so on... saved every 10 time steps...
m.uzair is offline   Reply With Quote

Old   January 16, 2018, 06:16
Default
  #20
Member
 
Muhammad Ali Uzair
Join Date: Sep 2017
Posts: 44
Rep Power: 9
m.uzair is on a distinguished road
Quote:
Originally Posted by destroy View Post
I think that you were registering a journal and then you were editing it into that code.
In my opinion if you want to use scheme programming, you have to use commands that you are typing into TUI. Firstly test how to achieve the tasks that you've got, by using TUI, and then write new program.
For my understanding, what you mean is that i export solution data using TUI, and then use scheme programming with the commands of TUI. Am i correct?
m.uzair 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] refineWallLayer Error Yuby OpenFOAM Meshing & Mesh Conversion 2 November 11, 2021 12:04
fluent journal file for carrying out LES raunakjung FLUENT 13 June 7, 2017 11:16
Calculation of Load Carrying capacity of a journal bearing in Fluent Dinesh_Dhande FLUENT 1 June 17, 2015 05:20
Fluent JOURNAL file issue mhsn FLUENT 0 June 5, 2013 13:47
Fluent jobs through pbs ibnkureshi FLUENT 5 June 9, 2011 14:43


All times are GMT -4. The time now is 20:10.