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

to separate pressure force and viscous force using udf

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 14, 2013, 06:29
Talking to separate pressure force and viscous force using udf
  #1
New Member
 
Yaroslav
Join Date: Nov 2013
Posts: 4
Rep Power: 13
ignayars is on a distinguished road
Hi all!
I'm simulate unsteady flow in Fluent and I need write to file pressure force and viscous force on a wall every time step. I'm using UDF in parallel, but my UDF working wrong. After first time step Fluent crashes
UDf code :
DEFINE_EXECUTE_AT_END(compute_forces)
{

/* Initialiazation */
FILE *out;
real ftx, fpx, fvx;
#if !RP_HOST

Domain * domain;
Thread * thread;
face_t f;
real NV_VEC(A);
real Force_viscous_tot[ND_ND], Force_pressure_tot[ND_ND], Force_tot[ND_ND];
real Force[ND_ND], Force_viscous[ND_ND], Force_pressure[ND_ND];

domain = Get_Domain(1);
thread = Lookup_Thread(domain,9);//wall is 9
N3V_S(Force_viscous_tot,=,0.0);
N3V_S(Force_pressure_tot,=,0.0);
N3V_S(Force_tot,=,0.0);
N3V_S(Force,=,0.0);
#endif //!RP_HOST

#if !RP_HOST

begin_f_loop_int(f,thread)
{

F_AREA(A,f,thread);

/* Get wall shear force and pressure force on face */
N3V_VS(Force_viscous,=,F_STORAGE_R_N3V(f,thread,SV _WALL_SHEAR),*,-1.0);
N3V_VS(Force_pressure, =, A, *, F_P(f,thread));

/* Add forces */
N3V_VV(Force, =, Force_viscous, +, Force_pressure);

/* Accumulate viscous/pressure forces */
N3V_V(Force_viscous_tot, +=, Force_viscous);
N3V_V(Force_pressure_tot, +=, Force_pressure);
N3V_V(Force_tot, +=, Force);
}
end_f_loop_int(f,thread);
ftx = Force_tot[0];
fpx = Force_pressure_tot[0];
fvx = Force_viscous_tot[0];
#endif //!RP_HOST

#if RP_NODE

ftx = PRF_GRSUM1(ftx);
fpx = PRF_GRSUM1(fpx);
fvx = PRF_GRSUM1(fvx);
#endif //RP_NODE

node_to_host_real_3(ftx, fpx, fvx);
#if !RP_NODE

out = fopen("data.txt","a");
fprintf(out,"%13.5e\t%13.5e\t%13.5e\t%13.5e\n",CUR RENT_TIME,fpx,fvx,ftx);
fclose(out);
#endif //!RP_NODE[/INDENT]}


Thank you!
ignayars is offline   Reply With Quote

Old   October 19, 2014, 08:26
Default
  #2
New Member
 
Kuldip Kulkarni
Join Date: Nov 2012
Location: Pune, Maharashtra
Posts: 4
Rep Power: 14
kuldip is on a distinguished road
Quote:
Originally Posted by ignayars View Post
Hi all!
I'm simulate unsteady flow in Fluent and I need write to file pressure force and viscous force on a wall every time step. I'm using UDF in parallel, but my UDF working wrong. After first time step Fluent crashes
UDf code :
DEFINE_EXECUTE_AT_END(compute_forces)
{

/* Initialiazation */
FILE *out;
real ftx, fpx, fvx;
#if !RP_HOST

Domain * domain;
Thread * thread;
face_t f;
real NV_VEC(A);
real Force_viscous_tot[ND_ND], Force_pressure_tot[ND_ND], Force_tot[ND_ND];
real Force[ND_ND], Force_viscous[ND_ND], Force_pressure[ND_ND];

domain = Get_Domain(1);
thread = Lookup_Thread(domain,9);//wall is 9
N3V_S(Force_viscous_tot,=,0.0);
N3V_S(Force_pressure_tot,=,0.0);
N3V_S(Force_tot,=,0.0);
N3V_S(Force,=,0.0);
#endif //!RP_HOST

#if !RP_HOST

begin_f_loop_int(f,thread)
{

F_AREA(A,f,thread);

/* Get wall shear force and pressure force on face */
N3V_VS(Force_viscous,=,F_STORAGE_R_N3V(f,thread,SV _WALL_SHEAR),*,-1.0);
N3V_VS(Force_pressure, =, A, *, F_P(f,thread));

/* Add forces */
N3V_VV(Force, =, Force_viscous, +, Force_pressure);

/* Accumulate viscous/pressure forces */
N3V_V(Force_viscous_tot, +=, Force_viscous);
N3V_V(Force_pressure_tot, +=, Force_pressure);
N3V_V(Force_tot, +=, Force);
}
end_f_loop_int(f,thread);
ftx = Force_tot[0];
fpx = Force_pressure_tot[0];
fvx = Force_viscous_tot[0];
#endif //!RP_HOST

#if RP_NODE

ftx = PRF_GRSUM1(ftx);
fpx = PRF_GRSUM1(fpx);
fvx = PRF_GRSUM1(fvx);
#endif //RP_NODE

node_to_host_real_3(ftx, fpx, fvx);
#if !RP_NODE

out = fopen("data.txt","a");
fprintf(out,"%13.5e\t%13.5e\t%13.5e\t%13.5e\n",CUR RENT_TIME,fpx,fvx,ftx);
fclose(out);
#endif //!RP_NODE[/INDENT]}


Thank you!
Hi ignayars,

Please define macro for unsteady simulation before #if !RP_HOST.

You have to define
real current_time;
current_time = CURRENT_TIME;


It may work.
kuldip 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
how does Fluent calculate the pressure and viscous force ? e30.lsb FLUENT 7 June 27, 2011 22:31
Viscous force and coefficient viscous force tobino Main CFD Forum 0 February 20, 2011 22:06
how does Fluent calculate the pressure and viscous force vector? Ralf Schmidt FLUENT 2 May 17, 2010 16:49
pressure force and viscous force CFD FLUENT 0 March 7, 2006 02:03
what the result is negatif pressure at inlet chong chee nan FLUENT 0 December 29, 2001 06:13


All times are GMT -4. The time now is 13:39.