CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF for CG_motion

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 10, 2014, 12:04
Default UDF for CG_motion
  #1
New Member
 
Linh Tuan The Nguyen
Join Date: Nov 2012
Posts: 9
Rep Power: 14
linh nguyen is on a distinguished road
Hi,

I am Linh. I quite new with using UDF. I was writing this UDF using CD_MOTION Macro.

My objective is solve the amplitude of motion for single degree of freedom using Finite different method. But I have two errors:
- syntax error : missing ';' before 'type'
- subscript is not of integral type.

Here is my UDF code.

#include "udf.h"
#include "stdio.h"
#include "stdlib.h"
#include "math.h"
#include "dynamesh_tools.h"
#include "storage.h"
static real v_prev = 0.0;

FILE *fout;

DEFINE_CG_MOTION(cylinder, dt, vel, omega, time, dtime)
{
Thread *t;
Domain *d = Get_Domain(1);
face_t f;
real NV_VEC (A);
real force;
real mass = 1.443;
real wn = 0.183;
real k = mass*wn*wn;
real c = 2*mass*wn*0.0072;

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

if (!Data_Valid_P ())
return;

/* get the thread pointer for which this motion is defined */
t = DT_THREAD(dt);

/* compute pressure force on body by looping through all faces */
force = 0.0;

begin_f_loop (f, t)
{
F_AREA (A, f, t);
force += F_P (f, t) * NV_MAG (A);
}
end_f_loop (f, t)

/* compute pressure amplitude of motion by Finite Different Method*/

NMAX = int(time/dtime) + 1;
real X[NMAX];
for(int i = 0; i < NMAX; i++){

X[0] = 0;
X[1] = 0;
X[i+1] = (force - X[i-1]*(mass/(dtime*dtime) - c/(2*dtime)) - X[i]*(-2*mass/(dtime*dtime) + k))/(mass/(dtime*dtime) + c/(2*dtime));
X[i+1]=DT_CG(dt)[1]; /*Assign to updated */

Message ("time = %f, force = %f, displacement = %f\n", time, force, X[i+1]);
fout = fopen("results.txt", "a");
fprintf(fout, "%f %f %f\n", time, force, X[i+1]);
fclose(fout);
}
}


Thanks for your help

Linh
linh nguyen is offline   Reply With Quote

Reply

Tags
sdof, udf cg motion


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Source Term UDF VS Porous Media Model pchoopanya Fluent UDF and Scheme Programming 1 August 28, 2013 07:12
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 22:38
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 05:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


All times are GMT -4. The time now is 01:43.