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

Zeytoonian

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 8, 2017, 13:04
Default Zeytoonian
  #1
New Member
 
hassan zeytoonian
Join Date: Feb 2016
Posts: 5
Rep Power: 10
Hzeytoonian is on a distinguished road
Hi
I am modeling a laminar flow in cylindrical coordinate.
My problem boundary condition are as follow:

1. Direkhlrt boundary condition as: Pin=15Mpa, Pout=0
2. numan boundary condition as: velocity derivative in normal direction to inlet and outlet boundary is zero.

i am trying to define a UDF that include both two above boundary condition.

I could not find any UDF or macros relate to numan boundarey condition.

Please help me to know can l found a UDF for my problem boundary condition?

Thanks
Hzeytoonian is offline   Reply With Quote

Old   November 8, 2017, 22:05
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:
Originally Posted by Hzeytoonian View Post
Hi
I am modeling a laminar flow in cylindrical coordinate.
My problem boundary condition are as follow:

1. Direkhlrt boundary condition as: Pin=15Mpa, Pout=0
2. numan boundary condition as: velocity derivative in normal direction to inlet and outlet boundary is zero.

i am trying to define a UDF that include both two above boundary condition.

I could not find any UDF or macros relate to numan boundarey condition.

Please help me to know can l found a UDF for my problem boundary condition?

Thanks
By default velocity derivatives in normal direction to inlet and outlet boundary are zero.

Best regards
AlexanderZ is offline   Reply With Quote

Old   November 8, 2017, 23:12
Default
  #3
New Member
 
hassan zeytoonian
Join Date: Feb 2016
Posts: 5
Rep Power: 10
Hzeytoonian is on a distinguished road
Thank you AlexanderZ

I don't understand what is your means.
The only default boundary conditions in fluent
Which all variable derivative (like velocity) are zero
Is just outflow boundary condition. But with select outflow boundary condition the inlet pressure can not be choice at the same time.
Hzeytoonian is offline   Reply With Quote

Old   November 9, 2017, 00:17
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
Ansys Fluent Customization manual

3.2.3.9. Derivative Macros

The macros listed in Table 3.14: Macros for Cell Velocity Derivatives Defined in mem.h (p. 258) can be
used to return real velocity derivative variables in SI units. The variables are available in both the
pressure-based and the density-based solver.

Best regards
AlexanderZ is offline   Reply With Quote

Old   November 9, 2017, 03:54
Default
  #5
New Member
 
hassan zeytoonian
Join Date: Feb 2016
Posts: 5
Rep Power: 10
Hzeytoonian is on a distinguished road
Dear Mr. AlexanderZ

Thank you for your useful help. The main problem
Is that i am a beginer in fluent udfs use.
I do not know how uses and how arrange my
Boundary condition in velocity derivative macro.
Other problem is related to my cylindrical geometry. My velocity derivative boundary condition should write in cylindrical coordinate.
Can you please help me to prepare it?
Thank you for all help
Best regards
Hzeytoonian is offline   Reply With Quote

Old   November 9, 2017, 11:08
Default
  #6
New Member
 
hassan zeytoonian
Join Date: Feb 2016
Posts: 5
Rep Power: 10
Hzeytoonian is on a distinguished road
Mr Alexander

As i said i need to apply both direkhlet boundary
Condition (Pin=15Mpa and Pout=0) and also numan boundary condition (velocity derivatives=0)
on my boundaries.
With your help i could find a velocity derivative macro mem.h.
Now i need to define a udf to include both direkhlet and numan boundary condition on my boundry. Is it correct?
Thanks again
Hzeytoonian is offline   Reply With Quote

Old   November 13, 2017, 20:54
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
what do you mean under velocity derivative, write an expression.

Regarding pressure, you may define Pin/Pout using pressure inlet/oulet boundary condition

Best regards
AlexanderZ is offline   Reply With Quote

Old   November 18, 2017, 02:09
Default zeytoonian
  #8
New Member
 
hassan zeytoonian
Join Date: Feb 2016
Posts: 5
Rep Power: 10
Hzeytoonian is on a distinguished road
Dear Alexanserz

i need to define a UDF for my boundary conditions which include the following equation:<br><br>&nbsp;dV/dn=0.

v is the velocity on boundary and n is the normal vector on boundary.<br><br>&nbsp;bests
Hzeytoonian is offline   Reply With Quote

Old   March 28, 2018, 03:17
Default
  #9
New Member
 
David
Join Date: Nov 2017
Posts: 14
Rep Power: 9
uconcorde is on a distinguished road
Quote:
Originally Posted by Hzeytoonian View Post
Dear Alexanserz

i need to define a UDF for my boundary conditions which include the following equation:<br><br>&nbsp;dV/dn=0.

v is the velocity on boundary and n is the normal vector on boundary.<br><br>&nbsp;bests
Dear Hzeytoonian,

I am wondering whether you found a solution to this boundary condition setting?
In velocity inlet bc, you may hook the UDF for u, v and p.

Thanks,
Dv
uconcorde is offline   Reply With Quote

Old   March 28, 2018, 06:32
Default
  #10
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
If you want to have a boundary with:
1. Fixed pressure (Pout=0 MPa)
2. Zero velocity gradient in normal direction.

Then it is very easy in Fluent: set a Pressure outlet, with pressure 0 Pa. This will automatically give the second condition, because this is default.

This is what AlexanderZ already said when he mentioned "By default velocity derivatives in normal direction to inlet and outlet boundary are zero."

So you don't need a UDF here. It is much more simple than you think.
pakk is offline   Reply With Quote

Old   March 28, 2018, 21:36
Default
  #11
New Member
 
David
Join Date: Nov 2017
Posts: 14
Rep Power: 9
uconcorde is on a distinguished road
Quote:
Originally Posted by pakk View Post
If you want to have a boundary with:
1. Fixed pressure (Pout=0 MPa)
2. Zero velocity gradient in normal direction.

Then it is very easy in Fluent: set a Pressure outlet, with pressure 0 Pa. This will automatically give the second condition, because this is default.

This is what AlexanderZ already said when he mentioned "By default velocity derivatives in normal direction to inlet and outlet boundary are zero."

So you don't need a UDF here. It is much more simple than you think.
Hi Pakk,

Thank you so much for your reply. This problem bothered me a long time.

For sure, by default, pressure outlet can satisfy the two conditions mentioned above.

In my case, however, I would like to simulate a flow over a curved surface. I have p_out=zero (through pressure outlet bc); a Blasius velocity profile inlet (through velocity inlet bc); a wall bc. At top of domain, I would like to implement the du/dy=0; dv/dy=0; dp/dy=0 (since my domain is fixed, I cannot move the top surface further away from the wall). I found Outflow b.c. in Fluent will give me these zero gradient conditions. However, Outflow and Pressure Outlet b.c. will not work at the same time by Fluent. Also, Symmetry b.c. also gives these zero gradient conditions, however, the normal velocity at the boundary is zero by default which I would not like to see.

I don't know how to implement it unless using UDF to give velocity inlet profile at the top surface. For the time being, it goes to the correct direction, but the convergence of continuity is not quite good (residual to 10e-6).

If you have any insights, please let me know. I hope to have simpler way to get b.c.'s I want.

Thank you in advance.
Dv
uconcorde is offline   Reply With Quote

Old   March 29, 2018, 04:36
Default
  #12
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Is the "top of the domain" also your outlet?

In that case, you are trying to specify the pressure and the pressure gradient in the same boundary. The Navier-Stokes equations are first-order in pressure, so you should only have one boundary condition for pressure.

In other words: spend less time on thinking how to implement your BCs, but spend more time thinking about if they are the correct BCs.
pakk is offline   Reply With Quote

Old   March 29, 2018, 06:24
Default
  #13
New Member
 
David
Join Date: Nov 2017
Posts: 14
Rep Power: 9
uconcorde is on a distinguished road
Quote:
Originally Posted by pakk View Post
Is the "top of the domain" also your outlet?

In that case, you are trying to specify the pressure and the pressure gradient in the same boundary. The Navier-Stokes equations are first-order in pressure, so you should only have one boundary condition for pressure.

In other words: spend less time on thinking how to implement your BCs, but spend more time thinking about if they are the correct BCs.
Hi Pakk,

Many thanks for your reply. I totally agree with you. The physics of the problem should be the most important when doing simulation.

I really have two outlets since I'd like to see the profile of y-velocity at the top surface. And, the main flow comes from inlet(left) to outlet(right). In this case, the pressure outlet at the right surface of domain is much more important than the top surface.

You mentioned that I was trying to specify the pressure and pressure gradient on the same top boundary. However, for the time being, I just use UDF to get dp/dy is zero (hook to the "Supersonic/Initial Gauge Pressure" dialogue box) and do not specify any value for the pressure.

Now, I'm thinking about if it is reasonable to have a zero pressure gradient at the top boundary, because the y-velocity is not zero. If dp/dy is zero, the y-velocity should be also zero, right?

Finally, here is the UDF I'm using to get zero gradient boundary, could you please take a look at it to see if it is feasible? It is the first time I write a UDF by just following some example in the manual. It doesn't converge well.

Any insights would be appreciated.

Best,
Dv

# include "udf.h"
DEFINE_PROFILE(top_u_gradient,t,i) /* du/dy */
{
real xf[ND_ND], xc[ND_ND];
face_t f;
cell_t c0;
Thread *t0;
begin_f_loop(f,t)
{
F_CENTROID(xf,f,t);
c0 = F_C0(f,t);
t0 = THREAD_T0(t);
C_CENTROID(xc,c0,t0);
F_PROFILE(f,t,i) = C_U(c0,t0); /* not confident */
}
end_f_loop(f,t)
}

DEFINE_PROFILE(top_v_gradient,t,i) /* dv/dy */
{
real xf[ND_ND], xc[ND_ND];
face_t f;
cell_t c0;
Thread *t0;
begin_f_loop(f,t)
{
F_CENTROID(xf,f,t);
c0 = F_C0(f,t);
t0 = THREAD_T0(t);
C_CENTROID(xc,c0,t0);
F_PROFILE(f,t,i) = (-1) * C_V(c0,t0); /* not confident if need to change the sign of y-velocity */
}
end_f_loop(f,t)
}

DEFINE_PROFILE(top_p_gradient,t,i) /* dp/dy */
{
real xf[ND_ND], xc[ND_ND];
face_t f;
cell_t c0;
Thread *t0;
begin_f_loop(f,t)
{
F_CENTROID(xf,f,t);
c0 = F_C0(f,t);
t0 = THREAD_T0(t);
C_CENTROID(xc,c0,t0);
F_PROFILE(f,t,i) = C_P(c0,t0); /* not confident */
}
uconcorde is offline   Reply With Quote

Old   March 29, 2018, 06:40
Default
  #14
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Going back to your setup: I don't know what you are simulating, but it looks like wind blowing past some obstacle.

Quote:
however, the normal velocity at the boundary is zero by default which I would not like to see.
If your domain is big enough, the normal velocity at the top of your domain will be (close to) zero. So, make your domain bigger. But you say this is not possible, because:
Quote:
since my domain is fixed, I cannot move the top surface further away from the wall
I don't know how to interpret this. You are in charge of the simulation, so you are the one who fixes the domain. Just choose it larger. Unfix your domain.
pakk is offline   Reply With Quote

Old   October 22, 2021, 03:52
Thumbs up
  #15
New Member
 
Join Date: Oct 2016
Posts: 2
Rep Power: 0
msky is on a distinguished road
God bless you.
msky 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



All times are GMT -4. The time now is 17:56.