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

Retrieve value of Scheme variable in TUI command

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By p.b+cfd

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 8, 2019, 11:49
Default Retrieve value of Scheme variable in TUI command
  #1
New Member
 
Mark Lytell
Join Date: Apr 2019
Location: Chicago area
Posts: 4
Rep Power: 7
lytemar is on a distinguished road
Hi,
I couldn't seem to find an answer to this particular type of problem. So here goes...
In a Fluent Journal, I would like to define a string constant that contains the root name of the case file so that I can use the same string in other TUI commands, e.g., setting the root name for auto-save, etc.. This is what I did:

; define the case/data file name root
(define casedatfileroot "./mdl-name-shell-cond-transient")
; define the case file path
(define casefilepath (string-append casedatfileroot ".cas.gz"))

These variables are defined, but when I try to read in the case file, using this command,

/file/read-case (rpgetvar 'casefilepath)

I get the errors:
Error: File "(rpgetvar" not found!
Error Object: #f
invalid command ['casefilepath)]

This is using Fluent 2019R3. Can someone please help me? The ANSYS documentation is essentially non-existent for this.
lytemar is offline   Reply With Quote

Old   November 8, 2019, 13:59
Default
  #2
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,673
Rep Power: 65
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
Filenames are not evaluated in the text prompt system, they are the only exception.

Quote:
Originally Posted by lytemar View Post
/file/read-case (rpgetvar 'casefilepath)
I get the errors:
Error: File "(rpgetvar" not found!
Error Object: #f
invalid command ['casefilepath)]
Fluent is looking for a file named (rpgetvar because this text is not being evaluated.


Here is a link to the non-existent documentation.
LuckyTran is offline   Reply With Quote

Old   November 8, 2019, 15:29
Default
  #3
New Member
 
Mark Lytell
Join Date: Apr 2019
Location: Chicago area
Posts: 4
Rep Power: 7
lytemar is on a distinguished road
Thanks, so this is not possible? That's a bummer.
lytemar is offline   Reply With Quote

Old   September 18, 2020, 04:19
Default
  #4
New Member
 
Join Date: Sep 2020
Posts: 8
Rep Power: 5
p.b+cfd is on a distinguished road
For the record

First option using scheme variable (only valid during the current session of Fluent):
Code:
(define casedatfileroot "./mdl-name-shell-cond-transient")
(define casefilepath (string-append casedatfileroot ".cas.gz"))

; Quoted
(ti-menu-load-string (format #f "/file/read-case ~s") casefilepath)

; Un-quoted
; (ti-menu-load-string (format #f "/file/read-case ~a") casefilepath)
Second option using rp-variables (will be stored with the case):
Code:
(rp-var-define 'casedatfileroot "./mdl-name-shell-cond-transient" 'string #f)
(rp-var-define 'casefilepath (format #f "~s" (string-append (rpgetvar casedatfileroot) ".cas.gz")) 'string #f)

; Quoted
(ti-menu-load-string (format #f "/file/read-case ~s") (rpgetvar 'casefilepath))
; Un-quoted
; (ti-menu-load-string (format #f "/file/read-case ~a") (rpgetvar 'casefilepath))
To avoid typing these insanely long macros
Code:
(format #f "format string ~s" variable)
(ti-menu-load-string (format #f "format string ~s" variable))
all over the place I'd strongly recommend some global definitions like:
Code:
(define (fmt . args) (apply format (append (list #f) args)))
(define (tui . args) (ti-menu-load-string (apply fmt args)))
With these little macros defined, the first example could be reduced to
Code:
(define casedatfileroot "./mdl-name-shell-cond-transient")
(define casefilepath (string-append casedatfileroot ".cas.gz"))

; Quoted
(tui "/file/read-case ~s" casefilepath)

; Un-quoted
; (tui "/file/read-case ~a" casefilepath)
,

while the second example could be simplified to
Code:
(rp-var-define 'casedatfileroot "./mdl-name-shell-cond-transient" 'string #f)
(rp-var-define 'casefilepath (fmt "~s" (string-append (rpgetvar casedatfileroot) ".cas.gz")) 'string #f)

; Quoted
(tui "/file/read-case ~s" (rpgetvar 'casefilepath))

; Un-quoted
; (tui "/file/read-case ~a" (rpgetvar 'casefilepath))
sfernaferna and zimao like this.
p.b+cfd is offline   Reply With Quote

Old   April 10, 2021, 14:15
Default typo?
  #5
New Member
 
Sócrates Fernández
Join Date: Mar 2020
Location: Cádiz, Spain
Posts: 10
Rep Power: 6
sfernaferna is on a distinguished road
Send a message via Skype™ to sfernaferna
Hi, thanks for your contribution. My first time quoting, I hope to do it correctly.

For me, the format command (rpgetvar option) worked only if I include the (rpgetvar 'variable) inside the parentheses of the format command. I am referring to the lines:

Quote:
Originally Posted by p.b+cfd View Post
Second option using rp-variables (will be stored with the case):

Code:
(rp-var-define 'casedatfileroot "./mdl-name-shell-cond-transient" 'string #f)
(rp-var-define 'casefilepath (format #f "~s" (string-append (rpgetvar casedatfileroot) ".cas.gz")) 'string #f)

; Quoted
(ti-menu-load-string (format #f "/file/read-case ~s") (rpgetvar 'casefilepath))
; Un-quoted
; (ti-menu-load-string (format #f "/file/read-case ~a") (rpgetvar 'casefilepath))

As an example, here are my own commands, where I put the rpgetvar inside the format parenthesis:

Code:
(ti-menu-load-string (format #f "report/dpm-extended-summary yes casename_~a yes no" (rpgetvar 'flow-time)))
DID WORK .

However, the following DID NOT WORK:

Code:
(ti-menu-load-string (format #f "report/dpm-extended-summary yes casename_~a yes no") (rpgetvar 'flow-time))

With the error:
Error: CAR: invalid argument [1]: wrong type [not a pair]
Error Object: ()
Hope it helps! If it was a typo then I'm happy to have helped. If it wasn't I would be very grateful to receive some explanation on why it worked for me.
sfernaferna is offline   Reply With Quote

Old   April 11, 2021, 22:47
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
that was typo
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Reply

Tags
fluent, scheme language, tui command


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
How to save /adjoint/observable/evaluate result to scheme variable? ProBioticum Fluent UDF and Scheme Programming 5 October 8, 2019 08:55
[PyFoam] PyFoam 0.6.9 wrong path to gnuplot klausb OpenFOAM Community Contributions 5 March 15, 2018 14:28
I need help for TUI command ringtail FLUENT 3 September 8, 2010 10:31
error in COMSOL:'ERROR:6164 Duplicate Variable' bhushas COMSOL 1 May 30, 2008 04:35
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 20:09


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