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/)
-   -   Case filename variable (https://www.cfd-online.com/Forums/fluent-udf/76056-case-filename-variable.html)

eshimshi May 12, 2010 16:13

Case filename variable
 
Is there a variable containing the name and path of the current loaded case?
Can it be retrived by UDF or scheme?

Thanks

gearboy May 13, 2010 02:35

Quote:

Originally Posted by eshimshi (Post 258544)
Is there a variable containing the name and path of the current loaded case?
Can it be retrived by UDF or scheme?

Thanks

Scheme to get the full-path case name:
(in-package cl-file-package rc-filename)
Scheme to get the case name:
(strip-directory (in-package cl-file-package rc-filename))

If you want to use them in UDF, just use CX_Interpret_String command to let them recognized by UDF. i.e.,
CX_Interpret_String("(in-package cl-file-package rc-filename)");
CX_Interpret_String("(strip-directory (in-package cl-file-package rc-filename))");

gearboy May 13, 2010 02:45

Quote:

Originally Posted by gearboy (Post 258590)
Scheme to get the full-path case name:
(in-package cl-file-package rc-filename)
Scheme to get the case name:
(strip-directory (in-package cl-file-package rc-filename))

If you want to use them in UDF, just use CX_Interpret_String command to let them recognized by UDF. i.e.,
CX_Interpret_String("(in-package cl-file-package rc-filename)");
CX_Interpret_String("(strip-directory (in-package cl-file-package rc-filename))");

scheme just get the path:
(directory (in-package cl-file-package rc-filename))

eshimshi May 14, 2010 07:38

Thanks for the help,

eshimshi May 14, 2010 08:17

it woks fine for scheme but in the UDF i get an Unbound variable erorr.
Do I have to add some #include file?

gearboy May 17, 2010 00:46

Quote:

Originally Posted by eshimshi (Post 258778)
it woks fine for scheme but in the UDF i get an Unbound variable erorr.
Do I have to add some #include file?

It seems that the CX_Interpret_String can't Interpret in-package command.

Another choice:
write the scheme command in a scm file, e.g. D:\test.scm. Write two commands in it.

(if(not(rp-var-object 'file-name))(rp-var-define 'file-name "" 'string #f) "")
(rpsetvar 'file-name (in-package cl-file-package rc-filename))
Then in your UDF code.

char*FileName;
CX_Interpret_String("(ti-read-scheme \"D:\\test.scm\")");
FileName=RP_Get_String("file-name");
Message0("Current case name is %s\n",FileName);


All times are GMT -4. The time now is 09:24.