Udf for moving circular edge
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); } |
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] |
More help....
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 |
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, |
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 |
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. |
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 |
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, |
1 Attachment(s)
Hi Amir,
My files are attached. Thank you for your help, sarit |
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?
|
I tried to do that, but than I get that the parts don't connect smoothly, even when the mesh is denser.
|
All times are GMT -4. The time now is 08:10. |