|
[Sponsors] |
April 14, 2011, 11:11 |
Defining a parameter for UDF
|
#1 |
New Member
Philipp Schapotschnikow
Join Date: Oct 2010
Posts: 11
Rep Power: 16 |
Hi all,
I have a UDF which requires a constant, real parameter. Is there a way to give this parameter a value, without having to modify and recompile the source? Thanks, Philipp |
|
April 15, 2011, 04:56 |
|
#3 |
New Member
Philipp Schapotschnikow
Join Date: Oct 2010
Posts: 11
Rep Power: 16 |
Thanks a lot, Amir!!
Is there a way to check whether a variable (with the given name) has been defined in the TUI? The manual shows how to check this in TUI (which is already quite useful). But I would like to do the same in the UDF, something like int myVar; ... if(isDefined("variable-name") myVar = RP_Get_Integer("variable-name"); else myVar = DefaultValue; |
|
April 15, 2011, 11:59 |
|
#5 |
New Member
Philipp Schapotschnikow
Join Date: Oct 2010
Posts: 11
Rep Power: 16 |
A call RP_Get_Real with an invalid scheme variable name produces a runtime error
|
|
April 18, 2011, 22:23 |
|
#6 | |
Senior Member
Join Date: Feb 2010
Posts: 164
Rep Power: 17 |
Quote:
|
||
April 19, 2011, 05:53 |
|
#7 |
New Member
Philipp Schapotschnikow
Join Date: Oct 2010
Posts: 11
Rep Power: 16 |
I use the following construction
int ret=0; const int default_value; ... ret = (int) CX_Interpret_String("( (if (rp-var-object 'var-name)) (%rpgetvar 'var-name))"); if(!ret) ret = default_value; return ret; The UDF shows correct behaviour, but it returns error messages Error : eval : unbound variable Error object: %rpgetvar These error messages make the execution extremely slow (but do not terminate it!). How can I avoid it? I have no idea of scheme programming, can anyone suggest me how to write a line that does " if variable "var_name" is defined, return 1, else return 0 " |
|
April 19, 2011, 22:28 |
|
#8 | |
Senior Member
Join Date: Feb 2010
Posts: 164
Rep Power: 17 |
Quote:
CX_Interpret_String("(if (rp-var-object 'var-name) (rpgetvar 'var-name)(rpsetvar 'var-name default-value))"); ret=RP_Get_Integer("var-name"); |
||
April 20, 2011, 05:35 |
|
#9 | |
New Member
Philipp Schapotschnikow
Join Date: Oct 2010
Posts: 11
Rep Power: 16 |
Quote:
I also tried CX_Interpret_String("(if (not (rp-var-object 'var-name))(rp-var-define 'var-name default-value 'integer #f))"); ret=RP_Get_Integer("var-name"); but it gives me an error "var-name" undefined variable. I should also mention that I am using a compiled UDF. Can it be that I need to include certain headers that are not present in udf.h? |
||
April 27, 2011, 22:19 |
|
#10 | |
Senior Member
Join Date: Feb 2010
Posts: 164
Rep Power: 17 |
Quote:
CX_Interpret_String("(if (not (rp-var-object 'var-name))(rp-var-define 'var-name -1 'integer #f))"); ret=RP_Get_Integer("var-name"); |
||
May 2, 2011, 12:07 |
|
#11 | |
New Member
Philipp Schapotschnikow
Join Date: Oct 2010
Posts: 11
Rep Power: 16 |
Quote:
Yes, that's what I meant. In the actual code, I have something like CX_Interpret_String("(if (not (rp-var-object 'var-name))(rp-var-define 'var-name -1 'integer #f))"); The error still occurs. |
||
May 2, 2011, 23:32 |
|
#12 |
Senior Member
Join Date: Feb 2010
Posts: 164
Rep Power: 17 |
CX_Interpret_String("(if(not(rp-var-object 'var-name))(rp-var-define 'var-name -1 'integer #f)())");
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Parameter Set Problem /Fluid Flow | Paul_Re | CFX | 0 | December 4, 2010 15:01 |
compile errors of boundary condition "expDirectionMixed" | liying02ts | OpenFOAM Bugs | 2 | February 1, 2010 21:11 |
MAxium residual...confusion with expert parameter | KK | CFX | 3 | February 8, 2008 11:47 |
Expert Parameter for compressible transient | ioannis | CFX | 0 | November 2, 2005 20:28 |
parameter file | CMB | Siemens | 1 | December 15, 2003 10:01 |