CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   help me check udf (https://www.cfd-online.com/Forums/fluent-udf/122618-help-me-check-udf.html)

 tranvantrung551987 August 23, 2013 05:55

help me check udf

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;
/************************************************** *********************************/
{
/* This function calculates the hydraulic forces acting on the spindle*/
pressure_force1=0.0;
pressure_force2=0.0;
pressure_force3=0.0;
pressure_force4=0.0;
#if !RP_HOST
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*/
/*compute pressure forces on body by looping through all faces*/
if (PRINCIPAL_FACE_P(face,thread1)) /* test if the face is the principle face*/
{
}
{
}
{
}
{
}
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);
/************************************************** ******************************/
{
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
face_t face;
real area[ND_ND];
{
total_area1 += NV_MAG(area);
}
{
total_area2 += NV_MAG(area);
}
{
total_area3 += NV_MAG(area);
65
}
#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

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