|
[Sponsors] |
August 21, 2011, 09:59 |
Udf for moving circular edge
|
#1 |
Member
anonymous
Join Date: Feb 2011
Posts: 50
Rep Power: 15 |
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); } |
|
August 21, 2011, 10:45 |
|
#2 |
Senior Member
|
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 |
|
August 23, 2011, 10:24 |
More help....
|
#3 |
Member
anonymous
Join Date: Feb 2011
Posts: 50
Rep Power: 15 |
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 |
|
August 23, 2011, 10:46 |
|
#4 |
Senior Member
|
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 |
|
August 23, 2011, 10:56 |
|
#5 |
Member
anonymous
Join Date: Feb 2011
Posts: 50
Rep Power: 15 |
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 |
|
August 23, 2011, 11:08 |
|
#6 |
Senior Member
|
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 |
|
August 24, 2011, 02:23 |
|
#7 |
Member
anonymous
Join Date: Feb 2011
Posts: 50
Rep Power: 15 |
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 |
|
August 24, 2011, 04:12 |
|
#8 | |
Senior Member
|
Quote:
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 |
||
August 24, 2011, 05:55 |
|
#9 |
Member
anonymous
Join Date: Feb 2011
Posts: 50
Rep Power: 15 |
Hi Amir,
My files are attached. Thank you for your help, sarit |
|
August 24, 2011, 08:00 |
|
#11 |
Member
anonymous
Join Date: Feb 2011
Posts: 50
Rep Power: 15 |
I tried to do that, but than I get that the parts don't connect smoothly, even when the mesh is denser.
|
|
|
|
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 |