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

Convective B.C. at the outlet

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 28, 2017, 17:30
Default Convective B.C. at the outlet
  #1
New Member
 
Karthikeyan
Join Date: Nov 2016
Posts: 14
Rep Power: 10
kar1209 is on a distinguished road
Hi,

I am working on the 2D transient simulation of external flow over a cylinder and would like to use the convective BC given by:

∂u/∂t+(U_c)(∂u/∂x)=0

at the outlet boundary. I have written a UDF to represent the discretized version of the BC; the UDF is getting interpreted and I am hooking to the 'velocity inlet BC' that I have given at outlet but when I try to initialize the solution, "fatal signal segmentation error" is reported.

I am attaching my source file. can I get some help?

thanks,
Karthikeyan

Quote:
#include"udf.h"
DEFINE_PROFILE(CBC_u_vel,t,i)
{
real x, y, z, u_temp, u_cor, mass_out = 0, ds;
real x[ND_ND], y[ND_ND];
Thread *nt;
face_t f;
cell_t c, nc;
begin_f_loop(f,t)
{
mass_out+=F_FLUX(f,t);
}
end_f_loop(f,t)
u_cor = (20 - mass_out)/20;
begin_f_loop(f,t)
{
nc = F_C0(f,t);
nt = THREAD_T0(t);
F_CENTROID(x,f,t);
C_CENTROID(y,nc,nt);
ds = x[0] - y[0];
if((CURRENT_TIME/CURRENT_TIMESTEP <= 1)
{
x = 0;
y = 0;
}
else
{
x = F_U_M1(f,t);
y = C_U_M1(nc,nt);
}
u_temp = F_U_M1(f,t) - CURRENT_TIMESTEP*(F_U_M1(f,t)-C_U_M1(nc,nt))/ds;
F_PROFILE(f,t,i) = u_temp + u_cor;
}
end_f_loop(f,t)
}
Attached Files
File Type: c convective BC_u-vel.c (622 Bytes, 11 views)

Last edited by kar1209; March 28, 2017 at 17:36. Reason: For quoting the Source file
kar1209 is offline   Reply With Quote

Old   March 29, 2017, 08:43
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
You defined x and y two times.

And the following code does nothing:
Code:
if((CURRENT_TIME/CURRENT_TIMESTEP <= 1)
{
x = 0;
y = 0;
}
else
{
x = F_U_M1(f,t);
y = C_U_M1(nc,nt);
}
Because you never use x and y afterwards.
pakk is offline   Reply With Quote

Old   April 4, 2017, 03:47
Default
  #3
New Member
 
Karthikeyan
Join Date: Nov 2016
Posts: 14
Rep Power: 10
kar1209 is on a distinguished road
I have corrected my code but still I am getting the "received a fatal signal (segmentation fault)" error. Is it because the function is not able to access the previous timestep values using F_U_M1 and C_U_M1?
Code:
#include"udf.h"
DEFINE_PROFILE(CBC_u_vel,t,i)
{
real u_f_old, u_c_old, u_temp, u_cor, mass_out = 0, ds;
real x[ND_ND], y[ND_ND];
Thread *nt;
face_t f;
cell_t c, nc;
begin_f_loop(f,t)
{
mass_out+=F_FLUX(f,t);
}
end_f_loop(f,t)
u_cor = (20 - mass_out)/20;
begin_f_loop(f,t)
{
nc = F_C0(f,t);
nt = THREAD_T0(t);
F_CENTROID(x,f,t);
C_CENTROID(y,nc,nt);
ds = x[0] - y[0];
u_f_old = F_U_M1(f,t);
u_c_old = C_U_M1(nc,nt);
u_temp = u_f_old - CURRENT_TIMESTEP*(u_f_old - u_c_old)/ds;
F_PROFILE(f,t,i) = u_temp + u_cor;
}
end_f_loop(f,t)
}
The UDF manual says:
Quote:
Note that data from C_T_M1 is available only if user-defined scalars are defined.
How do I define and use user-defined scalars to access data using C_U_M1 in my program?

Any help would be appreciated.
kar1209 is offline   Reply With Quote

Old   April 11, 2017, 07:21
Default Got it working!
  #4
New Member
 
Karthikeyan
Join Date: Nov 2016
Posts: 14
Rep Power: 10
kar1209 is on a distinguished road
I finally managed to get my udf working by using a user defined memory. The link "Previous time step variable to be used in UDF" helped me.

My intention was to impose the convective boundary condition at the outlet of my flow domain.

My objective is to simulate the flow over a square prism at low Reynolds number. The boundary condition to be imposed at the outlet of the domain is:

u/∂t) + (Uc)(∂u/∂x) =0

where, Uc is the convective velocity of the vortex centres and it is usually taken equal to the freestream velocity (Uc = 1 in my case). The attached image bears the discretized form of the equation.

My udf for the above purpose is:

Code:
#include"udf.h"
/*defining a global variable to to check for the number of timer steps*/
int n_ts = -1;
DEFINE_PROFILE(CBC_u_vel,t,i)
{
real ds, x[ND_ND], y[ND_ND];
Thread *nt;
face_t f;
cell_t nc;
/* assignment of F_UDMI from previous time step to the profile at the current time step*/
/*if condition to allow assignment of [rofile variable only at the first iteration of the time step*/
if(n_ts != N_TIME)
{
if(CURRENT_TIME == 0)
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = 1;
}
end_f_loop(f,t)
else
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = F_UDMI(f,t,0);
}
end_f_loop(f,t)
/*assigning the time step number to n_ts so that the profile does not work in the next iteration of the time step*/
n_ts = N_TIME;
}
/*loop for updating the F_UDMI at every iteration of the current time step*/
/*at the end of last iteration of the time step, F_UDMI will have the converged solution to be used in the next time step */
begin_f_loop(f,t)
{
nc = F_C0(f,t);
nt = THREAD_T0(t);
F_CENTROID(x,f,t);
C_CENTROID(y,nc,nt);
ds = x[0] - y[0];
F_UDMI(f,t,0) = F_U(f,t) - CURRENT_TIMESTEP*(F_U(f,t) - C_U(nc,nt))/ds;
}
end_f_loop(f,t)
}
Unlike my earlier attempts, I am able to successfully hook the udf. I have selected "velocity inlet" BC at the outlet zone and then I have hooked the udf to the x component of the velocity.

When I run the solution and plot the lift and drag coefficient history, I get them as very erroneous.

What might be going wrong in my procedure?
Thanks in advance for any help
Attached Images
File Type: png CBC.PNG (13.7 KB, 45 views)
kar1209 is offline   Reply With Quote

Old   April 12, 2018, 04:04
Default
  #5
New Member
 
Join Date: Apr 2018
Posts: 3
Rep Power: 8
tbridel is on a distinguished road
Hello everybody,

Does anyone has input on how to use th UDF that kar1209 posted ? Hooking it up and using it does not yield correct results, and as a matter of fact if
1/ I use it in a velocity inlet, it leads to segfault
2/ I use it as a slip velocity at a wall, the velocity in the cells next to the wall still goes to zero ...

I am using Fluent v16.2.

Thank you in advance for anyone's help !

Cheers
tbridel is offline   Reply With Quote

Old   November 14, 2018, 07:04
Default convective B.C. at outlet.
  #6
New Member
 
mukesh
Join Date: Nov 2018
Posts: 2
Rep Power: 0
mukeshkumar is on a distinguished road
Hello everyone,

I have used kar1209's coding for convective b.c.at outlet but in x component of velocity inlet type. It leads crashing of simulation.I have also used velocity with negative sign but facing same problem.

Any help would be appreciated.
mukeshkumar is offline   Reply With Quote

Old   November 14, 2018, 23:47
Default
  #7
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
describe step by step, how you start this simulation

best regards
AlexanderZ is offline   Reply With Quote

Old   November 28, 2018, 01:43
Default convective B.C. at outlet.
  #8
New Member
 
mukesh
Join Date: Nov 2018
Posts: 2
Rep Power: 0
mukeshkumar is on a distinguished road
thank you for replying AlexanderZ.

My simulation detail-i have used 2d, transient case for uniform flow(velocity= 9 m/s) over cylinder.
model-kw SST, method- 2nd order implicit, rest all are default( ANSYS fluent 19.1)
Boundary condition-
1. Inlet-velocity inlet
2.wall-wall with no slip condition
3.cylinder-wall with no slip condition
4.outlet-convective b.c.(mentioned already)
time step is .001s

suggestion is very please to me. thank you.
mukeshkumar is offline   Reply With Quote

Reply

Tags
boundary condition, convective, cylinder flow, fluent, 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
twoPhaseEulerFoam bubble column crashes due to problems at outlet region hester OpenFOAM Running, Solving & CFD 5 July 21, 2024 09:19
changing velocity (outlet) BC to pressure outlet majid_kamyab FLUENT 7 October 22, 2014 12:50
How to define outlet convective BC for the cyclic BC zxj160 OpenFOAM 9 October 9, 2012 12:28
Using Opening B.C. for both inlet and outlet SH_P CFX 1 June 11, 2012 21:15
ATTENTION! Reliability problems in CFX 5.7 Joseph CFX 14 April 20, 2010 16:45


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