CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > CONVERGE

udf problem of a moving boundary

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

Reply
 
LinkBack Thread Tools Display Modes
Old   October 26, 2017, 10:04
Default udf problem of a moving boundary
  #1
tmy
New Member
 
Mingyuan Tao
Join Date: Mar 2016
Posts: 12
Rep Power: 3
tmy is on a distinguished road
Hi all,

I am struggling with the udf to define a boundary movement. Attached is my code in "user_motion.c". What I want to do is set the boundary 1 with a constant moving velocity along x axis. However, after compiling the code and running simulation, I found the boundary was still stationary. Could anyone tell me how to fix it? Or is there any relevant tutorial about how to set user_defined_function of boundary movement? I would really appreciate for your help!

ps: in my code, I directly use " surface_verts[vertnum].x[0] = surface_verts[vertnum].x[0] - 0.3*dt " to update my boundary surface vertex coordinates. Is this enough?
Attached Files
File Type: c user_motion.c (2.8 KB, 4 views)
tmy is offline   Reply With Quote

Old   October 26, 2017, 10:13
Default
  #2
New Member
 
Shrirang
Join Date: May 2016
Location: India
Posts: 18
Rep Power: 3
shrirang is on a distinguished road
Fluent udf manual has many UDFs available for reference.
You can refer zone motion udf.
Worked fine for me.
shrirang is offline   Reply With Quote

Old   October 26, 2017, 10:20
Default
  #3
tmy
New Member
 
Mingyuan Tao
Join Date: Mar 2016
Posts: 12
Rep Power: 3
tmy is on a distinguished road
Thanks for your reply! I will look up the zone_motion in fluent.
tmy is offline   Reply With Quote

Old   October 26, 2017, 10:37
Default
  #4
tmy
New Member
 
Mingyuan Tao
Join Date: Mar 2016
Posts: 12
Rep Power: 3
tmy is on a distinguished road
Hi Shrirang,

I just checked the Ansys Fluent 14. UDF, and read the example of zone_motion code. I can tell how it calculates the motion, and actually in CONVERGE udf src_example there are details of how to calculate the motion of a zone.

I may not address my question clearly. My code is compiled with no error and it can run in the simulation. So I think the only possible problem is that I did not update the boundary vertex coordinate correctly.

Thus, my question is how to update the vertex coordinates in CONVERGE.

I appreciate for your quick reply again!
tmy is offline   Reply With Quote

Old   October 26, 2017, 16:42
Default
  #5
Member
 
tmburton's Avatar
 
Tristan Burton
Join Date: Sep 2017
Posts: 77
Rep Power: 2
tmburton is on a distinguished road
Mingyuan,

Why are you using a UDF to set a constant boundary velocity?

Best regards,

Tristan
__________________
Tristan Burton
Senior Principal Engineer
CONVERGECFD
tmburton is offline   Reply With Quote

Old   October 26, 2017, 17:10
Default
  #6
tmy
New Member
 
Mingyuan Tao
Join Date: Mar 2016
Posts: 12
Rep Power: 3
tmy is on a distinguished road
Hi Tristan,

Finally my boundary will move based on some variables I calculated in my simulation, which, will vary with respect to time, so right now I am just trying to figure out how to control the boundary movement manually starting from assuming a simple velocity.
tmy is offline   Reply With Quote

Old   October 27, 2017, 09:54
Default
  #7
tmy
New Member
 
Mingyuan Tao
Join Date: Mar 2016
Posts: 12
Rep Power: 3
tmy is on a distinguished road
Hi Tristan,

Thanks for your reply, I have figured out how to control the movement of my boundary using motion.c.

There is one further question I want to ask. My moving boundary is rectangular with z ranging from -0.000225 to 0.000225, but when I use the following code, it prints out 4 moving nodes on this boundary with much smaller z values: 0.000000024 and -0.000000024. Why does this happen?

Here are the codes:
for(ii=0;ii<boundary_list[bound_index].num_moving_nodes;ii++)
{
vertnum = boundary_list[bound_index].moving_node_list[ii];
printf("verts.x2:%f\n",surface_verts[vertnum].x[2]);
}
tmy is offline   Reply With Quote

Old   October 30, 2017, 08:04
Default
  #8
Member
 
nitesh.attal's Avatar
 
Nitesh Attal
Join Date: Sep 2017
Location: Convergent Science, Northville MI
Posts: 32
Rep Power: 2
nitesh.attal is on a distinguished road
Quote:
Originally Posted by tmy View Post
Hi Tristan,

Thanks for your reply, I have figured out how to control the movement of my boundary using motion.c.

There is one further question I want to ask. My moving boundary is rectangular with z ranging from -0.000225 to 0.000225, but when I use the following code, it prints out 4 moving nodes on this boundary with much smaller z values: 0.000000024 and -0.000000024. Why does this happen?

Here are the codes:
for(ii=0;ii<boundary_list[bound_index].num_moving_nodes;ii++)
{
vertnum = boundary_list[bound_index].moving_node_list[ii];
printf("verts.x2:%f\n",surface_verts[vertnum].x[2]);
}
Hello Mingyuan,

It is a difficult to debug without looking at the complete code. Shared below is a snippet of a UDF I wrote to change the outflow radius of a circular pipe with time. I hope the comments help you resolve the issue, otherwise please share your case with support@convergecfd.com.

##############################################

//---------------------------------------------------------------------------------------------
// this routine is called at the beginning of every time step, after user_motion_update_tm1
int user_motion_get_position_velocity(int bound_index)
{
int ii, vertnum;

// set new position for this boundary's vertices
for(ii=0;ii<boundary_list[bound_index].num_moving_nodes;ii++)
{
vertnum = boundary_list[bound_index].moving_node_list[ii];
user_motion_calc_moving_vector_vertex(0, bound_index, vertnum);
}

return 0;
}

//---------------------------------------------------------------------------------------------
// calc motion vector of each vertex
int user_motion_calc_moving_vector_vertex(int call_flag, int bound_index, int vertnum)
{
double r_init,r_max, x_new, x_old, y_new, y_old, r_new, r_old;

r_init = 0.01; // initial radius of the outflow boundary (corresponds to surface.dat)
r_max = 1.5e-2-1.0e-4; // Max radius of the outflow bounday (corresponds to a value slightly
// smaller than the outer radius of the nozzle lip in surface.dat)

// How does the ourflow radius change with time?
r_new = r_init+2.0*0.0025*sin(2.0*PI/5.0e-3*(simtime + start_time)+PI);

// Get the current location of a vertex on the outflow boundary
x_old = surface_verts[vertnum].x[0];
y_old = surface_verts[vertnum].x[1];

// Calculate the radial location of the vertex
r_old = sqrt(x_old*x_old + y_old*y_old);

// Calculate the new location of the vertex (similar triangle rule)
x_new = r_new/r_old*x_old;
y_new = r_new/r_old*y_old;


// Calculate the amount to be moved in x, y and z directions
// And move the vertex shared by the outflow and nozzle lip
// Ensure that the new location less than max allowed
if( ((r_old < r_max) && (r_new < r_max)) )
{
surface_verts[vertnum].move_vec[0] = x_new - x_old;
surface_verts[vertnum].move_vec[1] = y_new - y_old;
surface_verts[vertnum].move_vec[2] = 0.0;
}
else
{
surface_verts[vertnum].move_vec[0] = 0.0;
surface_verts[vertnum].move_vec[1] = 0.0;
surface_verts[vertnum].move_vec[2] = 0.0;
}

return 0;
}

##############################################
__________________
Nitesh Attal
Research Engineer | Applications
CONVERGECFD
nitesh.attal is offline   Reply With Quote

Old   November 30, 2017, 17:33
Default
  #9
tmy
New Member
 
Mingyuan Tao
Join Date: Mar 2016
Posts: 12
Rep Power: 3
tmy is on a distinguished road
Hi Nitesh,

Sorry for the late reply. Your code here helps a lot! My code is still not working correctly. I have emailed to the CONVERGE team for help! I will also further check my codes and post any questions here! Thanks again for your help.
tmy is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stefan Problem : Tin Melting : Moving Boundary swparth OpenFOAM 0 September 21, 2017 14:53
Moving boundary problem based on calculated data sandro.grm OpenFOAM Programming & Development 42 August 4, 2017 08:42
Writing udf for Transient Heat conduction boundary value problem abhi12019 FLUENT 3 October 7, 2015 09:10
Radiation interface hinca CFX 15 January 26, 2014 18:11
Error finding variable "THERMX" sunilpatil CFX 8 April 26, 2013 07:00


All times are GMT -4. The time now is 02:20.