CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Get residual in UDF (http://www.cfd-online.com/Forums/fluent-udf/105934-get-residual-udf.html)

Magneto August 13, 2012 13:52

Get residual in UDF
 
Hi, does anyone know if there's a way to access the most recent residual values in define macros? I'm trying to write an Execute at End macro that checks whether the solution is properly converged or is just moving on to the next time step after reaching its maximum number of iterations.

Thanks!

H.R.D. June 21, 2016 03:59

Hi,
I am seeking for the same thing!
did you find any way?

Bruno Machado June 21, 2016 05:55

Quote:

Originally Posted by H.R.D. (Post 605851)
Hi,
I am seeking for the same thing!
did you find any way?

This is a piece of a code I found on internet. You can use rpsetvar and rpgetvar to obtain the

Code:

(let ((old-rc client-read-case))
(set! client-read-case
(lambda args
(apply old-rc args)
(if (cx-gui?)
(begin
;; Do your customization here
(rpsetvar 'residuals/plot? #t)
(rpsetvar 'residuals/settings '(
(continuity #t 0 #f 0.001)
(x-velocity #t 0 #f 0.001)
(y-velocity #t 0 #f 0.001)
(z-velocity #t 0 #f 0.001)
(energy #t 0 #f 1e-06)
(k #t 0 #f 0.001)
(epsilon #t 0 #f 0.001)))
(rpsetvar 'mom/relax 0.4)
(rpsetvar 'pressure/relax 0.5)
(rpsetvar 'realizable-epsilon? #t)
(cxsetvar 'vector/style "arrow")
;; You can add more settings here

make couple of test and you can solve your problem.

H.R.D. June 22, 2016 20:04

Quote:

Originally Posted by Bruno Machado (Post 605870)
This is a piece of a code I found on internet. You can use rpsetvar and rpgetvar to obtain the

Code:

(let ((old-rc client-read-case))
(set! client-read-case
(lambda args
(apply old-rc args)
(if (cx-gui?)
(begin
;; Do your customization here
(rpsetvar 'residuals/plot? #t)
(rpsetvar 'residuals/settings '(
(continuity #t 0 #f 0.001)
(x-velocity #t 0 #f 0.001)
(y-velocity #t 0 #f 0.001)
(z-velocity #t 0 #f 0.001)
(energy #t 0 #f 1e-06)
(k #t 0 #f 0.001)
(epsilon #t 0 #f 0.001)))
(rpsetvar 'mom/relax 0.4)
(rpsetvar 'pressure/relax 0.5)
(rpsetvar 'realizable-epsilon? #t)
(cxsetvar 'vector/style "arrow")
;; You can add more settings here

make couple of test and you can solve your problem.

Thanks for your reply. :)

Do you think there might be any UDF-way? Because I am not good much at Scheme Programming.

Bruno Machado June 23, 2016 08:39

Quote:

Originally Posted by H.R.D. (Post 606160)
Thanks for your reply. :)

Do you think there might be any UDF-way? Because I am not good much at Scheme Programming.

I dont think there is any macro to use directly in your UDF. What you can do is look if there is a RP variable for the scalar, then you can read the variable in your udf by using

RP_Get_Integer("XXXXXXXXXX")
RP_Get_Double("XXXXXXXXXX")
RP_Get_Real("XXXXXXXXXX")

H.R.D. June 23, 2016 17:05

Thanks a lot! :)


All times are GMT -4. The time now is 23:51.