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

Add or subtract two variables in TUI

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By AlexanderZ
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 16, 2017, 09:30
Default Add or subtract two variables in TUI
  #1
Member
 
Tarantino
Join Date: Feb 2013
Posts: 46
Rep Power: 13
Tarantino is on a distinguished road
Hello all

I want to do a simple math in TUI as the following:

Code:
(define a pick-a-real "report surface-integrals volume-flow-rate bc1 ,,")
(define b pick-a-real "report surface-integrals volume-flow-rate bc2 ,,")

(- a b)

and I got this error:

Error: - (subtract): invalid argument [1]: wrong type [not a number]
Error Object: #[compound-procedure]



I tried also:

Code:
(rpsetvar 'x (pick-a-real "report surface-integrals volume-flow-rate bc1 ,,"))
(rpsetvar 'y (pick-a-real "report surface-integrals volume-flow-rate bc2 ,,"))

(- x y)

and I got this error:

Error: eval: unbound variable
Error Object: x


Anyone know what is the problem and how can I fix it?
Thanks.
Tarantino is offline   Reply With Quote

Old   October 16, 2017, 20:26
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
Hello,
you may try this approach
Code:
(define (make-new-rpvar name default type)
	(if (not (rp-var-object name))
	(rp-var-define name default type #f)))  ; function for creation new variables
(make-new-rpvar 'x 0.0 'real) ;define new variable x
(rpsetvar 'x (pick-a-real "report surface-integrals volume-flow-rate p ,,")) ; set x value
(rpgetvar 'x) ; get x value
Hope it works.

Best regards
Tarantino likes this.
AlexanderZ is offline   Reply With Quote

Old   October 16, 2017, 22:20
Default
  #3
Member
 
Tarantino
Join Date: Feb 2013
Posts: 46
Rep Power: 13
Tarantino is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
Hello,
you may try this approach
Code:
(define (make-new-rpvar name default type)
	(if (not (rp-var-object name))
	(rp-var-define name default type #f)))  ; function for creation new variables
(make-new-rpvar 'x 0.0 'real) ;define new variable x
(rpsetvar 'x (pick-a-real "report surface-integrals volume-flow-rate p ,,")) ; set x value
(rpgetvar 'x) ; get x value
Hope it works.

Best regards

Hi, thanks for your reply.
I think you misunderstood my question.
I successfully define the variables, but cannot do the math on those variables!
You explain how ca I define variable "x" and assign the volume flow rate of a BC to it. There is no problem in this section.
However, how to add a number to "x" for instance. Why
(+ x 2) won't work!
Tarantino is offline   Reply With Quote

Old   October 17, 2017, 00:36
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
Quote:
Originally Posted by Tarantino View Post
Hi, thanks for your reply.
I think you misunderstood my question.
I successfully define the variables, but cannot do the math on those variables!
You explain how ca I define variable "x" and assign the volume flow rate of a BC to it. There is no problem in this section.
However, how to add a number to "x" for instance. Why
(+ x 2) won't work!
If you want for instance x+2 you may use this expression

Code:
(rpsetvar 'x (+ (rpgetvar 'x) 2))
(rpgetvar 'x)
you will see x+2 in console output.

Best regards
Tarantino likes this.
AlexanderZ is offline   Reply With Quote

Old   October 17, 2017, 12:36
Default
  #5
Member
 
Tarantino
Join Date: Feb 2013
Posts: 46
Rep Power: 13
Tarantino is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
If you want for instance x+2 you may use this expression

Code:
(rpsetvar 'x (+ (rpgetvar 'x) 2))
(rpgetvar 'x)
you will see x+2 in console output.

Best regards
This works fine.
Thank you so much.
Tarantino 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
How to add a new variable in the list of variables for MESH ADAPTATION ?? Tramery CFX 3 September 28, 2011 10:27
diffusion Term for add. Variable Zaktatir CFX 9 July 16, 2011 09:51
How to limit a variable ash OpenFOAM Running, Solving & CFD 1 June 26, 2008 20:32
Problem in installation of OpenFOAM sachin OpenFOAM Installation 7 January 22, 2008 01:40
Env variable not set gruber2 OpenFOAM Installation 5 December 30, 2005 04:27


All times are GMT -4. The time now is 17:05.