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

student need your help

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 15, 2019, 09:01
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
Can anyone help me? This program can't run on my model. There are no errors in the program.

/*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

Old   May 15, 2019, 22:42
Default
  #2
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:
There are no errors in the program.
so why did you post it here? without any question

best regards
AlexanderZ is offline   Reply With Quote

Old   May 16, 2019, 00:23
Default Thank you for your reply. There's a problem here.
  #3
New Member
 
James Thor
Join Date: May 2019
Posts: 13
Rep Power: 7
Ya Hong is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
so why did you post it here? without any question

best regards
Thank you for your reply. There's a problem here when I run it.

https://www.cfd-online.com/Forums/at...1&d=1557980543[IMG]
Attached Images
File Type: png 1(6S]NFR[UQGQB@)ZRT)K~6.png (15.4 KB, 44 views)
Ya Hong is offline   Reply With Quote

Old   May 16, 2019, 00:45
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Did you allocate memory for user-defined memories (UDMs)?
This error may come from our code as well as in model settings, I recommend you to perform simulation without UDF first using default erosion model
Also you may try to use code from manual (Ansys Fluent Customization manual)

best regards
AlexanderZ is offline   Reply With Quote

Old   May 16, 2019, 01:22
Default
  #5
New Member
 
James Thor
Join Date: May 2019
Posts: 13
Rep Power: 7
Ya Hong is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
Did you allocate memory for user-defined memories (UDMs)?
This error may come from our code as well as in model settings, I recommend you to perform simulation without UDF first using default erosion model
Also you may try to use code from manual (Ansys Fluent Customization manual)

best regards
Because I need to compare the impact of different erosion models on erosion rates, UDF must be used. Can you tell me how to carry out user-defeated memories(UDMs)
Ya Hong is offline   Reply With Quote

Old   May 16, 2019, 02:06
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
in Fluent GUI go to User-Defined -> Memories -> set number of user-defined memory location to 8.
It seems in your UDF you are using 8, so 8 is enough.

best regards
AlexanderZ is offline   Reply With Quote

Old   May 16, 2019, 06:09
Default
  #7
New Member
 
James Thor
Join Date: May 2019
Posts: 13
Rep Power: 7
Ya Hong is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
in Fluent GUI go to User-Defined -> Memories -> set number of user-defined memory location to 8.
It seems in your UDF you are using 8, so 8 is enough.

best regards
Thank you so much.But after the UDM problem was solved, when I ran to step 10, the following situation still occurred.
https://www.cfd-online.com/Forums/at...1&d=1558001348
Attached Images
File Type: png DK6ZB2RO$$7N$3%QSP@A)~O.png (7.9 KB, 19 views)
Ya Hong is offline   Reply With Quote

Old   May 16, 2019, 10:51
Default
  #8
New Member
 
James Thor
Join Date: May 2019
Posts: 13
Rep Power: 7
Ya Hong is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
in Fluent GUI go to User-Defined -> Memories -> set number of user-defined memory location to 8.
It seems in your UDF you are using 8, so 8 is enough.

best regards
Thank you so much for your help.
I used a new program that allowed me to calculate, but the result of the erosion rate was 0. The procedure is as follows
#include "udf.h"

#define MIN_IMPACT_VELO -1000.
/* Minimum particle velocity normal to wall (m/s) to allow Accretion.*/

Domain *domain; /* Get the domain pointer and assign it later to domain*/
enum /* Enumeration of used User-Defined Memory Locations. */
{
NUM_OF_HITS, /* Number of particle hits into wall face considered.*/
AVG_DIAMETER, /* Average diameter of particles that hit the wall. */
AVG_RADI_VELO, /* Average radial velocity of "" "" ------------ */
NUM_OF_USED_UDM
};
void reset_UDM_s(void)
{
Thread *t;
cell_t c;
face_t f;
int i;
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));
}
} /* Skipping Cell Threads can happen if the user */
/* uses reset_UDM prior to initializing. */
Message(" --- Done.\n");
}
DEFINE_DPM_EROSION(dpm_erosion,tp,t,f,normal,alpha ,Vmag,Mdot)
{
real A[ND_ND],area;
Thread *t0;cell_t c0;
real R;
real Vmag;
real alpha;
real mdot;
c0=F_C0(f,t);
t0=THREAD_T0(t);
R=1-0.0016* Vmag*sin(alpha);
if(alpha<=60)
F_STORAGE_R (f,t,SV_DPMS_ACCRETION)+=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_ACCRETION)+=1.505*pow(10,-6)*pow(Vmag,2)*cos(1-R*R)+5.0*pow(10,-12)*pow(Vmag,4)*pow(sin(alpha),4);
}
DEFINE_ON_DEMAND(reset_UDM)
{
domain=Get_Domain(1);
reset_UDM_s();
}
Ya Hong is offline   Reply With Quote

Old   May 17, 2019, 00:13
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
remove floowing lines
real Vmag;
real alpha;
real mdot;

read your code

best regards
AlexanderZ is offline   Reply With Quote

Old   May 17, 2019, 02:13
Default
  #10
New Member
 
James Thor
Join Date: May 2019
Posts: 13
Rep Power: 7
Ya Hong is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
remove floowing lines
real Vmag;
real alpha;
real mdot;

read your code

best regards
I have remove it.The result is still 0. I wonder if you have written the relevant program. Can you write a complete program for me? Thank you very much.

best regards
Ya Hong is offline   Reply With Quote

Old   May 17, 2019, 02:39
Default
  #11
New Member
 
James Thor
Join Date: May 2019
Posts: 13
Rep Power: 7
Ya Hong is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
remove floowing lines
real Vmag;
real alpha;
real mdot;

read your code

best regards
This is my whole process.all.docx
all.docx
Ya Hong is offline   Reply With Quote

Old   May 17, 2019, 03:05
Default
  #12
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
as I told you:
as a first step I recommend you to perform simulation without UDF, using default erosion model.
This will show if the problem comes from UDF or just from model settings
As a next step you may try to use code from manual (Ansys Fluent Customization manual)
And finally use your code

best regards
AlexanderZ is offline   Reply With Quote

Old   June 29, 2021, 22:50
Default
  #13
New Member
 
WEIZHENJIANG
Join Date: Jun 2021
Posts: 1
Rep Power: 0
WeiZhenjiang is on a distinguished road
Is the problem solved?
WeiZhenjiang is offline   Reply With Quote

Reply

Tags
code, erosion, program, 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
Importing Solid Edge files into ANSYS student dbh0006 ANSYS 0 March 22, 2019 16:05
Student license? federernadal CFX 3 February 14, 2019 10:26
Need some information about ANSYS student version license approval Rajaero Main CFD Forum 2 August 5, 2018 23:49
help for a simple student harika FLUENT 6 January 10, 2006 00:18
Student looking for CFD software Chris Main CFD Forum 6 January 21, 2005 03:20


All times are GMT -4. The time now is 20:36.