CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

store and access the value in UDM

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By serene6390
  • 1 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 9, 2017, 17:50
Default store and access the value in UDM
  #1
New Member
 
Jing
Join Date: Feb 2013
Posts: 25
Rep Power: 13
serene6390 is on a distinguished road
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.
mambako likes this.
serene6390 is offline   Reply With Quote

Old   March 13, 2017, 06:00
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by serene6390 View Post
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);
Tobi likes this.
pakk is offline   Reply With Quote

Old   March 13, 2017, 13:38
Default
  #3
New Member
 
Jing
Join Date: Feb 2013
Posts: 25
Rep Power: 13
serene6390 is on a distinguished road
Quote:
Originally Posted by pakk View Post
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.
serene6390 is offline   Reply With Quote

Old   February 24, 2018, 03:07
Default
  #4
Member
 
Join Date: Oct 2017
Posts: 52
Rep Power: 8
gouravjee is on a distinguished road
Quote:
Originally Posted by serene6390 View Post
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?
gouravjee is offline   Reply With Quote

Old   February 25, 2018, 20:34
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
AlexanderZ is offline   Reply With Quote

Old   February 25, 2018, 23:31
Default
  #6
Member
 
Join Date: Oct 2017
Posts: 52
Rep Power: 8
gouravjee is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
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)
}
}
}
gouravjee is offline   Reply With Quote

Old   February 25, 2018, 23:50
Default
  #7
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
AlexanderZ is offline   Reply With Quote

Old   April 15, 2018, 14:41
Default
  #8
New Member
 
maji nouri
Join Date: Dec 2016
Posts: 2
Rep Power: 0
majeden is on a distinguished road
Quote:
Originally Posted by serene6390 View Post
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?
majeden is offline   Reply With Quote

Old   April 16, 2018, 01:21
Default
  #9
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Quote:
Originally Posted by majeden View Post
I have the same problem. can any one help please?
wat problem?

best regards
AlexanderZ is offline   Reply With Quote

Reply

Tags
udf, udm


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access value in cell across an interior interface iteration Fluent UDF and Scheme Programming 1 July 13, 2016 04:38
Way to access fluent report variables ravi.karamarkar1 Fluent UDF and Scheme Programming 1 August 18, 2015 07:13
How to access VOF of a face gandesk Fluent UDF and Scheme Programming 1 February 2, 2011 21:24
How to access or generate double derivatives? Vishal FLUENT 1 March 11, 2006 21:15
Help on UDF: access to wall shear stress Zhihua Li FLUENT 2 May 26, 2004 11:55


All times are GMT -4. The time now is 19:24.