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 give names to udf memory? (https://www.cfd-online.com/Forums/fluent-udf/152702-how-give-names-udf-memory.html)

sphoenix09 May 7, 2015 01:13

How to give names to udf memory?
 
In the contour plots C_UDMI(c,t,1) shows contours of user defined memory 1.
But I need this macro should display contours of velocity, temperature volume fraction etc.. How to give name to this macro?

Any help would be appreciated

`e` May 7, 2015 01:54

Use the "Set_User_Memory_Name" function with the following format (read the section in the user's guide on User-Defined Memory for details).

Code:

void Set_User_Memory_Name(int i,char *name);

sphoenix09 May 7, 2015 06:49

Thank you.
Can you help me to solve this?

Code:

#include "udf.h"
#include "sg_udms.h"
#include "math.h"
#include "mem.h"
#include "sg.h"
"
DEFINE_ADJUST(temp, d)
{
        #if PARALLEL
        Domain *d;       
       
        real tavg = 0.;
        real tmax = 0.;
        real tmin = 0.;
        real temp,volume,vol_tot;
       
        void Set_User_Memory_Name(int i,char *temp_ratio);
       
        Thread *t;
        cell_t c;
       
       
        d = Get_Domain(1);
        thread_loop_c(t,d)
        {
       
                begin_c_loop(c,t)
                {
                        volume = C_VOLUME(c,t);
                        temp = C_T(c,t);
                        if (temp < tmin || tmin == 0.) tmin = temp;
                        if (temp > tmax || tmax == 0.) tmax = temp;
                        vol_tot += volume;
                        tavg += temp*volume;
                }
                end_c_loop(c,t)
                tavg /= vol_tot;
               
                printf("\n Tmin = %g Tmax = %g Tavg = %g\n",tmin,tmax,tavg);

                begin_c_loop(c,t)
                {
                        temp = C_T(c,t);
                        C_UDMI(c,t,0) = (temp-tmin)/(tmax-tmin);
                        C_UDMI(c,t,temp_ratio)= C_UDMI(c,t,0);
                }
                end_c_loop(c,t)
        }
       
        #endif
}


`e` May 7, 2015 07:55

That's not how you call functions in C. The format I posted above was of the function declaration. Try the following code to call the function:

Code:

Set_User_Memory_Name(0, "temp_ratio");
Also, what are you trying to achieve with this line of code? The variable "temp_ratio" is not declared or initialised as an integer which is what the C_UDMI macro is expecting.

Code:

C_UDMI(c,t,temp_ratio)= C_UDMI(c,t,0);

sphoenix09 May 8, 2015 01:37

I replaced but didn't work.. Can you modify?

Code:

#include "udf.h"
#include "sg_udms.h"
#include "math.h"
#include "mem.h"
#include "sg.h"
"
DEFINE_ADJUST(temp, d)
{
        #if PARALLEL
        Domain *d;       
       
        real tavg = 0.;
        real tmax = 0.;
        real tmin = 0.;
        real temp,volume,vol_tot;
       
        void Set_User_Memory_Name(int i,char *temp_ratio);
       
        Thread *t;
        cell_t c;
       
       
        d = Get_Domain(1);
        thread_loop_c(t,d)
        {
       
                begin_c_loop(c,t)
                {
                        volume = C_VOLUME(c,t);
                        temp = C_T(c,t);
                        if (temp < tmin || tmin == 0.) tmin = temp;
                        if (temp > tmax || tmax == 0.) tmax = temp;
                        vol_tot += volume;
                        tavg += temp*volume;
                }
                end_c_loop(c,t)
                tavg /= vol_tot;
               
                printf("\n Tmin = %g Tmax = %g Tavg = %g\n",tmin,tmax,tavg);

                begin_c_loop(c,t)
                {
                        temp = C_T(c,t);
                        C_UDMI(c,t,0) = (temp-tmin)/(tmax-tmin);
                        Set_User_Memory_Name(0, "temp_ratio");
                       
                }
                end_c_loop(c,t)
        }
       
        #endif
}


`e` May 8, 2015 02:23

You still have the following line in your code...

Code:

void Set_User_Memory_Name(int i,char *temp_ratio);

sphoenix09 May 8, 2015 03:53

Code:

void Set_User_Memory_Name(int i,char *temp_ratio);
Thank you. So Only this line should be removed from the code, isn't it? Is rest all Ok?

pakk May 8, 2015 05:48

Does the code do what you want it to do?
If so, it is ok.

sphoenix09 May 8, 2015 06:01

Thank you

Yes. This is the only code.. Here I need to change inlet conditions, temperature values etc..
Code:

#include "udf.h"
#include "sg_udms.h"
#include "math.h"
#include "mem.h"
#include "sg.h"
"
DEFINE_ADJUST(temp, d)
{
        #if PARALLEL
        Domain *d;       
       
        real tavg = 0.;
        real tmax = 0.;
        real tmin = 0.;
        real temp,volume,vol_tot;
       
        Thread *t;
        cell_t c;
       
       
        d = Get_Domain(1);
        thread_loop_c(t,d)
        {
       
                begin_c_loop(c,t)
                {
                        volume = C_VOLUME(c,t);
                        temp = C_T(c,t);
                        if (temp < tmin || tmin == 0.) tmin = temp;
                        if (temp > tmax || tmax == 0.) tmax = temp;
                        vol_tot += volume;
                        tavg += temp*volume;
                }
                end_c_loop(c,t)
                tavg /= vol_tot;
               
                printf("\n Tmin = %g Tmax = %g Tavg = %g\n",tmin,tmax,tavg);

                begin_c_loop(c,t)
                {
                        temp = C_T(c,t);
                        C_UDMI(c,t,0) = (temp-tmin)/(tmax-tmin);
                        Set_User_Memory_Name(0, "temp_ratio");
                       
                }
                end_c_loop(c,t)
        }
       
        #endif
}

Is it ok now? No need to declare function as mentioned in the Manual?

pakk May 8, 2015 07:13

Quote:

Originally Posted by sphoenix09 (Post 545568)
Thank you

Yes. This is the only code.. Here I need to change inlet conditions, temperature values etc..
Code:

#include "udf.h"
#include "sg_udms.h"
#include "math.h"
#include "mem.h"
#include "sg.h"
"
DEFINE_ADJUST(temp, d)
{
        #if PARALLEL
        Domain *d;       
       
        real tavg = 0.;
        real tmax = 0.;
        real tmin = 0.;
        real temp,volume,vol_tot;
       
        Thread *t;
        cell_t c;
       
       
        d = Get_Domain(1);
        thread_loop_c(t,d)
        {
       
                begin_c_loop(c,t)
                {
                        volume = C_VOLUME(c,t);
                        temp = C_T(c,t);
                        if (temp < tmin || tmin == 0.) tmin = temp;
                        if (temp > tmax || tmax == 0.) tmax = temp;
                        vol_tot += volume;
                        tavg += temp*volume;
                }
                end_c_loop(c,t)
                tavg /= vol_tot;
               
                printf("\n Tmin = %g Tmax = %g Tavg = %g\n",tmin,tmax,tavg);

                begin_c_loop(c,t)
                {
                        temp = C_T(c,t);
                        C_UDMI(c,t,0) = (temp-tmin)/(tmax-tmin);
                        Set_User_Memory_Name(0, "temp_ratio");
                       
                }
                end_c_loop(c,t)
        }
       
        #endif
}

Is it ok now? No need to declare function as mentioned in the Manual?

What do you mean with "ok"?

Do you want to know if it compiles? Try it.
Do you want to know if it does what you want it to do? I don't know, because I don't know what you want it to do.

And what do you mean with "declare function as mentioned in the Manual"? Which part of the manual are you referring to?

I only have one remark. One thing your code does, is set the name "temp_ratio" to UDM0 many times, where one time is enough. You don't have to put that in the loop, so you can make your code more efficient by putting that line somewhere else.

sphoenix09 May 10, 2015 08:13

Thank you. I just needed the name of that udm-0 in the contour menu. I got it thank you very much.

sphoenix09 May 10, 2015 08:50

I have one more doubt. Can this udm be read in CFX post?

`e` May 10, 2015 17:46

UDM values can be visualised in CFD-Post. Ensure you have saved these values via File > Data File Quantities...

sphoenix09 May 10, 2015 23:59

Quote:

Originally Posted by `e` (Post 545783)
UDM values can be visualised in CFD-Post. Ensure you have saved these values via File > Data File Quantities...

Thank you... I visualized in CFD-Post..

shivakumar May 11, 2015 06:01

Hi,
Have you read this udm in techplot?


All times are GMT -4. The time now is 02:32.