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/)
-   -   store and access the value in UDM (https://www.cfd-online.com/Forums/fluent-udf/184743-store-access-value-udm.html)

serene6390 March 9, 2017 17:50

store and access the value in UDM
 
Hi,

I have a question about using UDM to store a single value and then retrieve it to do other calculation.

so far from all the manual and examples I could read, people always use UDM to store an array, e.g. store the Temperature of each cell on a wall. the code will be like:

begin_f_loop(c,t)
{
C_UDMI(c,t,0)=C_T(c,t);
}
end_f_loop(c,t)

Now, I'm trying to store a single value calculated from my code, and then in another code I might need to use it.

If I do this,

begin_f_loop(c,t)
{
C_UDMI(c,t,0)=h;
}
end_f_loop(c,t)

the value of h will be stored in every cell on the wall. But what if I need to use the value stored in UDM_0 in another code? How can I retrieve it?

It doesn't work if I simply use the value of h in the other code without storing it in UDM. Because if I stop the calculation and write the data, value of h won't be saved. When I read the data, I'm not able to use the value of h again. That's why I have to store it in UDM and then retrieve it.

Anyone could help me with that? I really appreciate that. I tried a long time but still couldn't make it.

pakk March 13, 2017 06:00

Quote:

Originally Posted by serene6390 (Post 640213)
Hi,

I have a question about using UDM to store a single value and then retrieve it to do other calculation.

so far from all the manual and examples I could read, people always use UDM to store an array, e.g. store the Temperature of each cell on a wall. the code will be like:

begin_f_loop(c,t)
{
C_UDMI(c,t,0)=C_T(c,t);
}
end_f_loop(c,t)

Now, I'm trying to store a single value calculated from my code, and then in another code I might need to use it.

If I do this,

begin_f_loop(c,t)
{
C_UDMI(c,t,0)=h;
}
end_f_loop(c,t)

the value of h will be stored in every cell on the wall. But what if I need to use the value stored in UDM_0 in another code? How can I retrieve it?

It doesn't work if I simply use the value of h in the other code without storing it in UDM. Because if I stop the calculation and write the data, value of h won't be saved. When I read the data, I'm not able to use the value of h again. That's why I have to store it in UDM and then retrieve it.

Anyone could help me with that? I really appreciate that. I tried a long time but still couldn't make it.

You have stored the value in the UDM. So if you want to use it, get it from the UDM!
Code:

h=C_UDMI(c,t,0);

serene6390 March 13, 2017 13:38

Quote:

Originally Posted by pakk (Post 640536)
You have stored the value in the UDM. So if you want to use it, get it from the UDM!
Code:

h=C_UDMI(c,t,0);

Hi, pakk,

Thank you so much for your reply. If I do h=C_UDMI(c,t,0), do I need to loop along the line?

From the UDF instruction, I see that when I store something in UDM, it's actually storing them in specifit cells. My concern is, if I only need to store one value, how do I locate the cell I want to store it into?

What I did was I selected a wall and loop along the wall, store the value to each cell on that wall, when I need to retrieve this value, I use Fluent to calculate the average number of values in that UDM. I know it's such a bad idea, but I still couldn't find a way to locate the cell of UDM that could store the value. Or, maybe I don't need to do that???

I appreciate your help. Thanks a lot.

gouravjee February 24, 2018 03:07

Quote:

Originally Posted by serene6390 (Post 640620)
Hi, pakk,

Thank you so much for your reply. If I do h=C_UDMI(c,t,0), do I need to loop along the line?

From the UDF instruction, I see that when I store something in UDM, it's actually storing them in specifit cells. My concern is, if I only need to store one value, how do I locate the cell I want to store it into?

What I did was I selected a wall and loop along the wall, store the value to each cell on that wall, when I need to retrieve this value, I use Fluent to calculate the average number of values in that UDM. I know it's such a bad idea, but I still couldn't find a way to locate the cell of UDM that could store the value. Or, maybe I don't need to do that???

I appreciate your help. Thanks a lot.



hello,
I am working on creating a new energy transport UDS in fluent and i am stuck in storing the values of liquid fraction.
when i compile and run the code it works fine but when i check the contour for liquid fraction using UDM it does not show anything.

description:
i have initialized all the UDM as zero in DEFINE_INIT
and
i am using these UDMs to store values in DEFINE_ADJUST


do you know how to sort it out?

AlexanderZ February 25, 2018 20:34

how could you know, that it works well?

try to initialize your initial variables using predefined values, so you can clearly see, that initialization works well.

for instance variable 1 = 1.0, value 2 = 2.0 and so on

best regards

gouravjee February 25, 2018 23:31

Quote:

Originally Posted by AlexanderZ (Post 682874)
how could you know, that it works well?

try to initialize your initial variables using predefined values, so you can clearly see, that initialization works well.

for instance variable 1 = 1.0, value 2 = 2.0 and so on

best regards

yes , you are right.init udf is always showing zero value.
i have attached init function below please tell me where is the error?


//------------------------------------
DEFINE_INIT(initialize,d)
{ cell_t c;
Thread *t;
int i;
/*----------------------------------------------*/


/*----------------------------------------------*/
thread_loop_c(t,d) /* Loop over all cell threads in domain */
{
if (FLUID_THREAD_P(t))
{
begin_c_loop(c,t) /* Loop over all cells in a cell thread*/
{
for(i=0; i<sg_udm; ++i) C_UDMI(c,t,i) = 0.0;
}
end_c_loop(c,t)
}
}
}

AlexanderZ February 25, 2018 23:50

looks like there is no error in code for INIT function.
I suggest to put other value, not zero, to check the contours
after debugging change values back to zero

best regards

majeden April 15, 2018 14:41

Quote:

Originally Posted by serene6390 (Post 640620)
Hi, pakk,

Thank you so much for your reply. If I do h=C_UDMI(c,t,0), do I need to loop along the line?

From the UDF instruction, I see that when I store something in UDM, it's actually storing them in specifit cells. My concern is, if I only need to store one value, how do I locate the cell I want to store it into?

What I did was I selected a wall and loop along the wall, store the value to each cell on that wall, when I need to retrieve this value, I use Fluent to calculate the average number of values in that UDM. I know it's such a bad idea, but I still couldn't find a way to locate the cell of UDM that could store the value. Or, maybe I don't need to do that???

I appreciate your help. Thanks a lot.




I have the same problem. can any one help please?

AlexanderZ April 16, 2018 01:21

Quote:

Originally Posted by majeden (Post 688969)
I have the same problem. can any one help please?

wat problem?

best regards


All times are GMT -4. The time now is 12:36.