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

User-Defined Scalar (UDS) Source code

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By coglione

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 9, 2010, 01:54
Default User-Defined Scalar (UDS) Source code
  #1
lig
New Member
 
Gloria
Join Date: Feb 2010
Posts: 16
Rep Power: 16
lig is on a distinguished road
Hi, Everybody,

I am using UDF in the source term of UDS. The equation is U*A*CEcell*Scalar/ V, where U is the velocity; A is the face area that normal to U; CEcell is function of U, but here it is treated as constant for test the code; V is the control volume of the cell.

I wrote a code (the simplified code is followed in the end) but there is error as followed. Experts, please give me some advice about the problem, I am really working on this problem for a long time. I post the problem before, but nobody answer me. I just try again, hope someone can help me .

Error:
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: ()

DEFINE_SOURCE(uds_source0,c,t,dS,eqn)
{

real source;
real x[ND_ND], z, Ucell,V, CEcell;
real NV_VEC(vel),NV_VEC(Af),flow_rate_1;
int i;
face_t f;

Ucell=C_U(c,t);
V=C_VOLUME(c,t);
z=x[1];

/************************************************** *************************************/
C_CENTROID(x,f,t);
CEcell=0.01;
/************************************************** *************************************/
F_AREA(Af,f,t);
NV_D(vel,=,F_U(f,t),F_V(f,t));
flow_rate_1=NV_DOT(vel,Af);

source = C_UDSI(c,t,0)*CEcell*flow_rate_1/V;
dS[eqn] = CEcell*flow_rate_1/V;

return source;
}
lig is offline   Reply With Quote

Old   June 9, 2010, 04:02
Default
  #2
New Member
 
Join Date: Jun 2009
Posts: 11
Rep Power: 17
jpcfd is on a distinguished road
Did you activate de UDS in the fluent menu? This is a tipical error when some pointer is doing his work anomaly.
jpcfd is offline   Reply With Quote

Old   June 9, 2010, 08:38
Default
  #3
lig
New Member
 
Gloria
Join Date: Feb 2010
Posts: 16
Rep Power: 16
lig is on a distinguished road
Thank you, jpcfd, for the reply.
What I did is that simulate the air flow first to get the velocity, then introduce 8 UDSs, change the diffusivity under material; flux under UDS; then initial value from the inlet; and source term under porous zone under boundary conditions. Then uncheck the equations of flow and turbulence under solution control to continue iteration. Can this active the UDS you asked? It works before I use this code, but this code is reasonable.
lig is offline   Reply With Quote

Old   June 10, 2010, 04:09
Default
  #4
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 17
coglione is on a distinguished road
Hi Gloria,
there are several errors in your code. First of all you have to realize that DEFINE_SOURCE loops over cells and not faces. Thus, F_AREA() does not know for which face f (and which face-thread t) it should compute the area. This definitely causes an access violation.
c_face_loop may be the macro that helps you as it loops over all faces of a given cell. Having a closer look at the udf-user guide will help too.

cheers
coglione is offline   Reply With Quote

Old   June 12, 2010, 02:04
Default
  #5
lig
New Member
 
Gloria
Join Date: Feb 2010
Posts: 16
Rep Power: 16
lig is on a distinguished road
Hi, Coglione,

Thank you for the suggestion. I wrote a code using c_face_loop(c,t,i), but it doesn't work and has the same error.Could you please help me to check where the problems are? Really appreciated!
/*****************************CEcell abtained in above program*************************************/
c_face_loop(c,t,i)
{
cell_t c0,c1=-1;
Thread *t0,*t1=NULL;
c0=F_C0(f,t);
t0=F_C0_THREAD(f,t);
F_AREA(Af,f,t);
if (BOUNDARY_FACE_THREAD_P(t))
{
NV_D(vel, =,F_U(f,t),F_V(f,t),F_W(f,t));
flow_rate_1=NV_DOT(vel,Af);

source = C_UDSI(c,t,0)*CEcell*flow_rate_1/V;
dS[eqn] = CEcell*flow_rate_1/V;

}

else {
NV_D(vel,=,C_U(c0,t0),C_V(c0,t0),C_W(c0,t0));
flow_rate_1=NV_DOT(vel,Af);

source = C_UDSI(c,t,0)*CEcell*flow_rate_1/V;
dS[eqn] = CEcell*flow_rate_1/V;
}
}
return source;
}
lig is offline   Reply With Quote

Old   June 14, 2010, 04:41
Default
  #6
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 17
coglione is on a distinguished road
Hello again,

your code is still missing the part where you retrieve the face-id (f) and face-thread (ft) for which you want to get some information.
Use within your c_face_loop
f = C_FACE(c,t,i);
tf = C_FACE_THREAD(c,t,i);

and with that
F_AREA(Af,f,tf), F_U(f,tf) ... should work properly.

cheers


tinhtt likes this.
coglione is offline   Reply With Quote

Old   October 15, 2014, 13:12
Default
  #7
New Member
 
Aravind
Join Date: Oct 2014
Posts: 3
Rep Power: 12
aravindbpillai is on a distinguished road
#include "udf.h"
#include"sg.h"
enum
{
E,
N_REQUIRED_UDS
};
DEFINE_ADJUST(e_adjust,domain)
{
if (n_uds < N_REQUIRED_UDS)
Internal_Error("not enough user-defined scalars allocated");
}


/*DEFINE_SOURCE(energy_source_up,c,t,dS,eqn)
{

dS[eqn]= -49574.9 *pow((C_R(c,t)*C_U(c,t))/C_MU_L(c,t), 0.42 );
return 49574.9 *pow((C_R(c,t)*C_U(c,t))/C_MU_L(c,t), 0.42 )*( 400 -C_UDSI(c,t,E));
}
DEFINE_SOURCE(energy_source_down,c,t,dS,eqn)
{
dS[eqn]= -12.45 *pow((C_R(c,t)*C_U(c,t))/C_MU_L(c,t), 0.96 );
return 12.45 *pow((C_R(c,t)*C_U(c,t))/C_MU_L(c,t), 0.96 )*( 400 -C_UDSI(c,t,E));
}*/

DEFINE_DIFFUSIVITY(e_diffusivity,c,t,i)
{
real X[ND_ND],xp;

C_CENTROID(X,c,t);
xp = X[0];
if(xp <= 0.035)
{
return 0.2 +( 1.772 *pow( 10.0 ,- 10 )*pow(C_UDSI(c,t,E), 3 ));
}
else
{

return 0.1 +( 1.77 *pow( 10.0 ,- 9 )*pow(C_UDSI(c,t,E), 3 ));
}
}
DEFINE_PROFILE(e_profile,t,i)
{
face_t f;
begin_f_loop (f,t)
{
F_PROFILE(f,t,i)= -2.367*pow(10.0 ,-7 )*(pow(F_UDSI(f,t,i), 4 )- pow( 300.0 , 4 ));
}
end_f_loop (f,t)
}



When i tried for initializing ,it is showing the below mentioned error.
Error: 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: #f

Plz help me sir
aravindbpillai 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
Understanding k-omega SST model source code tmhonka OpenFOAM Programming & Development 1 September 8, 2009 08:33
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 02:24
user defined scalar saghir FLUENT 1 December 4, 2006 06:25
Please help me run UDF code for source Suga FLUENT 1 February 3, 2006 04:40


All times are GMT -4. The time now is 07:47.