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/)
-   -   Question about C_UDMI and F_UDMI and How to define the gradient of a UDM? (https://www.cfd-online.com/Forums/fluent-udf/153161-question-about-c_udmi-f_udmi-how-define-gradient-udm.html)

aestas May 19, 2015 03:52

Question about C_UDMI and F_UDMI and How to define the gradient of a UDM?
 
Hello friends, I found a way to define the gradient of any quantities by UDS in fluent UDF manual:
DEFINE_ADJUST(adjust_gradient, domain)
{
Thread *t;
cell_t c;
face_t f;
domain = Get_Domain(domain_ID);
/* Fill UDS with the variable. */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDSI(c,t,0) = C_VOF(c,t);
}
end_c_loop (c,t)
}
thread_loop_f (t,domain)
{
if (THREAD_STORAGE(t,SV_UDS_I(0))!=NULL)
begin_f_loop (f,t)
{
F_UDSI(f,t,0) = F_VOF(f,t);
}
end_f_loop (f,t)
}
}

Then the gradient would be C_UDSI_G(c,t,0)
Question is,
1. In my UDF, sometimes I need both the cell value and face value of the same UDM I am confused whether if C_UDMI(c,t,0) and F_UDMI(c,t,0) could be defined at the same time in DEFINE_ADJUST MACRO?
2. As the example above shows, to define the gradient of a variable by C_UDSI_G(c,t,0), the UDF defined both cell values and face values of UDS, instead of just cell value, why?Does this matter?
3.If want to define a gradient of UDM 0, should I first both define the value of C_UDMI(c,t,0) and F_UDMI(c,t,0) , and then let
C_UDSI(c,t,0) = C_UDMI(c,t,0);
F_UDSI(f,t,0) = F_UDMI(c,t,0);
Is this necessary?
Or I just have to let C_UDSI(c,t,0) = C_UDMI(c,t,0) and ignore the face value of UDS?

CFDYourself May 22, 2015 06:34

Hi, I'm just a beginner myself, so please take my advice with a pinch of salt.

My understanding is that user-defined scalars and user defined memory are two different things.

User defined memory is stores a new value in every cell in the model. but this is just an artibary value in the cell. but these values are not subject to the generalised transport equation - they don't experience diffusion, convection etc. the values just "sit there" in the cell, like a cell in an excel spreadsheet.

User defined scalars are also stored as a new value in the every cell like user defined memory, but unlike user-defined memory they are also subject to a generalised transport equation.

I'm suggesting this could be the source of your problem - getting user-defined memory and user-defined scalars confused ?

aestas May 22, 2015 06:43

Thanks for your replay, my friend.
I can understand the difference between UDS and UDM.
In fluent, the gradient of a UDS could be calculated and used by C_UDSI_G,but there is no such way for UDM. I am trying to use UDS to calculate the gradient of any varibles and to use it in my UDF(by only assign the value to UDS in UDF but not solve the uds equation in fluent.).

NOW, I have found that the face vaule of the UDS should also be assigned. If not, the gradient value, especially near and at the boundary would be wrong.

Quote:

Originally Posted by CFDYourself (Post 547303)
Hi, I'm just a beginner myself, so please take my advice with a pinch of salt.

My understanding is that user-defined scalars and user defined memory are two different things.

User defined memory is stores a new value in every cell in the model. but this is just an artibary value in the cell. but these values are not subject to the generalised transport equation - they don't experience diffusion, convection etc. the values just "sit there" in the cell, like a cell in an excel spreadsheet.

User defined scalars are also stored as a new value in the every cell like user defined memory, but unlike user-defined memory they are also subject to a generalised transport equation.

I'm suggesting this could be the source of your problem - getting user-defined memory and user-defined scalars confused ?


tejasvikrishna May 11, 2018 11:55

Hi,

I am having the same trouble. I need to be able to find a bunch of gradients of variables too?
Did you resolve this problem?

annan May 14, 2018 10:50

Hi tejasvikrishna,
Have you tried writing a UDF where you define a UDS for each variable you want to calculate the gradient for, and then use C_UDSI_G or C_UDSI_RG of each defined UDS ?
regards,
Annan


All times are GMT -4. The time now is 11:53.