CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   How to repeat to read the same case without saving case and data file? (https://www.cfd-online.com/Forums/fluent-udf/109622-how-repeat-read-same-case-without-saving-case-data-file.html)

lcg44 November 22, 2012 00:54

How to repeat to read the same case without saving case and data file?
 
Hi, everyone.
I'm trying to do a loop. The velocity of dynamic mesh is adjusted every time step. If the result is not good enough then I need to read the case and data of last good result again to let the mesh back to the beginning of this time step. If the result is good enough then the date and case will be saved.I write a scheme file as following. But the problem is it doesn't read the case again when it has been read. It only calculate 5 step (as I set x max value is 5) after a case file is read in, which means the mesh has kept moving during the 5 steps. It is not I want.
Can you help me to find the problem?

Thank you very much.



yours,
Chenguang
(rp-var-define 'mlcg 1.0 'real #f)
(rp-var-define 'klcg 0.0 'real #f)
(rp-var-define 'nlcg 0.0 'real #f)
(rp-var-define 'setao 1.57 'real #f)
(rp-var-define 'omegao 0.0 'real #f)
(rp-var-define 'domegao 0.0 'real #f)
(rp-var-define 'mo 0.0 'real #f)
(define x 1)
(define y 0)
(format #f "heartvalve~03d~03d" y x)
(do ((x 1 (+ x 1)) ) ((> x 5))
(format #f "heartvalve~03d~03d" y x)
(ti-menu-load-string (format #f "file/read-case-data heartvalve~03d" y))
(ti-menu-load-string "solve/set/time-step 0.00245")
(ti-menu-load-string "solve/dual-time-iterate 1")
(ti-menu-load-string "file/write-case-data heartvalveo")
(if (> (rpgetvar 'mlcg) 0)
(begin
(set! y (+ y 1))
(ti-menu-load-string (format #f "file/write-case-data heartvalve~03d" y)))))

lcg44 November 22, 2012 01:30

RP variables are initialed everytime
 
Hi, everyone. I add a save command at the end of every time step. Then it can read the case again every time.
But I found these RP variables are initialed every time? Why?
I didn't put the define and initial command in the loop.

Please help me.


yours,
Chenguang

lcg44 November 22, 2012 02:13

RP variables are defined in case file
 
Now I understand RP variables are defined and saved in case file. Its value are different depending on different cases like pressure, velocity. Is that right?

So my problem is more difficult. Which kind of variables can exist along the FLUENT and keep the stored value until its value is changed. If there is not such kind of variables ,than I can write them to a data file and read them at the beginning of next step.

Is there any better way? I hope somebody can help me.


your,
Chenguang

lcg44 November 22, 2012 02:34

How to transfer the value from a Rp variable to a global variable?
 
How to transfer the value from a Rp variable to a global variable?
And from a global variable to a Rp variable?
Anyone can give me an answer?
Thank you very much.

lcg44 November 22, 2012 10:45

Hi, now I add these transfers between rp variables and global variables as following. But there is an error:
Error: %prf-set-var: invalid flonum
Error Object: #[compound-procedure]
what's the problem?

(rp-var-define 'mlcg 0 'real #f)
(rp-var-define 'klcg 0 'real #f)
(rp-var-define 'nlcg 0 'real #f)
(rp-var-define 'setao 0 'real #f)
(rp-var-define 'omegao 0 'real #f)
(rp-var-define 'domegao 0 'real #f)
(rp-var-define 'mo 0 'real #f)
(define x 1)
(define y 0)
(define mg 0)
(define kg 0)
(define ng 0)
(define setag 1.57)
(define omegag 0)
(define domegag 0)
(define mog 0)
(do ((x 1 (+ x 1)) ) ((> x 5))
(ti-menu-load-string (format #f "file/read-case-data heartvalve~05d" y))
(rpsetvar'mlcg mg)
(rpsetvar 'klcg kg)
(rpsetvar 'nlcg ng)
(rpsetvar 'setao setag)
(rpsetvar 'omegao omegag)
(rpsetvar 'domegao domegag)
(rpsetvar 'mo mog)
(ti-menu-load-string "solve/set/time-step 0.00245")
(ti-menu-load-string "solve/dual-time-iterate 1")
(set! mg rpgetvar('mlcg))
(set! kg rpgetvar('klcg))
(set! ng rpgetvar('nlcg))
(set! setag rpgetvar('setao))
(set! omegag rpgetvar('omegao))
(set! domegag rpgetvar('domegao))
(set! mog rpgetvar('mo))
(ti-menu-load-string (format #f "file/write-case-data heartvalve~07d" x))
(if (> (rpgetvar 'mlcg) 0)
(begin
(set! y (+ y 1))
(ti-menu-load-string (format #f "file/write-case-data heartvalve~05d" y)))))


All times are GMT -4. The time now is 12:44.