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/)
-   -   Can someone help me with a UDF for a simple rotatory geometry?? (https://www.cfd-online.com/Forums/fluent-udf/121636-can-someone-help-me-udf-simple-rotatory-geometry.html)

Maralady August 1, 2013 22:00

Can someone help me with a UDF for a simple rotatory geometry??
 
1 Attachment(s)
Hello, I am trying to create a code to this geometry, as you can see at the images it is a simple geometry, it is a pipe with 2 bodies rotating inside, so far I have been reading the UDF manual, and I made a code I would like to make some questions but first here is the code:

#include "udf.h"

DEFINE_CG_MOTION(Rotation,dt,vel,omega,time,dtime)
{
Thread *t;
face_t f;

/*reset velocities*/
NV_S(vel, =, 0.0);
NV_S(omega, =, 0.0);

/*not too sure what this is for*/
if (!Data_Valid_P())
return;
/*get the thread pointer for which this motion is defines (I assume that this is the cell zone that I made)*/
t = DT_THREAD(dt);

/* motion */
velocity[0] = 0;
velocity[1] = 0;
velocity[2] = 0;
omega[0] = 0;
omega[1] = 0;
/*This will be just a random number, I will try different values anyway*/
omega[2] = 120;
/*not sure how to do the loop and if I should make the loop for faces or cells*/
}



Question 1: Do I have to create a UDF for each body? Or can I include both bodies at the same UDF?

Question 2: Well as you can see at the code, I am not quite sure of how to make the loop (I have a decent programming knowledge, and because of this forced to learn C, I know how to create a loop, but I do not know what variables to include for the loop, so far I know the pointer will tell the program to use some faces/cells and that leads me to my other question)

Question 3: Should I use faces or cells for the Loop?

Question 4: There is something that I am missing?

I read just the first 2 chapters of the UDF guide, I will finish all the guide soon, but I think that the next chapters will not clear those doubts.

Thanks

Maralady August 1, 2013 23:25

Sorry wrong forum

Maralady August 2, 2013 17:23

I would like to know if I should use the cells or the faces, so far I understand that I should use the faces because that will make the adjacent cells to move as well and that is what I am looking for

vasava August 5, 2013 08:07

Question 1: You do not need separate UDFs unless you have different rotational speed for each body. Yes you can use one UDF for several bodies.

Question 2: For simple rotational and translational motion there seem to be nothing wrong with the UDF.

Instead of what you have you may use

#include "udf.h"

DEFINE_CG_MOTION(Rotation,dt,vel,omega,time,dtime)
{
/* motion */
velocity[0] = 0;
velocity[1] = 0;
velocity[2] = 0;
omega[0] = 0;
omega[1] = 0;
/*This will be just a random number, I will try different values anyway*/
omega[2] = 120;
/*not sure how to do the loop and if I should make the loop for faces or cells*/
}


Question 3: I dont think so.

Question 4: Again this is good enough for simple rotationg motion.

Make sure you have your Dynamic mesh settings right.

Maralady August 5, 2013 15:51

Vasava thanks for your reply, sadly I have to use 2 UDF because I have the same angular velocity but in different directions, therefore I will have to create a new UDF exactly the same but with Omega[2] = -120 instead of Omega[2] = 120, anyway I will try this today and post here the experience, to help others with the same problem, thanks again.

Maralady August 7, 2013 23:37

I will try your advice tomorrow thanks for it

Maralady August 8, 2013 21:15

Now I am getting this error:

The UDF library you are trying to load (libudf) is not compiled for 3ddp on the current platform (win64).
The system cannot find the file specified.

Not idea what it is

Saw different posts but none of them were solved

vasava August 9, 2013 00:55

1 Attachment(s)
You need to setup your visual c++ and SDK right. Here is a document that can help you.

Maralady August 9, 2013 17:33

Thank you Mr.Vasava you have been very helpful

Maralady August 9, 2013 20:54

My CMD shell says at the end v6.0 instead of v7.0, would this generate errors? Or I am able to work with this?

Maralady August 9, 2013 21:14

I uploaded my code and I got this warning

Rotation.c
..\..\src\Rotation.c(6) : error C2065: 'velocity' : undeclared identifier
..\..\src\Rotation.c(6) : error C2109: subscript requires array or pointer type
..\..\src\Rotation.c(7) : error C2109: subscript requires array or pointer type
..\..\src\Rotation.c(8) : error C2109: subscript requires array or pointer type

I fixed the first one (pretty obvious) and I will work on the other ones.

Maralady August 9, 2013 21:19

Looks like it was enough to just modify Velocity to Vel

Maralady August 9, 2013 23:04

When I build the udf everything is fine, when I load the library everything is fine when I save everything is fine, when I close the program and try to open the same case again I got this error from the fluent console

Auto-compilation of "libudf" failed. Please try to compile it manually.
Opening library "C:\Users\Arthur\Desktop\Rotation2_files\dp0\FFF\F luent\libudf"...
Error: The UDF library you are trying to load (libudf) is not compiled for 3ddp on the current platform (win64).

Somehow is not working...

vasava August 12, 2013 01:28

The error 'The UDF library you are trying....' means that your UDF has not been compiled.

The answers to 'how to fix?' lies in the errors:
..\..\src\Rotation.c(6) : error C2065: 'velocity' : undeclared identifier
..\..\src\Rotation.c(6) : error C2109: subscript requires array or pointer type
..\..\src\Rotation.c(7) : error C2109: subscript requires array or pointer type
..\..\src\Rotation.c(8) : error C2109: subscript requires array or pointer type


Usually these errors even pin-point to the line where these errors occur. If you post your UDF here we can try to fix it.

eaxbca August 12, 2013 08:23

Try the following UDF, it is from the gear pump tutorial. You don't need to specify zero values because defaults are zero.
Check you that tutorial how to setup dynamic mesh parameters etc.
#include "udf.h"

DEFINE_CG_MOTION(object1, dt, vel, omega, time, dtime)
{
Domain *domain;
domain = Get_Domain(1);
omega[2]=-220.;
}

DEFINE_CG_MOTION(object2, dt, vel, omega, time, dtime)
{
Domain *domain;
domain = Get_Domain(1);
omega[2]=220.;
}


All times are GMT -4. The time now is 19:08.