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

An important question about DPM_Erosion UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 25, 2014, 00:08
Unhappy An important question about DPM_Erosion UDF
  #1
Member
 
Join Date: May 2009
Posts: 58
Rep Power: 16
amir2920 is on a distinguished road
I am writing a UDF to calculate the erosion. I opened a User_Defined memory locations and set a name for it, but I store any value in that UDM. How can I store any data in my UDM? Here is the UDF:

/************************************************** *********************
UDF for Calculating Erosion
************************************************** **********************/
#include "udf.h"
DEFINE_EXECUTE_ON_LOADING(on_loading, libname)
{
Set_User_Memory_Name(0,"ER1_model");
}

enum /* Enumeration of used User-Defined Memory Locations. */
{
ER1_model, /* Erosion model.*/
};
DEFINE_DPM_EROSION(erudf, particle, t, f, normal, theta, vel, mdot)
{
real Avec[ND_ND];
real er, f_dia,f_angle;
real f_ss316;
real f_tmp;
Domain *d;
cell_t c;
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_UDMI(c,t,ER1_model) =0.002;
}
end_c_loop(c,t)
}
}
amir2920 is offline   Reply With Quote

Old   February 25, 2014, 03:05
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
C_UDMI(c,t,0) =0.002;
pakk is offline   Reply With Quote

Old   February 25, 2014, 11:10
Default
  #3
Member
 
Join Date: May 2009
Posts: 58
Rep Power: 16
amir2920 is on a distinguished road
I also tried that, and it did not work. Is there any specific way to store data in udm for dpm_erosion macro? I can store my data in other macros?
amir2920 is offline   Reply With Quote

Old   February 25, 2014, 11:12
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
I also tried that, and it did not work.
Please be more specific. Things can fail in many ways, and the way it fails is important for the solution.
Did you have problems with compiling? Interpreting? Running the simulation? Showing the results? What exactly did not work?
pakk is offline   Reply With Quote

Old   February 25, 2014, 11:17
Default
  #5
Member
 
Join Date: May 2009
Posts: 58
Rep Power: 16
amir2920 is on a distinguished road
The problem is when I want to see the results, it always shows that my UDM is zero, however I put that equal to 0.002. Why does not show 0.002 in the results? Thanks,
amir2920 is offline   Reply With Quote

Old   February 25, 2014, 11:20
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Are you sure that your udf erudf is used? Did you hook it at the right place?
Test it by adding a Message("test\n"); somewhere, and see if it shows up in the screen.
pakk is offline   Reply With Quote

Old   February 25, 2014, 11:26
Default
  #7
Member
 
Join Date: May 2009
Posts: 58
Rep Power: 16
amir2920 is on a distinguished road
Yes, after compiling I can see and select it in discrete phase model section. Should i do something else to hook that up? Thanks.
amir2920 is offline   Reply With Quote

Old   February 25, 2014, 11:37
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
No, you hooked it in the correct way.

But I now had a better look at your UDF, and it makes no sense to me. What are you trying to do? What do you want the user defined memory to store?
pakk is offline   Reply With Quote

Old   February 25, 2014, 11:44
Default
  #9
Member
 
Join Date: May 2009
Posts: 58
Rep Power: 16
amir2920 is on a distinguished road
I am trying to calculate the erosion and then store that in my UDM. But first i just wanted to test my UDM and see if it can show the value that I have already specified for that in my UDF. So I just put that equal to 0.002, and I checked that in XY plot and I picked the wall that I want to calculate erosion on that. Instead of showing 0.002 it just shows zero.
If I can store my value in my UDM then I will add my erosion equation based on the particle velocity and impact angle and other things.

Thanks,
amir2920 is offline   Reply With Quote

Old   February 25, 2014, 11:51
Default
  #10
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
So what you want is to set the UDM at the surface where the particle reflects equal to 0.002. That is a smart test.

But why do you use the thread_loops? I think that your problem is there...

What you do here:
Code:
 
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_UDMI(c,t,ER1_model) =0.002;
}
end_c_loop(c,t)
}
is to go through all cells of all threads of domain "d", and set the value equal to 0.002. You did not initialize "d" (no warnings about that?), so Fluent will take an arbitrary number for that. If that would happen to be equal to the number that your domain has, the UDM would be 0.002 everywhere, but in the likely situation that it is not equal, the UDM would remain 0.0 everywhere, which is what you see.

I think you need the much simpler version: change the UDM of face f to 0.002. In other words:
Code:
 F_UDMI(f,t,ER1_model) =0.002;
No loops necessary!
pakk is offline   Reply With Quote

Old   February 25, 2014, 12:04
Default
  #11
Member
 
Join Date: May 2009
Posts: 58
Rep Power: 16
amir2920 is on a distinguished road
Thank you very much for your help. I removed the loop and just added F_UDMI code that you wrote, but in XY Plot it still shows zero. If I put the face value equal to a number for example 0.002, can I see that in the result (XY plot) or I must put that number for the cell center by C_UDMI and then I will be able to see it in my XY Plot? How can I be sure that UDM reflects my calculation in my UDF?
amir2920 is offline   Reply With Quote

Old   February 26, 2014, 03:12
Default
  #12
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
I just checked some old code I once made for something similar, and I had the same problem as you did: the plots stayed zero. (If my memory were better, it would have saved us both some time...)

The way I solved it then, translated to your situation:

Code:
F_UDMI(f,t,0) = 0.002;
 C_UDMI(F_C0(f,t),THREAD_T0(t),0) = 0.002;

I don't know why this was necessary, and maybe it is sufficient to only use the second line. I hope it helps!
pakk is offline   Reply With Quote

Old   March 1, 2014, 14:50
Default
  #13
Member
 
Join Date: May 2009
Posts: 58
Rep Power: 16
amir2920 is on a distinguished road
Thank you, it works now!

c0 = F_C0(f, t);
t0 = THREAD_T0(t);
C_UDMI(c0, t0, 0) =F_UDMI(f,t,0);
amir2920 is offline   Reply With Quote

Reply


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
my important question, UDF hamid1 FLUENT 1 October 12, 2011 10:57
Quick question RE: UDF Dylan FLUENT 2 August 22, 2007 15:47
UDF question Kerem FLUENT 0 April 3, 2006 19:24
A question about the dynamic mesh UDF Tango FLUENT 1 November 27, 2003 02:56
a question about UDF Wenbin FLUENT 0 November 12, 2003 10:24


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