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

Udf for moving circular edge

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 21, 2011, 09:59
Default Udf for moving circular edge
  #1
noa
Member
 
anonymous
Join Date: Feb 2011
Posts: 50
Rep Power: 15
noa is on a distinguished road
I have a 2D channel that its edge is circular. I am moving the walls in y direction and this working. However, when I am not able to move the circular edge. This is the UDF I am using...


#include "udf.h"
#include "mem.h"
#include "dynamesh_tools.h"
/* Constants */
#define b 1.5e-3
#define T 20
#define a 0.0e-3
#define a1 10e-3
#define b1 0.5e-3
#define R 0.5e-3
#define phi 3.1415926535897932384626433832795
#define L 50
#define EdgeHeight 1.0e-3
/************************************************** ***/

DEFINE_GEOM(outlet,domain,dt,position)
{
Thread *tf = DT_THREAD (dt);
face_t f;
Node *node_p;
real x, y;
int n;

SET_DEFORMING_THREAD_FLAG (THREAD_T0 (tf));

begin_f_loop (f, tf)
{
f_node_loop (f, tf, n)
{
node_p = F_NODE (f, tf, n);
if (NODE_POS_NEED_UPDATE (node_p))
{
NODE_POS_UPDATED (node_p);
x = NODE_X (node_p);



y[0]=sqrt(fabs(pow(R,2)-pow((x-a1),2)))+(b1+CURRENT_TIME/T);

y[1]=-sqrt(fabs(pow(R,2)-pow((x-a1),2)))+(b1+CURRENT_TIME/T);

NODE_Y (node_p) = y;
}
}
}
end_f_loop (f, tf);
}
noa is offline   Reply With Quote

Old   August 21, 2011, 10:45
Default
  #2
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Hi noa,
there are some inconsistencies in your code! maybe you mean:
real x, y[2];
y[0]=...;
y[1]=...;
NODE_Y (node_p) = y;// you have to assign it with a scalar not vector, y[0] or y[1]
__________________
Amir
Amir is offline   Reply With Quote

Old   August 23, 2011, 10:24
Default More help....
  #3
noa
Member
 
anonymous
Join Date: Feb 2011
Posts: 50
Rep Power: 15
noa is on a distinguished road
Hi Amir,

Thank you very much for your help.
My model is built from half circle at its edge. every x has two y values.
However, when I change my udf and define y as vector, its not working since Node_y gets scalar only.


#include "udf.h"
#include "mem.h"
#include "dynamesh_tools.h"

/* Constants */
#define b 0
#define T 20
#define a 0.0e-3
#define a1 10e-3
#define b1 0.5e-3
#define R 0.5e-3
#define phi 3.1415926535897932384626433832795

#define L 50
#define EdgeHeight 1.0e-3

/************************************************** ***/



DEFINE_GEOM(outlet,domain,dt,position)

{
Thread *tf = DT_THREAD (dt);
face_t f;
Node *node_p;
real x, y[2];
int n;

SET_DEFORMING_THREAD_FLAG (THREAD_T0 (tf));


begin_f_loop (f, tf)
{
f_node_loop (f, tf, n)
{
node_p = F_NODE (f, tf, n);

if (NODE_POS_NEED_UPDATE (node_p))
{
NODE_POS_UPDATED (node_p);

x = NODE_X (node_p);



y[0]=sqrt(fabs(pow(R,2)-pow((x-a1),2)))+(b1+CURRENT_TIME/T);

y[1]=-sqrt(fabs(pow(R,2)-pow((x-a1),2)))+(b1+CURRENT_TIME/T);

NODE_Y (node_p) = y[0];


}
}
}
end_f_loop (f, tf);
}






Thank you
noa is offline   Reply With Quote

Old   August 23, 2011, 10:46
Default
  #4
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Hi,
you can use a if-clause or a compatible statement like this:
real y;
y=NODE_Y(node_p)/abs(NODE_Y(node_p))*sqrt(fabs(pow(R,2)-pow((x-a1),2)))+(b1+CURRENT_TIME/T);

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   August 23, 2011, 10:56
Default
  #5
noa
Member
 
anonymous
Join Date: Feb 2011
Posts: 50
Rep Power: 15
noa is on a distinguished road
I am sorry to bug u again but still I am not sure I got it.

I wish I could use IF but in this case of the half circle I have 2 y for every x and there is not a If statement I can use.

I didn't understand why u used

y=NODE_Y(node_p)/....


Thank you
noa is offline   Reply With Quote

Old   August 23, 2011, 11:08
Default
  #6
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Ok, every x has 2 y (in circular arch one + and another -) right?
so you can use if clause (if y>0 then ... else ....)
Or, because the difference is just in a negative mark use such compatible mode.
__________________
Amir
Amir is offline   Reply With Quote

Old   August 24, 2011, 02:23
Default
  #7
noa
Member
 
anonymous
Join Date: Feb 2011
Posts: 50
Rep Power: 15
noa is on a distinguished road
Hi Amir,

Thank you for your respond.


I can't use If statement since that half circle is not located on the X axis, its moving along the Y axis.


Thank you,
sarit
noa is offline   Reply With Quote

Old   August 24, 2011, 04:12
Default
  #8
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Quote:
Originally Posted by noa View Post
Hi Amir,

Thank you for your respond.


I can't use If statement since that half circle is not located on the X axis, its moving along the Y axis.


Thank you,
sarit
Dear noa,
It doesn't matter; I just wanted to show the procedure; you can use both methods in this case as well. Here you have to know movement of the interface between 2 y. Suppose the interface moves with this function f(t); then you can substitute this instead of 0 in if-clause. Anyway, if you can post your geometry and your desired moving function, I may help you better.

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   August 24, 2011, 05:55
Default
  #9
noa
Member
 
anonymous
Join Date: Feb 2011
Posts: 50
Rep Power: 15
noa is on a distinguished road
Hi Amir,


My files are attached.

Thank you for your help,

sarit
Attached Files
File Type: zip wall40.zip (55.7 KB, 6 views)
noa is offline   Reply With Quote

Old   August 24, 2011, 07:33
Default
  #10
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Why don't you separate your outlet and define 2 macro for each(upper_outlet and lower_outlet)? in this case each x has only one y?
__________________
Amir
Amir is offline   Reply With Quote

Old   August 24, 2011, 08:00
Default
  #11
noa
Member
 
anonymous
Join Date: Feb 2011
Posts: 50
Rep Power: 15
noa is on a distinguished road
I tried to do that, but than I get that the parts don't connect smoothly, even when the mesh is denser.
noa 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF Compilation Error - Loading Library - COMMON Problem! Help! robtheslob Fluent UDF and Scheme Programming 8 July 24, 2015 01:53
velocity profile UDF on porous jump edge mani1455 Fluent UDF and Scheme Programming 5 February 21, 2015 06:31
calculating cell edge length in 2D and call UDM into other udf code pibea Fluent UDF and Scheme Programming 0 November 30, 2014 06:27
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55
[Commercial meshers] Star mesh import problem chris1980 OpenFOAM Meshing & Mesh Conversion 20 May 8, 2006 02:07


All times are GMT -4. The time now is 06:52.