CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF: DEFINE_CG_MOTION for vertical jump motion of an electrode! (http://www.cfd-online.com/Forums/fluent-udf/65278-udf-define_cg_motion-vertical-jump-motion-electrode.html)

 alban June 10, 2009 08:56

UDF: DEFINE_CG_MOTION for vertical jump motion of an electrode!

Hello everybody,

I have to create a DEFINE_CG_MOTION udf for my 2D CFD model (Fluent 6.3).
It consists in one electrode (rectangular shape) which just translate verticaly (y-direction) into a cavity of the same shape (the move looks like a jump like a piston in a cylinder, with no rotation !).
I want to describe the jump in function of the flow-time « tm » , with a sine function, where i can play on two parameters, the magnitude « h » of the jump and the its duration « t » (return in the down position).
This UDF will allow me to use dynamic mesh, and layering to study the hydrodynamic of the fluid between the electrode and the cavity hole during the jump (there is a small gap into this space...)

With the several CG_MOTION udf exemples i have found on the net i have wrote this but it doesnt work !!!

(I’d like to work with this UDF on parallel processing (2 cores of my laptop), should I have to add some commands in my UDF or not ???)

I thank you so much…for the help and the time you have spend for me :-)

------------------------------------------------------------------------------------------------
#include <udf.h>
#include "dynamesh_tools.h"

/*I lock the five others degree of freedom that i am not using for the jump*/
static real v_x=0.0, v_z=0.0, omega_x=0.0, omega_y=0.0, omega_z=0.0;

DEFINE_CG_MOTION(jump_electrode, dt, vel, omega, time, dtime)
{
face_t f;

real t=0.5 /*Height of the jump*/
real h=0.05 /*Duration of the jump*/
real tm=RP_Get_Real("flow-time")

/* speed initialisation */
NV_S (vel, =, 0.0); /*I don’t know if it is useful to write these lines in my case*/
NV_S (omega, =, 0.0);

/* error message */
if (!Data_Valid_P ())
{
Message("Not good at all!\n")
return;
}

/* jump kinematic function */
vel[1] = (h*3.1415*2/t)*cos((3.1415*tm*2/t)-3.1415/2); /*in the y direction*/

/* Displaying */
Message("\ntime=%f, y=%f, Vy=%f",time,x_cg[1],vel[1]);
return
}
---------------------------------------------------------------------------------
there is the error message i receved before the fatal error... i don't really understand how to avoid it... maybe it can help you

..\..\src\cinematique2.c(8) : error C2065: 't' : undeclared identifier
..\..\src\cinematique2.c(8) : warning C4047: 'initializing' : 'struct thread_struct *' differs in levels of indirection from 'int '
..\..\src\cinematique2.c(10) : error C2065: 'x_cg' : undeclared identifier
..\..\src\cinematique2.c(10) : error C2109: subscript requires array or pointer type
..\..\src\cinematique2.c(12) : error C2275: 'real' : illegal use of this type as an expression
c:\fluent.inc\fluent6.3.26\src\global.h(158) : see declaration of 'real'
..\..\src\cinematique2.c(12) : error C2146: syntax error : missing ';' before identifier 't'
..\..\src\cinematique2.c(13) : error C2146: syntax error : missing ';' before identifier 'real'
..\..\src\cinematique2.c(13) : error C2275: 'real' : illegal use of this type as an expression
c:\fluent.inc\fluent6.3.26\src\global.h(158) : see declaration of 'real'
..\..\src\cinematique2.c(13) : error C2146: syntax error : missing ';' before identifier 'h'
..\..\src\cinematique2.c(13) : error C2065: 'h' : undeclared identifier
..\..\src\cinematique2.c(14) : error C2146: syntax error : missing ';' before identifier 'real'
..\..\src\cinematique2.c(14) : error C2275: 'real' : illegal use of this type as an expression
c:\fluent.inc\fluent6.3.26\src\global.h(158) : see declaration of 'real'
..\..\src\cinematique2.c(14) : error C2146: syntax error : missing ';' before identifier 'tm'
..\..\src\cinematique2.c(14) : error C2065: 'tm' : undeclared identifier
..\..\src\cinematique2.c(17) : error C2064: term does not evaluate to a function
..\..\src\cinematique2.c(24) : error C2143: syntax error : missing ';' before 'return'
..\..\src\cinematique2.c(31) : error C2109: subscript requires array or pointer type
..\..\src\cinematique2.c(33) : error C2143: syntax error : missing ';' before '}'
(system "copy c:\fluent.inc\fluent6.3.26\src\makefile_nt.udf libudf\ntx86\2d_node\makefile")
1 fichier(s) copi‚(s).
(chdir "libudf")()
(chdir "ntx86\2d_node")()
cinematique2.c
..\..\src\cinematique2.c(8) : error C2065: 't' : undeclared identifier
..\..\src\cinematique2.c(8) : warning C4047: 'initializing' : 'struct thread_struct *' differs in levels of indirection from 'int '
..\..\src\cinematique2.c(10) : error C2065: 'x_cg' : undeclared identifier
..\..\src\cinematique2.c(10) : error C2109: subscript requires array or pointer type
..\..\src\cinematique2.c(12) : error C2275: 'real' : illegal use of this type as an expression
c:\fluent.inc\fluent6.3.26\src\global.h(158) : see declaration of 'real'
..\..\src\cinematique2.c(12) : error C2146: syntax error : missing ';' before identifier 't'
..\..\src\cinematique2.c(13) : error C2146: syntax error : missing ';' before identifier 'real'
..\..\src\cinematique2.c(13) : error C2275: 'real' : illegal use of this type as an expression
c:\fluent.inc\fluent6.3.26\src\global.h(158) : see declaration of 'real'
..\..\src\cinematique2.c(13) : error C2146: syntax error : missing ';' before identifier 'h'
..\..\src\cinematique2.c(13) : error C2065: 'h' : undeclared identifier
..\..\src\cinematique2.c(14) : error C2146: syntax error : missing ';' before identifier 'real'
..\..\src\cinematique2.c(14) : error C2275: 'real' : illegal use of this type as an expression
c:\fluent.inc\fluent6.3.26\src\global.h(158) : see declaration of 'real'
..\..\src\cinematique2.c(14) : error C2146: syntax error : missing ';' before identifier 'tm'
..\..\src\cinematique2.c(14) : error C2065: 'tm' : undeclared identifier
..\..\src\cinematique2.c(17) : error C2064: term does not evaluate to a function
..\..\src\cinematique2.c(24) : error C2143: syntax error : missing ';' before 'return'
..\..\src\cinematique2.c(31) : error C2109: subscript requires array or pointer type
..\..\src\cinematique2.c(33) : error C2143: syntax error : missing ';' before '}'
-----------------------------------------------------
THANKS AGAIN FOR THE HELP

 iman_1844 May 28, 2010 15:31

it has many errors,