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/)
-   -   F_UDMI problem (http://www.cfd-online.com/Forums/fluent-udf/68259-f_udmi-problem.html)

ivanbuz September 11, 2009 17:20

F_UDMI problem
 
I use the following UDF to calculate time-averaged pressure coefficient on a airfoil surface. the UDF is interpreted with no problem. after a number of time steps, I plot the user defined memory 0 and 1 in XY Plot panal, but everything is zero.

Can anyone tell me why and how to fix it? Thanks for all answers!


-----------------------------------------------
/* be sure to allocate at least two UDMs*/

#include "udf.h"

real n=0; /* number of time-step */
int zone_ID=5; /* zone ID of airfoil surface */

DEFINE_EXECUTE_AT_END(time_avr_PC)
{
Domain *domain = Get_Domain(1);
Thread *t = Lookup_Thread(domain, zone_ID);
real p_ref=0, q_ref=100; /* reference pressures */

face_t f;
n += 1;

begin_f_loop(f, t)
{
F_UDMI(f,t,0) += F_P(f,t);
F_UDMI(f,t,1) = (F_UDMI(f,t,0)/n - p_ref)/q_ref;
}
end_f_loop(f, t)
}
-----------------------------------------------

isabel November 25, 2009 12:43

Thy this function. I hope it works:

#include "udf.h"

real n=0; /* number of time-step */
int zone_ID=5; /* zone ID of airfoil surface */

EXECUTE_ON_DEMAND(time_avr_PC)
{
Domain *domain = Get_Domain(1);
Thread *t ;
real p_ref=0, q_ref=100; /* reference pressures */

face_t f;
n += 1;

begin_f_loop(f, t)
{
F_UDMI(f,t,0) += F_P(f,t);
F_UDMI(f,t,1) = (F_UDMI(f,t,0)/n - p_ref)/q_ref;
}
end_f_loop(f, t)
}


isabel November 25, 2009 12:45

I have used "EXECUTE_ON_DEMAND" instead of "DEFINE_EXECUTE_AT_END"

Kanarya November 30, 2012 11:31

Quote:

Originally Posted by isabel (Post 237705)
I have used "EXECUTE_ON_DEMAND" instead of "DEFINE_EXECUTE_AT_END"

Hi,
it seems like F_UDMI doesnt save anything! value is always "0"!
is there any one who can explain this?
thanks in advance!

Kanarya December 4, 2012 10:19

Quote:

Originally Posted by ivanbuz (Post 229300)
I use the following UDF to calculate time-averaged pressure coefficient on a airfoil surface. the UDF is interpreted with no problem. after a number of time steps, I plot the user defined memory 0 and 1 in XY Plot panal, but everything is zero.

Can anyone tell me why and how to fix it? Thanks for all answers!


-----------------------------------------------
/* be sure to allocate at least two UDMs*/

#include "udf.h"

real n=0; /* number of time-step */
int zone_ID=5; /* zone ID of airfoil surface */

DEFINE_EXECUTE_AT_END(time_avr_PC)
{
Domain *domain = Get_Domain(1);
Thread *t = Lookup_Thread(domain, zone_ID);
real p_ref=0, q_ref=100; /* reference pressures */

face_t f;
n += 1;

begin_f_loop(f, t)
{
F_UDMI(f,t,0) += F_P(f,t);
F_UDMI(f,t,1) = (F_UDMI(f,t,0)/n - p_ref)/q_ref;
}
end_f_loop(f, t)
}
-----------------------------------------------

Hi,
did you find the solution for that because I have the same problem?

thanks in advance!!!

argeus December 4, 2012 17:47

Hi,
please, check this thread. ;)

Kanarya December 4, 2012 19:27

Quote:

Originally Posted by argeus (Post 395787)
Hi,
please, check this thread. ;)

Hi,

Thanks for the Christmas present!!!:DIt is perfect now!!!;)
cheers!

Kanarya January 16, 2013 11:08

Hi again,
I have problem to read the C_UDMI now it is saving but if I use it in F_profile it is always Zero :(
I am simulating gas-solid flow. So I want to save velocity and volume fraction in outlet and then to use it in inlet so I managed to save it with C_UDMI but in inlet everything is zero it seems it doesnt work. here is my inlet profile:
DEFINE_PROFILE(abs_vel,t,i)
{
Domain *d;
cell_t c, c0;
face_t f;
Thread *ct,*t0;

begin_f_loop(f,t)
{

c0 = F_C0(f, t);
t0 = THREAD_T0(t);
if (C_UDMI(c0,t0,2) =0)
F_PROFILE(f,t,i)=0.001;
else
F_PROFILE(f,t,i) = C_UDMI(c0,t0,2);
}
end_f_loop(f,t)
}
thanks for your help!!!

Kanarya January 18, 2013 05:32

Quote:

Originally Posted by argeus (Post 395787)
Hi,
please, check this thread. ;)

Hi Argeus,

I saved massflow rate at outlet and I want to use it like inlet it seems doesnt work. inlet always is zero?

begin_f_loop(f,t)
{
c0 = F_C0(f, t);
t0 = THREAD_T0(t);
mass_flow +=F_FLUX(f,pt[SOLID_PHASE_ID]);
C_UDMI(c0,t0,0)=mass_flow;
}
end_f_loop(f,t)

and my inlet profile is:

DEFINE_PROFILE(B0, t, i)
{ cell_t c0; face_t f; Thread *ct;
begin_f_loop(f, t)
{ c0 = F_C0(f,t); ct = t->t0;
F_PROFILE(f,t,i) = C_UDMI(c0,ct,0); }
end_f_loop(f,t) }

but it doesnt work :(

thanks in advance!!!

Kanarya March 18, 2013 10:02

Hi argeus,

After your help I managed to do the code but it is working only for serial.
i put at the beginning #if !PR_HOST and at the and #ifend but still not working.it seem it saves it but I can not use it in profile function. I try other variations but it seems not trivial.

argeus March 18, 2013 12:17

Hi Kanarya,
Firstly, I totally forgot to response to your previous answer. I apologize. To be honest, this stuff about memory storing ain't something I'm really familiar with..
However, I have two notes regarding the issue you are coping with:
1/ Do you really need to store the data using memory variable? (please clarify the purpose of your udf)
2/ To avoid "maybe" and "seems to be" use the printf function to check the value of each variable.. Then you will be sure what is still OK, and what already not.

And I did not understand this syntax you used: ct = t->t0;

Kanarya March 18, 2013 12:25

thanks for the quick answer!

I need to save the data because I need to keep const. solid mass_flow_rate in the reactor. this is the reason, I save the velocity and volume fraction in outlet and then applying them in the inlet.ct=t->t0 is changing the threat name because I am saving the data in t0 then using in profile different one.
it is working in serial perfect!
do you have any idea why it doesnt work in parallel?
Thanks again!
Quote:

Originally Posted by argeus (Post 414734)
Hi Kanarya,
Firstly, I totally forgot to response to your previous answer. I apologize. To be honest, this stuff about memory storing ain't something I'm really familiar with..
However, I have two notes regarding the issue you are coping with:
1/ Do you really need to store the data using memory variable? (please clarify the purpose of your udf)
2/ To avoid "maybe" and "seems to be" use the printf function to check the value of each variable.. Then you will be sure what is still OK, and what already not.

And I did not understand this syntax you used: ct = t->t0;


argeus March 18, 2013 13:04

I have no idea, why it does not work in parallel. Maybe you can find something about it in the help file. Anyway, I still do not understand why to use the memory variable. You can simply save the desired value into one global variable and the use it in another sub-udf.. What more, once you need to consider the time variable, you can use the time-dependent macros and save the variable in 2-dimensional field..
But maybe I just have bad experience with memory data storing and this is the only right way how to do it.. :)

Kanarya March 18, 2013 13:06

thanks
can you provide me an example?

thanks in advance!
Quote:

Originally Posted by argeus (Post 414749)
I have no idea, why it does not work in parallel. Maybe you can find something about it in the help file. Anyway, I still do not understand why to use the memory variable. You can simply save the desired value into one global variable and the use it in another sub-udf.. What more, once you need to consider the time variable, you can use the time-dependent macros and save the variable in 2-dimensional field..
But maybe I just have bad experience with memory data storing and this is the only right way how to do it.. :)


argeus March 18, 2013 14:55

Well.. I would really try to avoid to use the memory storing of the data (if not necessary)..
you can simply obtain the value for desired variable in a define_adjust macro, calculate whatever you want to and use it in define_profile sub-udf as follows:

Code:

real xxx1;

DEFINE_ADJUST(my_adjust, domain)
{
    Thread *t;
    face_t f;
    int ID = ;
    Domain *domain;
    domain = Get_Domain(1);
    tf = Lookup_Thread(domain,ID);

    thread_loop_f (t,domain)
    {
        begin_f_loop (f,t)
        xxx1+="whatever you want to preserve for define_profile";
        end_f_loop (f,t)
    }
}

DEFINE_PROFILE(my_profile, thread, index)                                         
{
        real x[ND_ND];
        real y;
        face_t f;
        int ID = ;
        Thread *tf;
        Domain *domain;
        domain = Get_Domain(1);
        tf = Lookup_Thread(domain,ID);

        begin_f_loop(f, thread)
                {
                F_CENTROID(x, f, thread);
                y = x[1];

                F_PROFILE(f, thread, index) = XXX1;
                }
        end_f_loop(f,thread)
}

But anyway, seems to be that memory works fine (once it works properly for the serial - unless there are some restrictions for parallel use).
I never did parallel yet, but regarding the manual, I would try following:
1/ include para.h header into your UDF
2/ consider use of this macro: node_to_host_real_2(velocity_s,vol_frac); for instance, the value of velocity_s is already hidden into the F_UDMI(f,t0,2) and thus once node_to_host macro is executed, it does not have an impact to the F_UDMI(f,t0,2). But not sure if I'm right now.
3/ you perform data transfer from node to host and then use the !RP_HOST macro - you exclude the host compute nodes from the calculation..

If I were you, I would just try som combinations of this macros and use the printf function to display the variables to see what's the matter. I never try it, so I'm just guessing..

Kanarya March 18, 2013 19:02

hi aregus,

thanks a lot for help!
I did it without memory storing as you said.but still working only in serial:confused:
do you have any other suggestions?
thanks for valuable help!

Best!

Kanarya
Quote:

Originally Posted by argeus (Post 414781)
Well.. I would really try to avoid to use the memory storing of the data (if not necessary)..
you can simply obtain the value for desired variable in a define_adjust macro, calculate whatever you want to and use it in define_profile sub-udf as follows:

Code:

real xxx1;

DEFINE_ADJUST(my_adjust, domain)
{
    Thread *t;
    face_t f;
    int ID = ;
    Domain *domain;
    domain = Get_Domain(1);
    tf = Lookup_Thread(domain,ID);

    thread_loop_f (t,domain)
    {
        begin_f_loop (f,t)
        xxx1+="whatever you want to preserve for define_profile";
        end_f_loop (f,t)
    }
}

DEFINE_PROFILE(my_profile, thread, index)                                         
{
        real x[ND_ND];
        real y;
        face_t f;
        int ID = ;
        Thread *tf;
        Domain *domain;
        domain = Get_Domain(1);
        tf = Lookup_Thread(domain,ID);

        begin_f_loop(f, thread)
                {
                F_CENTROID(x, f, thread);
                y = x[1];

                F_PROFILE(f, thread, index) = XXX1;
                }
        end_f_loop(f,thread)
}

But anyway, seems to be that memory works fine (once it works properly for the serial - unless there are some restrictions for parallel use).
I never did parallel yet, but regarding the manual, I would try following:
1/ include para.h header into your UDF
2/ consider use of this macro: node_to_host_real_2(velocity_s,vol_frac); for instance, the value of velocity_s is already hidden into the F_UDMI(f,t0,2) and thus once node_to_host macro is executed, it does not have an impact to the F_UDMI(f,t0,2). But not sure if I'm right now.
3/ you perform data transfer from node to host and then use the !RP_HOST macro - you exclude the host compute nodes from the calculation..

If I were you, I would just try som combinations of this macros and use the printf function to display the variables to see what's the matter. I never try it, so I'm just guessing..



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