CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   Trouble setting user scalar and user memory names (http://www.cfd-online.com/Forums/fluent/67159-trouble-setting-user-scalar-user-memory-names.html)

tstorm August 5, 2009 18:10

Trouble setting user scalar and user memory names
 
I'm trying to change the names of user-defined scalars and user-defined memory, but it isn't working. I have the following code at the end of my UDF, but it doesn't seem to change the names of the variables in FLUENT (they still show up as uds-0, uds-1, etc.)

What's wrong?

DEFINE_EXECUTE_ON_LOADING(rename_UDvars, libname)
{
Set_User_Scalar_Name(0,"UDS0: k");
Set_User_Scalar_Name(1,"UDS1: e");
Set_User_Scalar_Name(2,"UDS2: v2");
Set_User_Scalar_Name(3,"UDS3: f");
Set_User_Scalar_Name(4,"UDS4: Rxx");
Set_User_Scalar_Name(5,"UDS5: Ryy");
Set_User_Scalar_Name(6,"UDS6: Rzz");
Set_User_Scalar_Name(7,"UDS7: Rxy");
Set_User_Memory_Name(0,"UDM0: Turbulent viscosity");
Set_User_Memory_Name(1,"UDM1: Turbulent time scale");
Set_User_Memory_Name(2,"UDM2: Turbulent length scale");
Set_User_Memory_Name(3,"UDM3: mu_t*StrainRate");
}

Daniel Tanner August 6, 2009 06:02

I tried this before and had problems. I found that if I changed the UDM and UDS memories to zero and press ok and then change them back to 7 UDS's memories and 4 UDM's the names will be there. I found this painful so I just didn't use it.

Let me know how it goes!

tstorm August 6, 2009 10:21

I tried setting the number of UDMs and UDSs to 4 and 8, then setting them both to 0, then back to 4 and 8 - they're still showing up as uds-0, uds-1, etc. So that didn't work. Thanks for the idea though.
Any other ideas?

tstorm August 6, 2009 10:35

Nevermind, I worked it out. Thanks for your help.

I used a DEFINE_ON_DEMAND command rather than DEFINE_EXECUTE_ON_LOADING. I executed the code after loading the rest of the UDF. This code works:

DEFINE_ON_DEMAND(rename_UDvars)
{
Set_User_Scalar_Name(0,"UDS0: k");
Set_User_Scalar_Name(1,"UDS1: e");
Set_User_Scalar_Name(2,"UDS2: v2");
Set_User_Scalar_Name(3,"UDS3: f");
Set_User_Scalar_Name(4,"UDS4: Rxx");
Set_User_Scalar_Name(5,"UDS5: Ryy");
Set_User_Scalar_Name(6,"UDS6: Rzz");
Set_User_Scalar_Name(7,"UDS7: Rxy");
Set_User_Memory_Name(0,"UDM0: Turbulent viscosity");
Set_User_Memory_Name(1,"UDM1: Turbulent time scale");
Set_User_Memory_Name(2,"UDM2: Turbulent length scale");
Set_User_Memory_Name(3,"UDM3: mu_t*StrainRate");

}

tschump August 6, 2009 14:38

There is a "bug" related to the rename macros used in EXECUTE_ON_LOADING macros, so you'll better use those in other macros, like EXECUTE_ON_DEMAND.

cinwendy April 19, 2013 01:45

Thank you very much for the post. I am trying to rename my UDS. I am already using DEFINE_ON_DEMAND, but I get the following error:

..\..\src\DEFINE_ON_DEMAND.c(5) : error C2065: '"Si"' : undeclared identifier
..\..\src\DEFINE_ON_DEMAND.c(5) : warning C4047: 'function' : 'char *' differs in levels of indirection from 'int'
..\..\src\DEFINE_ON_DEMAND.c(5) : warning C4024: 'Set_User_Scalar_Name' : different types for formal and actual parameter 2
..\..\src\DEFINE_ON_DEMAND.c(6) : error C2065: '"Ss"' : undeclared identifier
..\..\src\DEFINE_ON_DEMAND.c(6) : warning C4047: 'function' : 'char *' differs in levels of indirection from 'int'
..\..\src\DEFINE_ON_DEMAND.c(6) : warning C4024: 'Set_User_Scalar_Name' : different types for formal and actual parameter 2

...(continue for the rest of the course file)


My source file looks like this:
#include "udf.h"
#include "sg_udms.h"
DEFINE_ON_DEMAND(rename_UDS)
{
Set_User_Scalar_Name(0,”Si”);
Set_User_Scalar_Name(1,”Ss”);
....(similarly for other UDS)...
}

I can, however interpret or compile other UDF without error. May I know how to fix this?

Thanks!


All times are GMT -4. The time now is 22:17.