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

help me check udf

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 23, 2013, 05:55
Default help me check udf
  #1
New Member
 
tran trung
Join Date: Aug 2013
Posts: 23
Rep Power: 12
tranvantrung551987 is on a distinguished road
hello every body
i have the udf
#include "udf.h"
#include "mem.h"
/*global variables*/
real k = 722150.0; /*spring constant*/
real gravity = -9.81; /*gravity constant*/
real x_max=0.0085; /*the maximum lift is 8.5 mm*/
real f0=7126.0; /*initial spring force */
real mass=3.1928; /*spindle mass*/
real total_force=0.0;
real pressure_force=0.0; /*the total hydraulic force over the entire spindle*/
real pressure_force1=0.0; /*hydraulic force beneath the disc, in contact with inlet*/
real pressure_force2=0.0; /*hydraulic force beneath the disc outside the seat*/
real pressure_force3=0.0; /*hydraulic force beneath the shroud*/
real pressure_force4=0.0; /*hydraulic force above the spindle */
real spring_force=0.0;
real x= 0.000425; /*simulation starts with an opening of 0.425 mm*/
real velocity1=0.0;
real velocity2=0.0;
real massflow=0.0;
real total_area1=0.0;
real total_area2=0.0;
real total_area3=0.0;
real mass_flow1=0.0;
real mass_flow2=0.0;
real mass_flow3=0.0;
real timestep=0.0;
real dx=0.008075;
real velocity =0.0;
real total_time=0.0;
real time_step=0.0;
real pressure=0.0;
real inlet_pressure=0.0;
/************************************************** *********************************/
DEFINE_ADJUST(force_calculation,domain)
{
/* This function calculates the hydraulic forces acting on the spindle*/
int surface_thread_id1=26;
int surface_thread_id2=30;
int surface_thread_id3=31;
int surface_thread_id4=32;
pressure_force1=0.0;
pressure_force2=0.0;
pressure_force3=0.0;
pressure_force4=0.0;
#if !RP_HOST
Thread *thread1;
Thread *thread2;
Thread *thread3;
Thread *thread4;
face_t face; /* an integer data type that indentifies
a particular face within a face thread*/
real area[ND_ND];
/*get the thread pointer for which this motion is defined*/
thread1 = Lookup_Thread(domain,surface_thread_id1);
thread2 = Lookup_Thread(domain,surface_thread_id2);
thread3 = Lookup_Thread(domain,surface_thread_id3);
thread4 = Lookup_Thread(domain,surface_thread_id4);
/*compute pressure forces on body by looping through all faces*/
begin_f_loop(face,thread1)
if (PRINCIPAL_FACE_P(face,thread1)) /* test if the face is the principle face*/
{
F_AREA(area,face,thread1);
pressure_force1+=area[2]*F_P(face,thread1);
}
end_f_loop(face,thread1)
begin_f_loop(face,thread2)
if (PRINCIPAL_FACE_P(face,thread2))
{
F_AREA(area,face,thread2);
pressure_force2+=area[2]*F_P(face,thread2);
}
end_f_loop(face,thread2)
begin_f_loop(face,thread3)
if (PRINCIPAL_FACE_P(face,thread3))
{
F_AREA(area,face,thread3);
pressure_force3+=area[2]*F_P(face,thread3);
}
end_f_loop(face,thread)
begin_f_loop(face,thread4)
if (PRINCIPAL_FACE_P(face,thread4))
{
F_AREA(area,face,thread4);
pressure_force4+=area[2]*F_P(face,thread4);
}
end_f_loop(face,thread4)
pressure_force=pressure_force1+pressure_force2+pre ssure_force3+pressure_force4;
#endif
#if RP_NODE
/*the value from all nodes are summed*/
pressure_force = PRF_GRSUM1(pressure_force);
pressure_force1 = PRF_GRSUM1(pressure_force1);
pressure_force2 = PRF_GRSUM1(pressure_force2);
pressure_force3 = PRF_GRSUM1(pressure_force3);
pressure_force4 = PRF_GRSUM1(pressure_force4);
#endif
64
/*the data from the nodes is sent to the host*/
node_to_host_real_5(pressure_force,pressure_force1 ,
pressure_force2, pressure_force3, pressure_force4);
/************************************************** ******************************/
DEFINE_ADJUST(velocity_calculation,domain)
{
int surface_thread_id1=5;
int surface_thread_id2=34;
int surface_thread_id3=13;
total_area1=0.0;
total_area2=0.0;
total_area3=0.0;
mass_flow1=0.0;
mass_flow2=0.0;
mass_flow3=0.0;
#if !RP_HOST
Thread *thread1;
Thread *thread2;
Thread *thread3;
face_t face;
real area[ND_ND];
thread1 = Lookup_Thread(domain,surface_thread_id1);
thread2 = Lookup_Thread(domain,surface_thread_id2);
thread3 = Lookup_Thread(domain,surface_thread_id3);
begin_f_loop(face,thread1)
if (PRINCIPAL_FACE_P(face,thread1))
{
F_AREA(area,face,thread1);
total_area1 += NV_MAG(area);
mass_flow1+=F_FLUX(face,thread1);
}
end_f_loop(face,thread1)
begin_f_loop(face,thread2)
if (PRINCIPAL_FACE_P(face,thread2))
{
F_AREA(area,face,thread2);
total_area2 += NV_MAG(area);
mass_flow2+=F_FLUX(face,thread2);
}
end_f_loop(face,thread2)
begin_f_loop(face,thread3)
if (PRINCIPAL_FACE_P(face,thread3))
{
F_AREA(area,face,thread3);
total_area3 += NV_MAG(area);
mass_flow3+=F_FLUX(face,thread3);
65
}
end_f_loop(face,thread3)
#endif
#if RP_NODE
mass_flow1 = PRF_GRSUM1(mass_flow1);
mass_flow2 = PRF_GRSUM1(mass_flow2);
mass_flow3 = PRF_GRSUM1(mass_flow3);
total_area1 =PRF_GRSUM1(total_area1);
total_area2 =PRF_GRSUM1(total_area2);
total_area3 =PRF_GRSUM1(total_area3);
#endif
massflow=mass_flow1;
node_to_host_real_1(massflow);
}
/************************************************** *****************************/
DEFINE_CG_MOTION(spindle, dt, vel, omega, time, dtime)
{
/*reset velocities*/
NV_S(vel, =, 0.0);
NV_S(omega,=, 0.0); /*no angular motion*/
/*set y-component of velocity*/
vel[2] = velocity;
/*variable needed in execute_at_end*/
timestep=dtime;
}
/************************************************** ******************************/
DEFINE_EXECUTE_AT_END(Velocity)
{
/*Calculation of velocity*/
real dv=0;
real gravity_force=0.0;
spring_force=0.0;
/* calculate the total force acting on the spindle*/
gravity_force = mass*gravity;
/*calculate the spring force*/
spring_force = -k*x - f0;
/*calculate the total hydraulic force since mirror symmetry is used*/
pressure_force=pressure_force*2;
total_force=pressure_force + gravity_force + spring_force;
dv = timestep * total_force/mass;
velocity+=dv;
66
/*Restriction: stop at lift=8.5 mm*/
if (dx < 0)
{
velocity=0;
Message("\nThe valve is fully open!");
}
/*Restriction: stop if the valve is closed*/
if (dx > 0.008074)
{
if (total_force<0)
{
velocity=0;
Message("\nThe valve is fully closed");
}
}
}
/************************************************** ********************/
DEFINE_EXECUTE_AT_END(lift_movement)
{
/*Calculation of the spindle position*/
x+=timestep*velocity;
dx=x_max-x;
Message("\nThe spindle has moved %f\n", x);
total_time+=timestep;
}
/************************************************** ********************/
DEFINE_EXECUTE_AT_END(saving_values)
{
#if RP_NODE
if(myid==0)
{
FILE *data;
data = fopen("data_SST_second_order_34bar_igen.txt", "a");
fprintf(data,"%f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t
%f\t %f\n", total_time, velocity, x, pressure_force1, pressure_force2,
pressure_force3, pressure_force4, pressure_force, spring_force, total_force,
inlet_pressure, velocity1, velocity2, massflow);
fclose(data);
}
#endif
}

when complied function udf i get error
valuue.c
..\..\src\valuue.c(46) : error C2275: 'Thread' : illegal use of this type as an expression
C:\PROGRA~1\ANSYSI~1\v140\fluent\fluent14.0.0\src\ mem.h(792) : see declaration of 'Thread'
..\..\src\valuue.c(46) : error C2065: 'thread1' : undeclared identifier
..\..\src\valuue.c(47) : error C2275: 'Thread' : illegal use of this type as an expression
C:\PROGRA~1\ANSYSI~1\v140\fluent\fluent14.0.0\src\ mem.h(792) : see declaration of 'Thread'
..\..\src\valuue.c(47) : error C2065: 'thread2' : undeclared identifier
..\..\src\valuue.c(48) : error C2275: 'Thread' : illegal use of this type as an expression
C:\PROGRA~1\ANSYSI~1\v140\fluent\fluent14.0.0\src\ mem.h(792) : see declaration of 'Thread'
..\..\src\valuue.c(48) : error C2065: 'thread3' : undeclared identifier
..\..\src\valuue.c(49) : error C2275: 'Thread' : illegal use of this type as an expression
C:\PROGRA~1\ANSYSI~1\v140\fluent\fluent14.0.0\src\ mem.h(792) : see declaration of 'Thread'
..\..\src\valuue.c(49) : error C2065: 'thread4' : undeclared identifier
..\..\src\valuue.c(50) : error C2275: 'face_t' : illegal use of this type as an expression
C:\PROGRA~1\ANSYSI~1\v140\fluent\fluent14.0.0\src\ mem.h(196) : see declaration of 'face_t'
..\..\src\valuue.c(50) : error C2146: syntax error : missing ';' before identifier 'face'
..\..\src\valuue.c(50) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(52) : error C2275: 'real' : illegal use of this type as an expression
c:\program files\ansys inc\v140\fluent\fluent14.0.0\src\global.h(175) : see declaration of 'real'
..\..\src\valuue.c(52) : error C2146: syntax error : missing ';' before identifier 'area'
..\..\src\valuue.c(52) : error C2065: 'area' : undeclared identifier
..\..\src\valuue.c(52) : error C2109: subscript requires array or pointer type
..\..\src\valuue.c(54) : error C2065: 'thread1' : undeclared identifier
..\..\src\valuue.c(54) : warning C4047: '=' : 'int' differs in levels of indirection from 'Thread *'
..\..\src\valuue.c(55) : error C2065: 'thread2' : undeclared identifier
..\..\src\valuue.c(55) : warning C4047: '=' : 'int' differs in levels of indirection from 'Thread *'
..\..\src\valuue.c(56) : error C2065: 'thread3' : undeclared identifier
..\..\src\valuue.c(56) : warning C4047: '=' : 'int' differs in levels of indirection from 'Thread *'
..\..\src\valuue.c(57) : error C2065: 'thread4' : undeclared identifier
..\..\src\valuue.c(57) : warning C4047: '=' : 'int' differs in levels of indirection from 'Thread *'
..\..\src\valuue.c(59) : error C2065: 'thread1' : undeclared identifier
..\..\src\valuue.c(59) : error C2223: left of '->nelements' must point to struct/union
..\..\src\valuue.c(59) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(59) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(59) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(62) : error C2065: 'area' : undeclared identifier
..\..\src\valuue.c(62) : error C2109: subscript requires array or pointer type
..\..\src\valuue.c(62) : error C2065: 'thread1' : undeclared identifier
..\..\src\valuue.c(62) : error C2223: left of '->storage' must point to struct/union
..\..\src\valuue.c(62) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(62) : error C2065: 'area' : undeclared identifier
..\..\src\valuue.c(62) : error C2109: subscript requires array or pointer type
..\..\src\valuue.c(62) : error C2065: 'thread1' : undeclared identifier
..\..\src\valuue.c(62) : error C2223: left of '->storage' must point to struct/union
..\..\src\valuue.c(62) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(62) : error C2065: 'area' : undeclared identifier
..\..\src\valuue.c(62) : error C2109: subscript requires array or pointer type
..\..\src\valuue.c(62) : error C2065: 'thread1' : undeclared identifier
..\..\src\valuue.c(62) : error C2223: left of '->storage' must point to struct/union
..\..\src\valuue.c(62) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(63) : error C2065: 'area' : undeclared identifier
..\..\src\valuue.c(63) : error C2109: subscript requires array or pointer type
..\..\src\valuue.c(63) : error C2065: 'thread1' : undeclared identifier
..\..\src\valuue.c(63) : error C2223: left of '->storage' must point to struct/union
..\..\src\valuue.c(63) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(66) : error C2065: 'thread2' : undeclared identifier
..\..\src\valuue.c(66) : error C2223: left of '->nelements' must point to struct/union
..\..\src\valuue.c(66) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(66) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(66) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(69) : error C2065: 'area' : undeclared identifier
..\..\src\valuue.c(69) : error C2109: subscript requires array or pointer type
..\..\src\valuue.c(69) : error C2065: 'thread2' : undeclared identifier
..\..\src\valuue.c(69) : error C2223: left of '->storage' must point to struct/union
..\..\src\valuue.c(69) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(69) : error C2065: 'area' : undeclared identifier
..\..\src\valuue.c(69) : error C2109: subscript requires array or pointer type
..\..\src\valuue.c(69) : error C2065: 'thread2' : undeclared identifier
..\..\src\valuue.c(69) : error C2223: left of '->storage' must point to struct/union
..\..\src\valuue.c(69) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(69) : error C2065: 'area' : undeclared identifier
..\..\src\valuue.c(69) : error C2109: subscript requires array or pointer type
..\..\src\valuue.c(69) : error C2065: 'thread2' : undeclared identifier
..\..\src\valuue.c(69) : error C2223: left of '->storage' must point to struct/union
..\..\src\valuue.c(69) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(70) : error C2065: 'area' : undeclared identifier
..\..\src\valuue.c(70) : error C2109: subscript requires array or pointer type
..\..\src\valuue.c(70) : error C2065: 'thread2' : undeclared identifier
..\..\src\valuue.c(70) : error C2223: left of '->storage' must point to struct/union
..\..\src\valuue.c(70) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(73) : error C2065: 'thread3' : undeclared identifier
..\..\src\valuue.c(73) : error C2223: left of '->nelements' must point to struct/union
..\..\src\valuue.c(73) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(73) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(73) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(76) : error C2065: 'area' : undeclared identifier
..\..\src\valuue.c(76) : error C2109: subscript requires array or pointer type
..\..\src\valuue.c(76) : error C2065: 'thread3' : undeclared identifier
..\..\src\valuue.c(76) : error C2223: left of '->storage' must point to struct/union
..\..\src\valuue.c(76) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(76) : error C2065: 'area' : undeclared identifier
..\..\src\valuue.c(76) : error C2109: subscript requires array or pointer type
..\..\src\valuue.c(76) : error C2065: 'thread3' : undeclared identifier
..\..\src\valuue.c(76) : error C2223: left of '->storage' must point to struct/union
..\..\src\valuue.c(76) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(76) : error C2065: 'area' : undeclared identifier
..\..\src\valuue.c(76) : error C2109: subscript requires array or pointer type
..\..\src\valuue.c(76) : error C2065: 'thread3' : undeclared identifier
..\..\src\valuue.c(76) : error C2223: left of '->storage' must point to struct/union
..\..\src\valuue.c(76) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(77) : error C2065: 'area' : undeclared identifier
..\..\src\valuue.c(77) : error C2109: subscript requires array or pointer type
..\..\src\valuue.c(77) : error C2065: 'thread3' : undeclared identifier
..\..\src\valuue.c(77) : error C2223: left of '->storage' must point to struct/union
..\..\src\valuue.c(77) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(80) : error C2065: 'thread4' : undeclared identifier
..\..\src\valuue.c(80) : error C2223: left of '->nelements' must point to struct/union
..\..\src\valuue.c(80) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(80) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(80) : error C2065: 'face' : undeclared identifier
..\..\src\valuue.c(83) : error C2065: 'area' : undeclared identifier
..\..\src\valuue.c(83) : error C2109: subscript requires array or pointer type
..\..\src\valuue.c(83) : fatal error C1003: error count exceeds 100; stopping compilation

Done.

what do you do ?
thank you
tranvantrung551987 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
parse error while interpreting udf Kristin Fluent UDF and Scheme Programming 3 March 15, 2012 06:43
UDF for transient pressure inlet, mass flow check at nozzle exit and volumetric heat kokoory FLUENT 0 August 17, 2011 02:07
critical error during installation of openfoam Fabio88 OpenFOAM Installation 21 June 2, 2010 03:01
I need UDF help. S.Whitney FLUENT 0 October 15, 2007 11:29
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 04:03


All times are GMT -4. The time now is 21:05.