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

How to get a value from a data file bound to a variable in Scheme?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   August 24, 2011, 14:05
Default How to get a value from a data file bound to a variable in Scheme?
  #1
New Member
 
Alexander M
Join Date: Aug 2011
Location: Germany
Posts: 5
Rep Power: 5
Shirock is on a distinguished road
Hello everyone,

I am a student from Germany and have the following problem.

During the simulation Fluent is writing the current of each iteration into a data file "I_anode.out".
I now want the value back into scheme to be able to do some calculations with it and feed Fluent a new mass-flow-rate befor the next iteration step.

I have found a an example how to read values back into scheme by Mirko Javurek and changed it for my purpose.

(let
((p (open-input-file "I_anode.out")))
(do
((x (read p) (read p)))
(
(or (number? x) (eof-object? x))
(close-input-port p)
(if (number? x) x #f)
)
)
)


The problem is that only the number is shown in the TUI and I do not have a variable to do calculations with. I tried a few ideas myself but was not able to bind the current value to a variable.

I would really appreciate if someone could help me to rewrite the program so I could to do some further calculations.

Thank you for your help!
Alexander
Shirock is offline   Reply With Quote

Old   August 30, 2011, 08:21
Default
  #2
Member
 
fox000002's Avatar
 
Join Date: Apr 2009
Posts: 46
Rep Power: 7
fox000002 is on a distinguished road
Code:
(define read-data-from-file
(lambda (fn)
(let 
    ((p (open-input-file "I_anode.out")))
    (do 
        ((x (read p) (read p))) 
        (
            (or (number? x) (eof-object? x)) 
            (close-input-port p)      
            (if (number? x) x #f)
        )
    )
)
)
)

(define your-var (read-data-from-file "I_anode.out"))
fox000002 is offline   Reply With Quote

Old   August 31, 2011, 06:04
Default
  #3
New Member
 
Alexander M
Join Date: Aug 2011
Location: Germany
Posts: 5
Rep Power: 5
Shirock is on a distinguished road
Thank you very much!
Shirock is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenFOAM 1.7.1 installation problem on OpenSUSE 11.3 flakid OpenFOAM Installation 16 December 28, 2010 09:48
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51
Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Native Meshers: blockMesh 10 April 2, 2007 14:00
Results saving in CFD hawk Main CFD Forum 16 July 21, 2005 20:51
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 21:09


All times are GMT -4. The time now is 03:01.