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

student need your help

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 16, 2019, 01:29
Default student need your help
  #1
New Member
 
James Thor
Join Date: May 2019
Posts: 13
Rep Power: 7
Ya Hong is on a distinguished road
When I ran my UDF, the following question came up. Can anyone tell me how to solve it
https://www.cfd-online.com/Forums/at...1&d=1557980543
there is my code.
/*ErosionTabakoff.C*/
#include "udf.h"
#include "dpm.h"
#define bv 2.41
Domain *domain;
enum{
NUM_OF_HITS,AVG_DIAMETER,AVG_ALPHA,AVG_VMAG,AVG_MD OT, MAX_ALPHA, MIN_ALPHA, NUM_OF_USED_UDM
};
int UDM_checked=0;
void reset_UDM_s(void);
int check_for_UDM(void)
{
Thread *t;
if(UDM_checked)
return UDM_checked;
thread_loop_c(t,domain)
{
if(FLUID_THREAD_P(t))
if(NULLP(THREAD_STORAGE(t,SV_UDM_I)))
return 0;
}
UDM_checked=1;
reset_UDM_s();
return UDM_checked;
}
void reset_UDM_s(void)
{
Thread *t;cell_t c;
face_t f;
int i;
if (!check_for_UDM())
return;
Message ("Resetting User Defined Memory...\n");
thread_loop_f(t,domain)
{
if(NNULLP(THREAD_STORAGE(t,SV_UDM_I)))
{
begin_f_loop(f,t)
{
for(i=0;i<NUM_OF_USED_UDM;i++)
F_UDMI(f,t,i)=0.;
}
end_f_loop(f,t)
}
else
{
Message("Skipping FACE thread no. %d..\n",THREAD_ID(t));
}
}
thread_loop_c(t,domain)
{
if(NNULLP(THREAD_STORAGE(t,SV_UDM_I)))
{
begin_c_loop(c,t)
{
for(i=0;i<NUM_OF_USED_UDM;i++)C_UDMI(c,t,i)=0.;
}
end_c_loop(c,t)
}
else
{
Message("Skipping CELL thread no. %d..\n",THREAD_ID(t));
}
}
Message("---Done.\n");
}
DEFINE_DPM_SCALAR_UPDATE(dpm_scalup,c,t,if_init,p)
{
if(if_init)
P_USER_REAL(p,0)=0;
}
DEFINE_DPM_EROSION(dpm_erosion,p,t,f,normal,alpha, Vmag,Mdot)
{
real A[ND_ND],area;
int num_in_data;
Thread *t0;cell_t c0;
real R;
if(!UDM_checked)
if(!check_for_UDM())
return;c0=F_C0(f,t);
t0=THREAD_T0(t);
num_in_data=F_UDMI(f,t,NUM_OF_HITS);
if(num_in_data==0)
{
F_UDMI(f,t,MAX_ALPHA)=alpha;C_UDMI(c0,t0,MAX_ALPHA )=F_UDMI(f,t,MAX_ALPHA);
F_UDMI(f,t,MIN_ALPHA)=alpha;C_UDMI(c0,t0,MIN_ALPHA )=F_UDMI(f,t,MIN_ALPHA);
}
if(num_in_data>0)
{
if(alpha>F_UDMI(f,t,MAX_ALPHA))
{
F_UDMI(f,t,MAX_ALPHA)=alpha;C_UDMI(c0,t0,MAX_ALPHA )=F_UDMI(f,t,MAX_ALPHA);
}
if(alpha<F_UDMI(f,t,MIN_ALPHA))
{
F_UDMI(f,t,MIN_ALPHA)=alpha;C_UDMI(c0,t0,MIN_ALPHA )=F_UDMI(f,t,MIN_ALPHA);
}
}
F_UDMI(f,t,AVG_DIAMETER)=(P_DIAM(p)+num_in_data*F_ UDMI(f,t,AVG_DIAMETER))/(num_in_data+1);C_UDMI(c0,t0,AVG_DIAMETER)=F_UDMI( f,t,AVG_DIAMETER);
F_UDMI(f,t,AVG_ALPHA)=(alpha+num_in_data*F_UDMI(f, t,AVG_ALPHA))/(num_in_data+1);C_UDMI(c0,t0,AVG_ALPHA)=F_UDMI(f,t ,AVG_ALPHA);
F_UDMI(f,t,AVG_VMAG)=(Vmag+num_in_data*F_UDMI(f,t, AVG_VMAG))/(num_in_data+1);C_UDMI(c0,t0,AVG_VMAG)=F_UDMI(f,t, AVG_VMAG);
F_UDMI(f,t,AVG_MDOT)=(Mdot+num_in_data*F_UDMI(f,t, AVG_MDOT))/(num_in_data+1);C_UDMI(c0,t0,AVG_MDOT)=F_UDMI(f,t, AVG_MDOT);
F_UDMI(f,t,NUM_OF_HITS)=num_in_data+1;C_UDMI(c0,t0 ,NUM_OF_HITS)=num_in_data+1;
R=1-0.0016* Vmag*sin(alpha);
if(alpha<=60)
F_STORAGE_R(f,t,SV_DPMS_EROSION)+=1.505*pow(10,-6)*pow((1+0.296*sin(4.5*alpha)),2)*pow(Vmag,2)*cos (1-R*R)+5.0*pow(10,-12)*pow(Vmag,4)*pow(sin(alpha),4);
else
F_STORAGE_R(f,t,SV_DPMS_EROSION)+=1.505*pow(10,-6)*pow(Vmag,2)*cos(1-R*R)+5.0*pow(10,-12)*pow(Vmag,4)*pow(sin(alpha),4);
P_USER_REAL(p,0)=1.;
}
DEFINE_DPM_LAW(stop_dpm_law,p,if_cpld)
{
if(0.<P_USER_REAL(p,0))
P_MASS(p)=0.;
}
DEFINE_ON_DEMAND(reset_UDM)
{
domain=Get_Domain(1);
reset_UDM_s();
}
Ya Hong is offline   Reply With Quote

Reply

Tags
fluent - udf, programing, udf


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
Student license? federernadal CFX 3 February 14, 2019 11:26
Need some information about ANSYS student version license approval Rajaero Main CFD Forum 2 August 6, 2018 00:49
ANSYS Student CFD Post kf+1 ANSYS 1 October 16, 2017 05:49
License for fluent will expire -Ansys 16.2 Student MichaelK ANSYS 5 November 2, 2016 14:10
modeling exterior aero for Formula Student Car FSAE_student STAR-CCM+ 5 November 11, 2011 14:08


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