CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   write a UDF to give a velocity boundary condition at an interior face (https://www.cfd-online.com/Forums/fluent-udf/146232-write-udf-give-velocity-boundary-condition-interior-face.html)

Tharanga December 21, 2014 19:08

write a UDF to give a velocity boundary condition at an interior face
 
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)
}

behest December 26, 2014 08:28

What is your error message?


Quote:

Originally Posted by Tharanga (Post 524883)
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)
}


Tharanga December 27, 2014 20:45

Quote:

Originally Posted by behest (Post 525262)
What is your error message?

This is the error massage and please help
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.
4. Report error to your distributor

behest December 30, 2014 07:18

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:

Originally Posted by Tharanga (Post 525346)
This is the error massage and please help
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.
4. Report error to your distributor


upeksa December 30, 2014 10:15

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.

macfly December 30, 2014 12:05

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 January 5, 2015 20:09

1 Attachment(s)
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.

macfly January 6, 2015 01:25

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, ...

Tharanga January 6, 2015 03:32

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

sxdl92victor February 3, 2015 17:36

Quote:

Originally Posted by Tharanga (Post 526261)
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.

Tharanga February 3, 2015 18:19

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!!

sxdl92victor February 3, 2015 22:47

Quote:

Originally Posted by Tharanga (Post 530261)
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.

Tharanga February 3, 2015 23:22

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

sxdl92victor February 3, 2015 23:25

Quote:

Originally Posted by Tharanga (Post 530277)
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.

Aerathon June 4, 2015 16:40

:) Out of curiosity, have you figured out how to do it with UDF? I'm trying to model a cylinder with porous wall.

Tharanga June 17, 2015 23:02

Quote:

Originally Posted by Aerathon (Post 548942)
:) 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

Prabhumsrit January 5, 2018 08:14

velocity and pressure on interior face
 
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

Tharanga January 6, 2018 18:20

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

crotchet May 23, 2018 11:08

Quote:

Originally Posted by Tharanga (Post 677176)
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

gouravjee August 5, 2018 04:29

Problem in temperature calculation using udf
 
Quote:

Originally Posted by upeksa (Post 525567)
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"


DEFINE_PROFILE(fluxloss,thread,position)
{
real h;
real T_ext;
face_t f;
begin_f_loop(f,thread)
{
h = 10;
T_ext = 300;
F_PROFILE(f,thread,position) =-10*(WALL_TEMP_INNER(f,thread)-T_ext);
}
end_f_loop(f,thread)

}



All times are GMT -4. The time now is 23:31.