CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF Rotation (https://www.cfd-online.com/Forums/fluent-udf/87300-udf-rotation.html)

lepetitmort April 16, 2011 08:51

UDF Rotation
 
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?

Amir April 16, 2011 14:03

omega[0] : x-component
omega[1] : y-component
omega[2] : z-component

lepetitmort April 16, 2011 14:18

THX a lot! First Problem is solved.

But how can I decide around which point my object rotate? Center of Gravity maybe?

Amir April 16, 2011 16:02

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 April 16, 2011 17:15

Thx I will try this :)

AlbertoP June 19, 2011 13:24

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

Amir June 19, 2011 15:21

Quote:

Originally Posted by AlbertoP (Post 312635)
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

AlbertoP June 25, 2011 17:42

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

Amir June 26, 2011 01:32

Quote:

Originally Posted by AlbertoP (Post 313574)
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?

AlbertoP June 26, 2011 20:00

Hi,

yes I did everything you wrote on your first message... Thanks...

Amir June 28, 2011 10:49

Quote:

Originally Posted by AlbertoP (Post 313655)
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?

AlbertoP June 28, 2011 18:41

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

Amir June 29, 2011 08:36

Quote:

Originally Posted by AlbertoP (Post 313963)
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

AlbertoP July 4, 2011 19:14

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 <stdio.h>
#include <math.h>
#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

http://img641.imageshack.us/img641/3...vevolumes2.png
http://img708.imageshack.us/img708/4...ivevolumes.png

AlbertoP July 4, 2011 19:17

ps: if you need the entire case file I can send it by e-mail... Thanks!

mecamor July 4, 2011 20:52

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

Amir July 5, 2011 02:12

Quote:

Originally Posted by AlbertoP (Post 314691)
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

Amir July 5, 2011 02:16

Quote:

Originally Posted by mecamor (Post 314698)
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

mecamor July 5, 2011 08:29

hello
I use moving wall ... but it does not move. I work unsteady. piston speed is 10m / s

mecamor July 5, 2011 08:42

how I should set conditions to limit the piston with moving wall so that the piston moves


All times are GMT -4. The time now is 09:54.