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

Please help UDF error!!!!

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By pakk
  • 1 Post By upeksa

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 25, 2014, 01:34
Default Please help UDF error!!!!
  #1
Member
 
Anh
Join Date: Sep 2014
Posts: 72
Rep Power: 12
dinhanh is on a distinguished road
Hi everyone, I am new in CFD. I try to make a simple udf: DEFINE_SOURCE as below. But when complied show the error.

#include "udf.h"
#include "math.h"
#include "sg.h"
#include "sg_mphase.h"
#include "flow.h"
#include "mem.h"
#include "metric.h"

#define Cpl 4184
#define Cpv 2014
#define h0l 1143000
#define h0v 1982000
#define Rb 0.000001
#define anuc 0.0005
#define Fvar 50
#define Fcond 0.01
#define pk 22130000
#define Tk 647.31
#define a 7.21379
#define b 0.00001152
#define c -0.000000004787
#define d 483.16
#define Rhol 998.6
#define Rhov 0.02435

DEFINE_SOURCE(energy_source, c, t, dS, i)
{

real Pv;
real dp;
real me;
real mc;
real L;
real source;
int liquid=0;
int vapor =1;
Thread *phase1;
Thread *phase2;
phase1=THREAD_SUB_THREAD(t,liquid);
phase2=THREAD_SUB_THREAD(t,vapor );

Pv=pk*exp((1.0-Tk/C_T(c,t))*(a+(b+c*C_T(c,t))*(C_T(c,t)-d)*(C_T(c,t)-d)));
voidf=C_VOF(c,phase2);
dp =C_P(c,t)-Pv;
if(dp<0)
{
me=Fvar*3.0*anuc*(1.0-voidf)*Rhov*sqrt(2.0*abs(dp)/Rhol/3.0)/Rb;
mc=0.0;
}
else
{
mc=Fcond*3.0*voidf*Rhov*sqrt(2.0*abs(dp)/Rhol/3.0)/Rb;
me=0.0;
}
L=(Cpv*C_T(c,t)+h0v)-(Cpl*C_T(c,t)+h0l);
source=-L*(me-mc);
dS[i]=0.0
return source;

}

Program error message

for d in lnamd64/[23]*; do \
( \
cd $d; \
for f in ../../src/*.[ch] ../../src/makefile; do \
if [ ! -f `basename $f` ]; then \
echo "# linking to" $f "in" $d; \
ln -s $f .; \
fi; \
done; \
echo ""; \
echo "# building library in" $d; \
if [ "" = "1" ]; then \
echo "# using gcc64"; \
make ARCHC=gcc64 -k>makelog 2>&1; \
else \
if [ "" = "1" ]; then \
echo "# using gcc"; \
make ARCHC=gcc -k>makelog 2>&1; \
else \
make -k>makelog 2>&1; \
fi; \
fi;\
cat makelog; \
) \
done
# linking to ../../src/Energy_source.c in lnamd64/3d

# building library in lnamd64/3d
make[1]:
ディレクトリ `/home/CFb/CFb003/Exp_Data/Energy_effect/libudf1/lnamd64/3d' に入ります
# Generating udf_names.c because of makefile Energy_source.c
make[2]:
ディレクトリ `/home/CFb/CFb003/Exp_Data/Energy_effect/libudf1/lnamd64/3d' に入ります
make libudf.so "CFLAGS=-D_lnamd64 -D_GNU_SOURCE -fpic -shared -ansi -Wall -O -DPTR_RESTRICT= " "LDFLAGS=-shared -lm"
make[3]:
ディレクトリ `/home/CFb/CFb003/Exp_Data/Energy_effect/libudf1/lnamd64/3d' に入ります
# Compiling udf_names.o because of udf_names.c
cc -D_lnamd64 -D_GNU_SOURCE -fpic -shared -ansi -Wall -O -DPTR_RESTRICT= -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/`expr "\`pwd\`" : '.*/\(.*\)/[23].*'`/`basename "\`pwd\`"` -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/src -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/cortex/src -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/client/src -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/tgrid/src -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/multiport/src -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/multiport/mpi_wrapper/include -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/multiport/mpi_wrapper/src -I. -c udf_names.c
# Compiling Energy_source.o because of Energy_source.c
cc -D_lnamd64 -D_GNU_SOURCE -fpic -shared -ansi -Wall -O -DPTR_RESTRICT= -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/`expr "\`pwd\`" : '.*/\(.*\)/[23].*'`/`basename "\`pwd\`"` -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/src -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/cortex/src -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/client/src -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/tgrid/src -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/multiport/src -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/multiport/mpi_wrapper/include -I/ap/ANSYS/ansys_inc/v145/fluent/fluent14.5.7/multiport/mpi_wrapper/src -I. -c Energy_source.c
Energy_source.c:26: error: expected ‘;’, ‘,’ or ‘)’ before ‘-’ token
make[3]: *** [Energy_source.o]
エラー 1
make[3]:
ターゲット `libudf.so' はエラーにより再 make できませんでした.
make[3]:
ディレクトリ `/home/CFb/CFb003/Exp_Data/Energy_effect/libudf1/lnamd64/3d' から出ます
make[2]: *** [lnamd64]
エラー 2
make[2]:
ディレクトリ `/home/CFb/CFb003/Exp_Data/Energy_effect/libudf1/lnamd64/3d' から出ます
make[1]: *** [default]
エラー 2
make[1]:
ディレクトリ `/home/CFb/CFb003/Exp_Data/Energy_effect/libudf1/lnamd64/3d' から出ます


How could I fix this error? Plese help, thank you in advance!!!
dinhanh is offline   Reply With Quote

Old   September 25, 2014, 05:06
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
The problem is that you use the variable "c" two times.

Once in your definition in line 21, where you define it as a number. And the second time in line 26, where you define it as a variable.

You line 21 tells to the compiler: "every time I write the letter c, replace it by the number -0.000000004787".
So when the compiler reaches line 26, it reads:
Code:
DEFINE_SOURCE(energy_source, -0.000000004787, t, dS, i)
And that does not make any sense, since a variable name is expected there. Once the compiler reads the minus sign, it knows there is a problem, so that explains your error.

Edit: To solve it, you should rename one of the two c's. I would advice to rename the first one (in line 21), but either option works.
dinhanh likes this.
pakk is offline   Reply With Quote

Old   September 25, 2014, 05:06
Default
  #3
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 13
upeksa is on a distinguished road
You have defined "c" twice: as a constant and as a cell_t type argument in DEFINE_SOURCE.

Check this line: dS[i]=0.0;

Cheers
dinhanh likes this.
upeksa is offline   Reply With Quote

Old   September 26, 2014, 05:10
Default
  #4
Member
 
Anh
Join Date: Sep 2014
Posts: 72
Rep Power: 12
dinhanh is on a distinguished road
Thank you very much, Upeksa and Pakk
dinhanh is offline   Reply With Quote

Reply


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
[OpenFOAM] an error in Calculator's equation immortality ParaView 12 June 29, 2021 01:10
Undeclared Identifier Errof UDF SteveGoat Fluent UDF and Scheme Programming 7 October 15, 2014 08:11
ParaView for OF-1.6-ext Chrisi1984 OpenFOAM Installation 0 December 31, 2010 07:42
Installation OF1.5-dev ttdtud OpenFOAM Installation 46 May 5, 2009 03:32
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 21:50


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