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

How to do a counter to exit loop in scheme language?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 22, 2013, 08:20
Default How to do a counter to exit loop in scheme language?
  #1
New Member
 
rayolau
Join Date: Aug 2012
Posts: 23
Rep Power: 14
rayolau is on a distinguished road
Hi all! I need help with this code scheme.

I want that in each iteration, Fluid expected to create a profile (1.prof), and then, when there is this file, read the file 1.prof, and got on a correct boundary condition. After this, another profile is deleted.

At the moment, my code wait 1.prof file creation, and when this file exists, read 1.prof profile and put in the boundary condition I want. However, this process is repeated again and again and never get to clear another profile and continue to the next iteration.

To make the wait for the file to each iteration, I put the file.smc as a command that repeats at each iteration.

Does anyone know how to make a counter waiting for the profile creation 1.prof repeat x times, then leave the "loop"?


Thanks in advance =)
My scheme code is this:
Code:
(define nit 1)
(let loop ()

    ; to continue, must exist profile 1.prof
(if (file-exists? "C:\path\1.prof") (ti-menu-load-string "file read-profile C:\path\1.prof"))
	
;if file exists --> put the profile in the bc
(if (file-exists? "C:\path\1.prof") (ti-menu-load-string "define/boundary-conditions/...""))  ; set profile in bc
(if (file-exists? "C:\path\1.prof") (set! nit (+ nit 1)))  ; counter
(cx-pause 1)
(loop))

;delete other profile
(if (file-exists? ""C:\path\5.prof") (system "del C:\path\5.prof"))  ;
rayolau is offline   Reply With Quote

Old   May 23, 2013, 09:15
Default
  #2
Member
 
fox000002's Avatar
 
Join Date: Apr 2009
Posts: 46
Rep Power: 17
fox000002 is on a distinguished road
You can add an if-condition to your tail recursion.

Code:
(let loop ()
  ; ...
  (if (< nit 10)
    (begin
       (cx-pause 1)
       (loop))))
fox000002 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
[Gmsh] Problem with Gmsh nishant_hull OpenFOAM Meshing & Mesh Conversion 23 August 5, 2015 03:09
[CAD formats] my stl surface is seen as just a line rcastilla OpenFOAM Meshing & Mesh Conversion 2 January 6, 2010 02:30
Scheme lprogramming language question Hendawi FLUENT 2 October 3, 2008 04:15
NACA0012 geometry/design software needed Franny Main CFD Forum 13 July 7, 2007 16:57
FLUENT scheme language Luca FLUENT 2 October 21, 2004 05:51


All times are GMT -4. The time now is 16:40.