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

Write projected area into variable

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 31, 2020, 03:45
Default Write projected area into variable
  #1
New Member
 
Join Date: Mar 2020
Posts: 2
Rep Power: 0
Aerodynamicist is on a distinguished road
Hello everyone,

I am currently working on a script to fully automate a straight line vehicle CFD-simulation to do quicker design iterations. In order to calculate the coefficients cl and cd correctly I have to automate the task of calculating the projected frontal area of the car onto the x-plane, store it as some kind of variable and access this variable/value when defining the reference values later. I already know how to calculate the value via my script but I fail to assign the single value to a variable for easy access. I have also tried to output the value to a .txt-file that could be read in later but the problem is, that not just the value but additional text is stored in that file making it hard to just access the desired value.

Here is my code so far:


;;OPTION01: WRITE VALUE TO .TXT FILE

;;projected area on x-plane evaluation
(define projectedsurfaces '(wing01 wing02 endplate))
;calculate the projected area on x-plane and write it to .txt file
(with-output-to-file "projectedxarea.txt"
(lambda ()
(ti-menu-load-string "report projected-surface-area projectedsurfaces 0.001 1 0 0")))

;;The output .txt-file will look like this:
;report projected-surface-area projectedsurfaces 0.001 1 0 0
; Area of surfaces (9 8 7 6) projected onto plane (1, 0, 0): 0.00041090155


;;OPTION02: OUTPUT VALUE TO CONSOLE/TUI AND ACCESS FROM HERE(?)
(define projectedsurfaces '(wing01 wing02 endplate))
(ti-menu-load-string "report projected-surface-area projectedsurfaces 0.001 1 0 0")

I only need the value "0.00041090155" to work with.

I will be very grateful for any help. Thank's in advance.

Best regards
Aerodynamicist is offline   Reply With Quote

Old   March 31, 2020, 07:22
Smile Solved it
  #2
New Member
 
Join Date: Mar 2020
Posts: 2
Rep Power: 0
Aerodynamicist is on a distinguished road
Sorry for bothering, I was able to transfer knowledge I collected in other threads. The solution to my problem is as follows:

;variable for projected area on x-plane
(define projectedsurfaces '(wing01 wing02 endplate))

;;define reference values
;area
(define projectedxarea (ti-menu-load-string (format #f "report reference-values area ~a " (pick-a-real "report projected-surface-area projectedsurfaces 0.001 1 0 0")))'int #f)
(display projectedxarea)

It's a combination of the "ti-menu-load-string"-, the "format"- and "pick-a-real"-commands. In the end 'int #f converts the string to an int, which can then be used inside the reference values.

Best regards
Aerodynamicist 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
mesh file for flow over a circular cylinder Ardalan Main CFD Forum 7 December 15, 2020 13:06
Non overlap area fractions saisanthoshm88 CFX 11 September 17, 2015 18:42
Water subcooled boiling Attesz CFX 7 January 5, 2013 03:32
Write the cell area of a patch Andrea_85 OpenFOAM 5 July 27, 2011 08:29
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 20:09


All times are GMT -4. The time now is 08:06.