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

UDF for move a wall with a hole

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Entwistle
  • 1 Post By hayder

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 2, 2014, 13:00
Default UDF for move a wall with a hole
  #1
New Member
 
AFM
Join Date: Nov 2013
Posts: 14
Rep Power: 12
Entwistle is on a distinguished road
Hello sirs;

Our team is developing an UDF for scour predictions. At this time we have the main code that includes the wall shear stress calculation and the velocity of deformation inside a DEFINE_GRID_MOTION macro.

We have builded and loaded correctly the UDF and defined the parameters in the Dynamic Mesh menu but when we start the calculation it crashes when tries to advance one time step. In the Dynamic Mesh we have defined the wall-bed as a User-Defined surface and all others boundaries as a stationary surfaces, even the wall of the pier. We use the layering approach to calculate the dynamic mesh movement.

We have think that our problem could be at the junction between the wall-bed and the wall-cylinder. What do you think? In a few moments I will post our present code.

Last edited by Entwistle; July 2, 2014 at 14:26.
Entwistle is offline   Reply With Quote

Old   July 2, 2014, 14:34
Default
  #2
New Member
 
AFM
Join Date: Nov 2013
Posts: 14
Rep Power: 12
Entwistle is on a distinguished road
This is the code of our UDF:

Quote:

#include "udf.h"

DEFINE_GRID_MOTION(cambio_malla,domain,dt,time,dti me)
{
Thread *tf = DT_THREAD(dt);
Domain *d;
face_t f;
Node *v;
real A[ND_ND];
real NV_VEC(velocity), NV_VEC(axis);
real NV_VEC(origin), NV_VEC(rvec);
real vel,wss,tau,area;
int n;
d=Get_Domain(1);

/* set deforming flag on adjacent cell zone */
SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));
NV_D(velocity, =, 0.0, 0.0, 0.0);
NV_D(axis, =, 0.0, 0.0, 1.0);
NV_D(origin, =, 0.0, 0.0, 0.0);
thread_loop_f(tf,d)
{
begin_f_loop(f,tf)
{
f_node_loop(f,tf,n)
{
v = F_NODE(f,tf,n);
NODE_POS_UPDATED(v);
F_AREA(A,f,tf);
area=NV_MAG(A);
wss=NV_MAG(F_STORAGE_R_N3V(f,tf,SV_WALL_SHEAR));
tau=wss/area;
vel=0.0158*pow((3.584*tau-1),1.5);
NV_VS(velocity,=,axis,*,vel);
NV_S(velocity,*=,dtime);
NV_VV(rvec,=,NODE_COORD(v),-,origin);
NV_V(NODE_COORD(v),-=,velocity);
}
}
end_f_loop(f,tf);
}
}
As I said in my last post, we think that the problem is in the junction between the wall of the cylinder and the wall of the bed. We think that there is some kind of conflict when the position of the nodes of the bed descends while the position of the wall of the cylinder remains static. Could someone guide us?

Thanks.
Entwistle is offline   Reply With Quote

Old   July 2, 2014, 14:56
Default
  #3
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by Entwistle View Post
Hello sirs;
You don't want answers from female readers?
Quote:
We have builded and loaded correctly the UDF and defined the parameters in the Dynamic Mesh menu but when we start the calculation it crashes when tries to advance one time step.
What you you mean with "it crashes"? Fluent exits? Fluent stops the calculation and gives a warning? Which warning?
pakk is offline   Reply With Quote

Old   July 2, 2014, 15:01
Default
  #4
New Member
 
AFM
Join Date: Nov 2013
Posts: 14
Rep Power: 12
Entwistle is on a distinguished road
Quote:
Originally Posted by pakk View Post
You don't want answers from female readers?

What you you mean with "it crashes"? Fluent exits? Fluent stops the calculation and gives a warning? Which warning?
Please sorry me, I sent my first message from my mobile phone and I forgot to use the "Ladies and Gentleman"... :-s

Fluent stop the calculations and show us an error message: Segmentation fault

Thank you.

Edit: FYI, our domain for the validation of the code is a rectangular flume (X (long) from -2 to +2 m, Y (width) from -0.6 to +0.6 m and Z (vertical) from 0 to 0.2 m). The pier is a cylinder with it's center at (0,0,0) and a diameter of 0.2 m. The bed (bottom boundary) is a rough wall. The surface of the cylinder is a smooth wall. X = -2 plane is the inlet BC and X = +2 plane is the outflow BC. Both lateral boundaries and the top boundary are symmetry faces. For the test case we use the realizable k-eps with all other values (coupling scheme, gradient treatment, etc.) set by default.
Entwistle is offline   Reply With Quote

Old   July 3, 2014, 09:58
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by Entwistle View Post
Please sorry me, I sent my first message from my mobile phone and I forgot to use the "Ladies and Gentleman"... :-s
That's fine. It is better to use no formality ("Hi all") then to use one which excludes half of the population. I'm just a man who likes gender equality...
Quote:
Fluent stop the calculations and show us an error message: Segmentation fault
That means there is something wrong in your UDF, it is trying to access memory that is not allowed.
To solve this, you should debug your code.

For example, try this one: (your version with most of it removed)

Code:
#include "udf.h"

DEFINE_GRID_MOTION(cambio_malla,domain,dt,time,dtime)
{
Thread *tf = DT_THREAD(dt);
Domain *d;
face_t f;
Node *v;
real A[ND_ND];
real NV_VEC(velocity), NV_VEC(axis);
real NV_VEC(origin), NV_VEC(rvec);
real vel,wss,tau,area;
int n;
d=Get_Domain(1);

}
Does it give still the segmentation fault? If so, the problem is in one of these lines. If not, it is in one of the other lines. Keep on going like this until you have identified the line that is causing the problem.
pakk is offline   Reply With Quote

Old   July 3, 2014, 14:49
Default
  #6
New Member
 
AFM
Join Date: Nov 2013
Posts: 14
Rep Power: 12
Entwistle is on a distinguished road
Quote:
Originally Posted by pakk View Post
That's fine. It is better to use no formality ("Hi all") then to use one which excludes half of the population. I'm just a man who likes gender equality...
Yes, I understand you, I'm another man who likes gender equality. When I sent my first message I was literally translating my thinkings into English, but in my native language the neutral-form was lost, so we use by default the masculine as inclusive form and the femenin as exclusive form, but this fact based on the economy of the language does not have any influence or meaning about gender discrimination.

Quote:
Originally Posted by pakk View Post

That means there is something wrong in your UDF, it is trying to access memory that is not allowed.
To solve this, you should debug your code.

For example, try this one: (your version with most of it removed)

Code:
#include "udf.h"

DEFINE_GRID_MOTION(cambio_malla,domain,dt,time,dtime)
{
Thread *tf = DT_THREAD(dt);
Domain *d;
face_t f;
Node *v;
real A[ND_ND];
real NV_VEC(velocity), NV_VEC(axis);
real NV_VEC(origin), NV_VEC(rvec);
real vel,wss,tau,area;
int n;
d=Get_Domain(1);

}
Does it give still the segmentation fault? If so, the problem is in one of these lines. If not, it is in one of the other lines. Keep on going like this until you have identified the line that is causing the problem.
[/QUOTE]

I try a code based on my first one but without the calculation of the wall shear stress. In this case, we use a formula for grid motion based on the distance to the center, something like z_movement = Constant*dtime/r, where r = (x^2+y^2)^0.5 and restricted to r >= 0.1 (so it only moves the mesh outside the cylinder in order to avoid possible errors).

When we preview the movement, it seems to be correct, but when we try to iterate for some time steps, Fluent tell us that there is a negative volume. We try the smoothing method and the layering method, and we activated the implicit option in dynamic mesh menu. Our boundaries were defined as stationary (inlet, outflow and symmetries), as deforming (wall of the cylinder) and as user defined (wall-bed). Our mesh is formed by only one body and uses hexaedral elements. Tomorrow I will send you a picture of our mesh for this test case. Some kind of trip in order to avoid the non-positive volume? We also reduce the time step, but even with this action the model presents the non-positive volume.

On the other hand, it seems like the problem for the segmentation fault is in the calculation of shear stress, but it is strange because the method that we use was proposed by the Ansys Support Team (unfortunately, the can not help us more because our support does not include help about any error when we use UDFs).

Thank you for your answers.

Bests regards.
Entwistle is offline   Reply With Quote

Old   July 4, 2014, 08:30
Default
  #7
New Member
 
AFM
Join Date: Nov 2013
Posts: 14
Rep Power: 12
Entwistle is on a distinguished road
Hi all;

as I promised yesterday, I send you some images of my test mesh.

Finally, after some code debugging, the test UDF for deform the mesh it's ok. The test function for DEFINE_GRID_MOTION is the next:


Quote:
#include "udf.h"
#include "dynamesh_tools.h"

DEFINE_GRID_MOTION(cambio_malla,domain,dt,time,dti me)
{
Thread *tf = DT_THREAD(dt);
face_t f;
Node *v;
real vel, aux1, aux2, aux3;
real NV_VEC(dz);
int n;
/* set deforming flag on adjacent cell zone */
SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));
NV_S(dz,=,0);
begin_f_loop(f,tf)
{
f_node_loop(f,tf,n)
{
v = F_NODE(f,tf,n);
if (NODE_Z(v)<0.001 && NODE_POS_NEED_UPDATE(v))
{
NODE_POS_UPDATED (v);
vel=0.8;
aux1=pow(NODE_X(v),2);
aux2=pow(NODE_Y(v),2);
aux3=pow((aux1+aux2),0.5);
dz[2]=vel/aux3;
NV_S(dz,*=,dtime);
NV_V(NODE_COORD(v), -=,dz);
}
}
end_f_loop(f,tf);
}
}
I also send you an image of the deformed mesh in order to add some visual information.

So, we think that now we only have to add the calculation of the wall shear stress in order to modify the dz[2] avobe expression. Our first idea is something like that:

Quote:
#include "udf.h"
#include "dynamesh_tools.h"
static int wall_id=9;
DEFINE_GRID_MOTION(cambio_malla,domain,dt,time,dti me)
{

face_t f;
Node *v;
real vel, tau;
real area[ND_ND];
real wss[ND_ND];
real NV_VEC(dz);
int n;
Domain *dom = Get_Domain(1);
Thread *tf = Lookup_Thread(dom,wall_id);
SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));
NV_S(dz,=,0);
begin_f_loop(f,tf)
{
f_node_loop(f,tf,n)
{
v = F_NODE(f,tf,n);
if (NODE_Z(v)<0.001 && NODE_POS_NEED_UPDATE(v))
{
NODE_POS_UPDATED (v);
F_AREA(area,f,tf);
N3V_V(wss,=,F_STORAGE_R_N3V(f,tf,SV_WALL_SHEAR)); tau=sqrt(wss[0]*wss[0]+wss[1]*wss[1]+wss[2]*wss[2])/(area[0]*area[0]+area[1]*area[1]+area[2]*area[2]);
vel=0.0158*pow((3.584*tau-1),1.5);
dz[2]=vel;
NV_S(dz,*=,dtime);
NV_V(NODE_COORD(v), -=,dz);
}
}
end_f_loop(f,tf);
}
}
However, there something wrong in that code, probably something related with the Lookup_Thread(dom,wall_id). Any idea please?

One last thing is an extrange value of the velocity field that we saw in the test case for the test DEFINE_GRID_MOTION (the first one, without wall shear stress calculation). The velocity inlet is 0.3 m/s (the blue zone

Thank you very much.

Best regards.






Last edited by Entwistle; July 4, 2014 at 08:47. Reason: add image files
Entwistle is offline   Reply With Quote

Old   July 8, 2014, 04:08
Default
  #8
New Member
 
AFM
Join Date: Nov 2013
Posts: 14
Rep Power: 12
Entwistle is on a distinguished road
Hi all, finally we got an UDF that seems correct. However, when we run it, Fluent shows a floating point exception, and divergence in all solvers (we use a Realizable k-eps model).

Our last code is the next:

Quote:
#include "udf.h"
#include "dynamesh_tools.h"

static int wall_id= 9;

DEFINE_EXECUTE_AT_END(tau)
{
Domain *domain = Get_Domain(1);
Thread *ft,*ct;
face_t f;
cell_t c;
real shear_stress;
real ts_force[ND_ND];
real area[ND_ND];

ft=Lookup_Thread(domain,wall_id);
begin_f_loop(f,ft)
{
F_AREA(area,f,ft);
N3V_V(ts_force,=,F_STORAGE_R_N3V(f,ft,SV_WALL_SHEA R));
shear_stress=sqrt(ts_force[0]*ts_force[0]+ts_force[1]*ts_force[1]+ts_force[2]*ts_force[2])/sqrt(area[0]*area[0]+area[1]*area[1]+area[2]*area[2]);
c=F_C0(f,ft);
ct=THREAD_T0(ft);
C_UDMI(c,ct,0)=shear_stress;
}
end_f_loop(f,ft)
}

DEFINE_GRID_MOTION(cambio_malla,domain,dt,time,dti me)
{
Thread *tf = DT_THREAD(dt);
face_t f;
cell_t c0;
Thread *ct0;
Node *v;
real vel, tau;
real NV_VEC(dz);
/*real zprev=0.0;*/
int n;
/* set deforming flag on adjacent cell zone */
SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));
NV_S(dz,=,0);
begin_f_loop(f,tf)
{
f_node_loop(f,tf,n)
{
v = F_NODE(f,tf,n);
if (NODE_Z(v)<0.001 && (NODE_POS_NEED_UPDATE(v)) &&
(sqrt(pow(NODE_X(v),2) + pow(NODE_Y(v),2))<0.3))
{
NODE_POS_UPDATED (v);
c0=F_C0(f,tf);
ct0=THREAD_T0(tf);
tau = C_UDMI(c0,ct0,0);
vel=0.0158*pow((3.584*tau-1),1.5);
dz[2]=vel;
NV_S(dz,*=,dtime);
NV_V(NODE_COORD(v), -=,dz);
}
}
end_f_loop(f,tf);
}
}
Someone could, please, try to help us?

Thank you.
Lucrecio likes this.
Entwistle is offline   Reply With Quote

Old   November 19, 2014, 12:34
Default Scour around a bridge pier
  #9
Member
 
muhamed
Join Date: Jun 2013
Posts: 66
Rep Power: 12
Mohammad80 is on a distinguished road
Hello.
Could you please help me?
I want to do a simulation to study the scour around a cylindrical bridge pier inside a channel same as your model. Could you please tell me how you drew your geometry, one body? or two bodies, one for the fluid and the other for sand material?
and what about Fluent setup? I will be very thankful if you can help me.
Mohammad80 is offline   Reply With Quote

Old   December 15, 2014, 09:11
Default
  #10
New Member
 
hayder
Join Date: Dec 2013
Posts: 3
Rep Power: 12
hayder is on a distinguished road
Hi all, finally we got an UDF that seems correct. However, when we run it, Fluent shows a floating point exception, and divergence in all solvers (we use a Realizable k-eps model).

Our last code is the next:


Quote:
#include "udf.h"
#include "dynamesh_tools.h"

static int wall_id= 9;

DEFINE_EXECUTE_AT_END(tau)
{
Domain *domain = Get_Domain(1);
Thread *ft,*ct;
face_t f;
cell_t c;
real shear_stress;
real ts_force[ND_ND];
real area[ND_ND];

ft=Lookup_Thread(domain,wall_id);
begin_f_loop(f,ft)
{
F_AREA(area,f,ft);
N3V_V(ts_force,=,F_STORAGE_R_N3V(f,ft,SV_WALL_SHEA R));
shear_stress=sqrt(ts_force[0]*ts_force[0]+ts_force[1]*ts_force[1]+ts_force[2]*ts_force[2])/sqrt(area[0]*area[0]+area[1]*area[1]+area[2]*area[2]);
c=F_C0(f,ft);
ct=THREAD_T0(ft);
C_UDMI(c,ct,0)=shear_stress;
}
end_f_loop(f,ft)
}

DEFINE_GRID_MOTION(cambio_malla,domain,dt,time,dti me)
{
Thread *tf = DT_THREAD(dt);
face_t f;
cell_t c0;
Thread *ct0;
Node *v;
real vel, tau;
real NV_VEC(dz);
/*real zprev=0.0;*/
int n;
/* set deforming flag on adjacent cell zone */
SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));
NV_S(dz,=,0);
begin_f_loop(f,tf)
{
f_node_loop(f,tf,n)
{
v = F_NODE(f,tf,n);
if (NODE_Z(v)<0.001 && (NODE_POS_NEED_UPDATE(v)) &&
(sqrt(pow(NODE_X(v),2) + pow(NODE_Y(v),2))<0.3))
{
NODE_POS_UPDATED (v);
c0=F_C0(f,tf);
ct0=THREAD_T0(tf);
tau = C_UDMI(c0,ct0,0);
vel=0.0158*pow((3.584*tau-1),1.5);
dz[2]=vel;
NV_S(dz,*=,dtime);
NV_V(NODE_COORD(v), -=,dz);
}
}
end_f_loop(f,tf);
}
}
Hi Entwistle

I got the same problem in Fluent are you found the answer for the divergence solution problem? please help me if you have any idea.
Lucrecio likes this.
hayder is offline   Reply With Quote

Reply

Tags
gris motion, 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
Natural convection in a closed domain STILL NEEDING help! Yr0gErG FLUENT 4 December 2, 2019 00:04
Enhanced Wall Treatment paduchev FLUENT 24 January 8, 2018 11:55
UDF for slip and moving wall lichun Dong FLUENT 3 March 26, 2014 04:37
UDF hook on the WALL boundary condition Luke FLUENT 0 June 7, 2006 11:54
udf: dimensionless wall coordinate Chris FLUENT 0 June 22, 2004 06:10


All times are GMT -4. The time now is 19:07.