# write a UDF to give a velocity boundary condition at an interior face

 Register Blogs Members List Search Today's Posts Mark Forums Read

 December 21, 2014, 19:08 write a UDF to give a velocity boundary condition at an interior face #1 New Member   Tharanga Jayathungage Don Join Date: Sep 2014 Location: Auckland Posts: 25 Rep Power: 9 I'm trying to write a UDF to give a velocity boundary condition at an interior face. The velocity condition is U.n=alpa*(C_P(c0,t0)-C_P(c1,t1)). When I'm trying to get velocity condition for C1 cells, error msg is coming. Can anyone advice me on this? Thank you. udf #include "udf.h" DEFINE_PROFILE(edge_Velo,t,i) { real xf[ND_ND]; real xc[ND_ND]; real xe[ND_ND]; face_t f; cell_t c1 ; Thread*t1 ; cell_t c0 ; Thread*t0 ; double _D=0; begin_f_loop(f,t) { F_CENTROID(xf,f,t); c1=F_C1(f,t) ; t1=THREAD_T1(t); C_CENTROID(xc,c1,t1); c0=F_C0(f,t) ; t0=THREAD_T0(t) ; C_CENTROID(xe,c0,t0); F_PROFILE(f,t,i) = -(0.000025*((C_P(c0,t0)-C_P(c1,t1))); } end_f_loop(f,thread) }

December 26, 2014, 08:28
#2
Member

Ali.E
Join Date: Sep 2010
Location: Lisboa
Posts: 83
Rep Power: 13

Quote:
 Originally Posted by Tharanga I'm trying to write a UDF to give a velocity boundary condition at an interior face. The velocity condition is U.n=alpa*(C_P(c0,t0)-C_P(c1,t1)). When I'm trying to get velocity condition for C1 cells, error msg is coming. Can anyone advice me on this? Thank you. udf #include "udf.h" DEFINE_PROFILE(edge_Velo,t,i) { real xf[ND_ND]; real xc[ND_ND]; real xe[ND_ND]; face_t f; cell_t c1 ; Thread*t1 ; cell_t c0 ; Thread*t0 ; double _D=0; begin_f_loop(f,t) { F_CENTROID(xf,f,t); c1=F_C1(f,t) ; t1=THREAD_T1(t); C_CENTROID(xc,c1,t1); c0=F_C0(f,t) ; t0=THREAD_T0(t) ; C_CENTROID(xe,c0,t0); F_PROFILE(f,t,i) = -(0.000025*((C_P(c0,t0)-C_P(c1,t1))); } end_f_loop(f,thread) }

December 27, 2014, 20:45
#3
New Member

Tharanga Jayathungage Don
Join Date: Sep 2014
Location: Auckland
Posts: 25
Rep Power: 9
Quote:
 Originally Posted by behest What is your error message?
C:\PROGRA~1\ANSYSI~1\v145\fluent\fluent14.5.0\win6 4\3ddp\fl1450s.exe received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.

December 30, 2014, 07:18
#4
Member

Ali.E
Join Date: Sep 2010
Location: Lisboa
Posts: 83
Rep Power: 13
I compiled the UDF, it works very well.
You recieved an access violation error, and this error means that UDF can not access a defined value in UDF. I do not have your Fluent file to check the UDF. If it is possible share your file you check the UDF.

Quote:

 December 30, 2014, 10:15 #5 Member   Join Date: Jul 2013 Posts: 80 Rep Power: 10 You can not set any kind of define-profile in an interior boundary. I think that you have a boundary which happens to be interior and you set it as velocity-inlet. I have not checked it, but I guess that both THREAD_T1 and F_C1 can only be used if that cell or thread exists, and I think that is not your case. Anyway, if for some reason you want to set a velocity inlet boundary condition in an interior boundary, I would leave that boundary as interior and I would use a momentum source instead, but that still sounds weird to me. Tharanga and iteration like this.

 December 30, 2014, 12:05 #6 Senior Member   François Grégoire Join Date: Jan 2010 Location: Canada Posts: 392 Rep Power: 14 Indeed, a boundary condition on an interior face sounds weird. I think you should redo the geometry/mesh, make a small zone where you want to fix the velocities, e.g. a zone with only 1 cell layer, and then in Fluent: Cell Zone Conditions => Edit... => Fixed Values... Tharanga likes this.

January 5, 2015, 20:09
#7
New Member

Tharanga Jayathungage Don
Join Date: Sep 2014
Location: Auckland
Posts: 25
Rep Power: 9
Hi, there are two regions larger one is porous. I wanted to make velocity v=const.*P at the interface. P is the pressure difference taking from the nearest cell values. Can anyone suggest something pls? Thank you very much for the replies.
Attached Images
 fd.png (20.6 KB, 108 views)

 January 6, 2015, 01:25 #8 Senior Member   François Grégoire Join Date: Jan 2010 Location: Canada Posts: 392 Rep Power: 14 I have no idea how you can achieve that, all kind of questions are popping in my head: - 2D or 3D? steady or transient? - you want to define velocity vectors that are normal to the interface? the interface is the yellow circle? - it looks like a little coding nightmare: trying to retrieve pressure on both sides of the interface, calculate some angles, calculate x-y-z velocity components, ...

 January 6, 2015, 03:32 #9 New Member   Tharanga Jayathungage Don Join Date: Sep 2014 Location: Auckland Posts: 25 Rep Power: 9 It is 3D and Steady state simulation. Yes, I want to define normal velocity (radial). Yellow circle is a non porous region (Cylinder) and cube is porous (hollow). Interface or interior lies between these two regions and want to access pressure values in order to give velocity. This is actually trying to implement a permeable BC at the interface. Indeed, it is a nightmare.. big time . Really appreciate your suggestions. Thank you

February 3, 2015, 17:36
#10
New Member

Xu Su
Join Date: Jul 2014
Posts: 3
Rep Power: 9
Quote:
 Originally Posted by Tharanga It is 3D and Steady state simulation. Yes, I want to define normal velocity (radial). Yellow circle is a non porous region (Cylinder) and cube is porous (hollow). Interface or interior lies between these two regions and want to access pressure values in order to give velocity. This is actually trying to implement a permeable BC at the interface. Indeed, it is a nightmare.. big time . Really appreciate your suggestions. Thank you
Hello,
How about your simulation now? I met the same problems defining permeable membrane wall in FLUENT. It is pretty difficult to define the velocity.

 February 3, 2015, 18:19 #11 New Member   Tharanga Jayathungage Don Join Date: Sep 2014 Location: Auckland Posts: 25 Rep Power: 9 Hi, I couldn't do it and I just gave up. Specially, I was trying to give it at the interface and that was the difficult part. No success. What kind of problem are you dealing with? cheers!!

February 3, 2015, 22:47
#12
New Member

Xu Su
Join Date: Jul 2014
Posts: 3
Rep Power: 9
Quote:
 Originally Posted by Tharanga Hi, I couldn't do it and I just gave up. Specially, I was trying to give it at the interface and that was the difficult part. No success. What kind of problem are you dealing with? cheers!!
I'm sorry to hear that you gave up. Have you ever tried to use other CFD software such as CFX?
My project is simulating membrane desalination process which is pretty similar with your problem. I also need to define velocity at the membrane side(interior or interface) to obey the mass conservation law.
Now, I'm trying to learn how to use mass source and wish it can solve this problem.

 February 3, 2015, 23:22 #13 New Member   Tharanga Jayathungage Don Join Date: Sep 2014 Location: Auckland Posts: 25 Rep Power: 9 In order to implement condition (above) at the interface, needs to change the interpolation scheme or the pressure velocity coupling method (I think). I'm trying few things at the moment lets see and Hope for the best. Good luck with you work. cheers

February 3, 2015, 23:25
#14
New Member

Xu Su
Join Date: Jul 2014
Posts: 3
Rep Power: 9
Quote:
 Originally Posted by Tharanga In order to implement condition (above) at the interface, needs to change the interpolation scheme or the pressure velocity coupling method (I think). I'm trying few things at the moment lets see and Hope for the best. Good luck with you work. cheers
Good luck. Keep in touch.

 June 4, 2015, 16:40 #15 New Member   Join Date: Jun 2015 Posts: 1 Rep Power: 0 Out of curiosity, have you figured out how to do it with UDF? I'm trying to model a cylinder with porous wall.

June 17, 2015, 23:02
#16
New Member

Tharanga Jayathungage Don
Join Date: Sep 2014
Location: Auckland
Posts: 25
Rep Power: 9
Quote:
 Originally Posted by Aerathon Out of curiosity, have you figured out how to do it with UDF? I'm trying to model a cylinder with porous wall.
Sad to say It didn't work. cheers

 January 5, 2018, 08:14 velocity and pressure on interior face #17 New Member   Prabhu R Join Date: Nov 2017 Posts: 13 Rep Power: 5 I want to measure the velocity and pressure on interior face in Nozzle design and also required further thrust calculation. Please share any details with u and it is useful for my project and

 January 6, 2018, 18:20 #18 New Member   Tharanga Jayathungage Don Join Date: Sep 2014 Location: Auckland Posts: 25 Rep Power: 9 Hi, Can you explain bit more? I manage to create a one cell thickness layer and implement my BCs in there. I think specifying a BC at an interior surface does not work as we dealing with the cell-based calculations. Thanks

May 23, 2018, 11:08
#19
New Member

Jianan Zhao
Join Date: Nov 2017
Posts: 1
Rep Power: 0
Quote:
 Originally Posted by Tharanga Hi, Can you explain bit more? I manage to create a one cell thickness layer and implement my BCs in there. I think specifying a BC at an interior surface does not work as we dealing with the cell-based calculations. Thanks
Hi

I had the similar problem as you, which was defining a velocity profile on an interior face or wall. This link might be useful for you

http://cape-forum.com/index.php?topic=1248.0

However, after following the steps mentioned in above link, you need to define a opposite velocity profile on the other slit wall. This method works for my case, and hope it can help.

Jianan

August 5, 2018, 04:29
Problem in temperature calculation using udf
#20
Member

Join Date: Oct 2017
Posts: 52
Rep Power: 5
Quote:
 Originally Posted by upeksa You can not set any kind of define-profile in an interior boundary. I think that you have a boundary which happens to be interior and you set it as velocity-inlet. I have not checked it, but I guess that both THREAD_T1 and F_C1 can only be used if that cell or thread exists, and I think that is not your case. Anyway, if for some reason you want to set a velocity inlet boundary condition in an interior boundary, I would leave that boundary as interior and I would use a momentum source instead, but that still sounds weird to me.
I have to calculate heat transfer losses from radial surface of the cylinder.
I have written a udf for this but it is showing "segmentation fault".
can you tell me where might be the problem ?
Code:
```#include "udf.h"

{
real h;
real T_ext;
face_t f;
{
h = 10;
T_ext = 300;
}

}```