# UDF Rotation

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

 April 16, 2011, 08:51 UDF Rotation #1 New Member   Hans Johans Join Date: Apr 2011 Posts: 6 Rep Power: 7 I want to rotate a object and I am using a UDF. The user manual says that I should use the variable omega, but using this code: DEFINE_CG_MOTION(....) { omega[1]=30; } I get a horizontal movement (or maybe a rotation with a very big circle, so that it looks like a horizontal movement) Can somebody see my prob? what does the X in variable[X] exactly mean?

 April 16, 2011, 14:03 #2 Senior Member     Amir Join Date: May 2009 Location: Montreal, QC Posts: 739 Blog Entries: 1 Rep Power: 15 omega[0] : x-component omega[1] : y-component omega[2] : z-component lepetitmort and jugurtha like this.

 April 16, 2011, 14:18 #3 New Member   Hans Johans Join Date: Apr 2011 Posts: 6 Rep Power: 7 THX a lot! First Problem is solved. But how can I decide around which point my object rotate? Center of Gravity maybe?

 April 16, 2011, 16:02 #4 Senior Member     Amir Join Date: May 2009 Location: Montreal, QC Posts: 739 Blog Entries: 1 Rep Power: 15 I think so. you can see your grid motion in (solve->grid motion) to make sure about that before running. I've used DEFINE_GRID_MOTION before, if you can't handle that with DEFINE_CG_MOTION, try this general macro. lepetitmort likes this.

 April 16, 2011, 17:15 #5 New Member   Hans Johans Join Date: Apr 2011 Posts: 6 Rep Power: 7 Thx I will try this

 June 19, 2011, 13:24 #6 Member   Alberto Pellegrino Join Date: Jan 2011 Posts: 32 Rep Power: 7 Hi Amir, I'm trying to create a sinusoidal motion of a circular grid that contains the airfoil (pitching). And the circular grid (quad) is inside a tri-grid supposed to remain static. Reading on cfd-online I have not figured out yet if I need to use DEFINE_CG_MOTION or DEFINE_GRID_MOTION... - Please can you explain what you know about that? - Must the node at the interface (between rotating quad-mesh and static tri-mesh) be merged or not? - What setting on Fluent about dynamic mesh? I mean, smoothing, layering, remeshing, or nothing? - Could you kindly show me the "general macro" you mentioned above, I would really appreciate your help. Many thanks! Kind regards, Alberto

June 19, 2011, 15:21
#7
Senior Member

Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 739
Blog Entries: 1
Rep Power: 15
Quote:
 Originally Posted by AlbertoP Hi Amir, I'm trying to create a sinusoidal motion of a circular grid that contains the airfoil (pitching). And the circular grid (quad) is inside a tri-grid supposed to remain static. Reading on cfd-online I have not figured out yet if I need to use DEFINE_CG_MOTION or DEFINE_GRID_MOTION... - Please can you explain what you know about that? - Must the node at the interface (between rotating quad-mesh and static tri-mesh) be merged or not? - What setting on Fluent about dynamic mesh? I mean, smoothing, layering, remeshing, or nothing? - Could you kindly show me the "general macro" you mentioned above, I would really appreciate your help. Many thanks! Kind regards, Alberto
Hi Alberto,
According to the UDF manual, DEFINE_CG_MOTION can be used for solid body motion; on the other hand, DEFINE_GRID_MOTION is more general, even you can define specific functions for each node.
For your case, I propose you to use DEFINE_CG_MOTION without any additional setting, and for this purpose, you have to use interfaces (non-conformal mesh) between to different zones in order to let them slide on each other.
You can also use general macro, i.e. DEFINE_GRID_MOTION to rotate inner zone sinusoidally with the same setting with the previous one, but here, you have to define a rotation matrix instead which is not recommended for your case.

Regards,

Amir

 June 25, 2011, 17:42 #8 Member   Alberto Pellegrino Join Date: Jan 2011 Posts: 32 Rep Power: 7 Thank you Amir for your quick reply. After have facing the problem of compiling the UDF since I didn't have VC++ installed...now I have the negative volume problem. Specifying, when I go for a Mesh Motion Preview on Fluent, I got this error message: "Update-Dynamic-Mesh failed. Negative cell volume detected". Any idea please? Many thanks. Kind regards, Alberto

June 26, 2011, 01:32
#9
Senior Member

Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 739
Blog Entries: 1
Rep Power: 15
Quote:
 Originally Posted by AlbertoP Thank you Amir for your quick reply. After have facing the problem of compiling the UDF since I didn't have VC++ installed...now I have the negative volume problem. Specifying, when I go for a Mesh Motion Preview on Fluent, I got this error message: "Update-Dynamic-Mesh failed. Negative cell volume detected". Any idea please? Many thanks. Kind regards, Alberto
Hi,
did you create interfaces in order to let them slide on each other?

 June 26, 2011, 20:00 #10 Member   Alberto Pellegrino Join Date: Jan 2011 Posts: 32 Rep Power: 7 Hi, yes I did everything you wrote on your first message... Thanks...

June 28, 2011, 10:49
#11
Senior Member

Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 739
Blog Entries: 1
Rep Power: 15
Quote:
 Originally Posted by AlbertoP Hi, yes I did everything you wrote on your first message... Thanks...
Hi,
Did you hook it to appropriate zones (interior and interface) and are you sure about UDF correctness?

 June 28, 2011, 18:41 #12 Member   Alberto Pellegrino Join Date: Jan 2011 Posts: 32 Rep Power: 7 Hi, yes the UDF is correct, but maybe I did wrong in hooking it: my idea was to hook it to the wall (airfoil) which makes rotate the inner mesh (free to rotate as interfaced and not conforming). But.. you said that I need to hook to the interface or to the inner mesh? In this case it would be a grid_motion instead of a cg_motion (referring to a body)...am I wrong? So, please, can you clarify this point..so I will not bother you again.. Many thanks again... Alberto

June 29, 2011, 08:36
#13
Senior Member

Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 739
Blog Entries: 1
Rep Power: 15
Quote:
 Originally Posted by AlbertoP Hi, yes the UDF is correct, but maybe I did wrong in hooking it: my idea was to hook it to the wall (airfoil) which makes rotate the inner mesh (free to rotate as interfaced and not conforming). But.. you said that I need to hook to the interface or to the inner mesh? In this case it would be a grid_motion instead of a cg_motion (referring to a body)...am I wrong? So, please, can you clarify this point..so I will not bother you again.. Many thanks again... Alberto
Dear Alberto,
you have to hook it over everything in inner part (walls-interiors-one of the interfaces) except fluid zone and this not depend on your macro.

Regards,

Amir

 July 4, 2011, 19:14 #14 Member   Alberto Pellegrino Join Date: Jan 2011 Posts: 32 Rep Power: 7 Dear Amir, very sorry to bother you again...but I cannot solve my problem. As you can see in the images below, the profile moves, while the mesh around it remains steady, so that's why I got negative volumes error. So maybe the UDF is not so correct like I thought, or I am wrong whit some settings. Now, to avoid further waste of time...I'll copy my UDF and my settings, so you will be able to figure out what is wrong, I hope... UDF: #include #include #include "udf.h" DEFINE_CG_MOTION(airfoil_pitch, dt, vel, omega, time, dtime) { real pitchampl, pitchdispl, omg, pi, count; pi = 3.14159265; /* reset velocities */ NV_S (vel, =, 0.0); NV_S (omega, =, 0.0); /* motion */ pitchampl = 2 * pi / 180; /* angular pitch amplitude */ omg = 2 * pi * 20; /* angular frequency */ pitchdispl = pitchampl * sin(omg * time); /* resultant displacement */ omega[2] = pitchampl * omg * cos(omg * time); } ------ Now my principal settings: - CELL ZONE CONDITIONS: all the mesh set as steady. - MESH INTERFACES: without any option settings. - DYNAMIC MESH: activated, with the UDF hooked over the airfoil and over the interface that belongs to the inner mesh (supposed to oscillate). I don't have anything more inside of it. And no other options or methods like you said. ----- To make a disgression...what about the two walls automatically generated after the interface creation? Are them supposed to remain walls or do I have to change them? Resuming, the problem is that the inner grid is not made in motion. Can you understand why? Many thanks again for your availability. Regards, Alberto

 July 4, 2011, 19:17 #15 Member   Alberto Pellegrino Join Date: Jan 2011 Posts: 32 Rep Power: 7 ps: if you need the entire case file I can send it by e-mail... Thanks!

 July 4, 2011, 20:52 #16 New Member   mecamor Join Date: Jul 2011 Posts: 23 Rep Power: 7 hello I wanted to see the shock wave generated by a piston. My problem I can not even move my piston with moving wall. thank you for helping me

July 5, 2011, 02:12
#17
Senior Member

Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 739
Blog Entries: 1
Rep Power: 15
Quote:
 Originally Posted by AlbertoP ps: if you need the entire case file I can send it by e-mail... Thanks!
Dear Alberto,
It seems that your settings are correct and I don't think that the problem origins from walls created over interfaces. I have 2 suggestions:
1) to make sure about your UDF, hook it to the whole domain and check whether it works or not.
2) after you have changed dynamic mesh settings, it's better to write your case and read it again and then see grid motion panel.
if you don't have any progress, send it to my E-mail.

Amir

July 5, 2011, 02:16
#18
Senior Member

Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 739
Blog Entries: 1
Rep Power: 15
Quote:
 Originally Posted by mecamor hello I wanted to see the shock wave generated by a piston. My problem I can not even move my piston with moving wall. thank you for helping me
Hi,
if you use moving wall, you have just set a boundary condition over that and it wouldn't move. To achieve you purpose, you have to use dynamic mesh instead which as I know, there is special kind for moving piston in cylinder.

Regards,

Amir

 July 5, 2011, 08:29 #19 New Member   mecamor Join Date: Jul 2011 Posts: 23 Rep Power: 7 hello I use moving wall ... but it does not move. I work unsteady. piston speed is 10m / s

 July 5, 2011, 08:42 #20 New Member   mecamor Join Date: Jul 2011 Posts: 23 Rep Power: 7 how I should set conditions to limit the piston with moving wall so that the piston moves

 Thread Tools Display Modes Linear Mode

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

 Similar Threads Thread Thread Starter Forum Replies Last Post araz Fluent UDF and Scheme Programming 1 January 13, 2016 03:46 Mads FLUENT 2 April 15, 2014 03:30 Mike FLUENT 3 September 27, 2011 06:46 Lorenzo FLUENT 2 October 10, 2008 10:37 araz FLUENT 0 January 2, 2005 02:12

All times are GMT -4. The time now is 15:40.