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

Get gradient from uds

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   October 24, 2010, 05:59
Default Get gradient from uds
  #1
New Member
 
qwerty753
Join Date: May 2009
Posts: 16
Rep Power: 8
qwerty753 is on a distinguished road
I defined an uds.
As postprocessing fluent allows to read the uds variable by contour etc.
I just want to reat the gradient of my variable for a surface integral or a plot.
How can i get it?
Thank you
qwerty753 is offline   Reply With Quote

Old   October 25, 2010, 01:50
Default
  #2
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 647
Rep Power: 11
dmoroian is on a distinguished road
Check the UDF Manual at 3.2.3 Cell Macros (to see when and how you make available the gradients to your udf), and after that try the macro C_UDSI_G.
dmoroian is offline   Reply With Quote

Old   October 25, 2010, 06:31
Default
  #3
New Member
 
qwerty753
Join Date: May 2009
Posts: 16
Rep Power: 8
qwerty753 is on a distinguished road
Thank you for your help!
I wrote this udf:
# include "udf.h"
# define domain_ID 2
DEFINE_ON_DEMAND(store_gradient)
{
Domain *domain;
cell_t c;
Thread *t;

domain=Get_Domain(1);

/* Fill the UDM with magnitude of gradient. */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDMI(c,t,0) = C_UDSI_G(c,t,0)[1];
}
end_c_loop (c,t)
}

This doesn't work becouse if i execute on demand i receive this message:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()
Indeed if i wrote:

DEFINE_ON_DEMAND(store_gradient)
{
Domain *domain;
cell_t c;
Thread *t;

domain=Get_Domain(1);

/* Fill the UDM with magnitude of gradient. */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDMI(c,t,0) = C_UDSI(c,t,0);
}
end_c_loop (c,t)
}

to check if it run...i have no problem, why?
qwerty753 is offline   Reply With Quote

Old   October 25, 2010, 07:25
Default
  #4
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 647
Rep Power: 11
dmoroian is on a distinguished road
As I said previously :
Quote:
Check the UDF Manual at 3.2.3 Cell Macros (to see when and how you make available the gradients to your udf), and after that try the macro C_UDSI_G.
I'll give you a hint: the memory for the gradient is not allocated when you try to access C_UDSI_G, so look for the gradient paragraph in the above section of the manual!
dmoroian is offline   Reply With Quote

Old   October 25, 2010, 07:33
Default
  #5
New Member
 
qwerty753
Join Date: May 2009
Posts: 16
Rep Power: 8
qwerty753 is on a distinguished road
OK i understood my error...

solve/set/expert and then answering yes to the question Keep temporary solver memory from being freed?


i set correctly and now it runs.

But i discover that the gradient is calcolated by uds at cell... i need at face because i'm at B.C..

Is there any procedure?
qwerty753 is offline   Reply With Quote

Old   October 25, 2010, 11:38
Default
  #6
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 647
Rep Power: 11
dmoroian is on a distinguished road
If you use second order discretisation scheme, then the gradient is constant over the entire cell, so you may use the cell value on the boundary face.
Otherwise, just as wild guess try F_UDSI_G.
dmoroian is offline   Reply With Quote

Old   July 27, 2012, 13:52
Default
  #7
New Member
 
Join Date: Jul 2012
Posts: 18
Rep Power: 4
mila_oliv is on a distinguished road
hey qwerty753,

did you solve your problem?
I need the gradient too, but it's inserted in my function, so i dont need to postprocess the gradient directly...

look what i've done:

Quote:
#include "udf.h"
DEFINE_ON_DEMAND(heat_flux_lines)
{
Domain *d;
Thread *t;
cell_t c;
real H;
real rho,u,Temp,k,dTdx;
d=Get_Domain(1);
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
rho=C_R(c,t);
u=C_U(c,t);
Temp=C_T(c,t);
k=C_K_L(c,t);
dTdx=C_T_G(c,t)[0];
H+=((rho*u*Temp)-(k*dTdx))*0.1;
C_UDMI(c,t,1)=H;
}
end_c_loop(c,t)
}
}
mila_oliv is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Gradient of UDS gemini Fluent UDF and Scheme Programming 2 December 24, 2013 01:24
How to compute UDS fourth order gradient Emma66 FLUENT 1 April 27, 2010 05:44
reconstruction gradient of a UDS gemini Fluent UDF and Scheme Programming 0 June 7, 2009 16:03
Gradient UDS tom FLUENT 1 April 28, 2006 03:46
Gradient of a UDS Ilkay FLUENT 0 March 8, 2000 14:42


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