CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   A Problem of Fluent Interpreted UDF: parse error (https://www.cfd-online.com/Forums/fluent-udf/72857-problem-fluent-interpreted-udf-parse-error.html)

knight February 19, 2010 15:42

A Problem of Fluent Interpreted UDF: parse error
 
Hello guys!
I am a newly learner of Fluent, I got some problems with my UDF file when I compiled it in Fluent.
I don't want to bother you, while I really searched everywhere but didn't find a good solution. I hope someone could help me

my fluent path:
C:\Fluent.Inc\fluent\ntbin\ntx86\fluent.exe -r6.2.16

Model exported by GAMBIT path:
E:\dissertation\fluent模型\2010-2-5\A11\a11.msh

Udf file(it is a peroidical velocity inlet)
E:\dissertation\fluent模型\2010-2-5\A11\velocity2.c

run FLUENT, READ CASE--A11.MSH,Done!
Then,DEFINE--UDF---INTERPRETED UDF---velocity2.c
It is reported that:

cpp -IC:\Fluent.Inc\fluent\fluent6.2.16/src
-IC:\Fluent.Inc\fluent\fluent6.2.16/cortex/src
-IC:\Fluent.Inc\fluent\fluent6.2.16/client/src
-IC:\Fluent.Inc\fluent\fluent6.2.16/multiport/src -I.
-DUDFCONFIG_H="<udfconfig.h>"
E:\dissertation\fluen 模型\2010-2-5\A11\velocity2.c
Error: E:\dissertation\fluent模型\2010-2-5\A11\velocity2.c: line 1: parse
error.


It's said that there is one PARSE ERROR in line 1,then I opened this velocity.c in VC++

-----------------------------------------------------------------------
#include "udf.h"
#include "stdio.h"
#include "math.h"
#include "stdlib.h"

DEFINE_PROFILE(inlet_velocity1, thread, i)
{
Domain *domain;
Thread *f_thread ;
face_t f;
float time;

// float inlet_d=0.397e-3;
// float ave_v=1.0;

// x0=-0.528e-3;
// y0=0.00000;
// z0=0.00000;
time=CURRENT_TIME;

begin_f_loop(f, thread)
{
F_PROFILE(f, thread, i) = abs(0.003*sin(2*6.283*time));
}
end_f_loop(f, thread)
}
----------------------------------------------------------------------
When compiling, VC said:
e:\dissertation\fluent模型\2010-2-5\a11\velocity2.c(1) : fatal error C1083:
Cannot open include file: 'udf.h': No such file or directory
error when running cl.exe

I remember there is no need to compile udf in VC. Just compiling it in fluent is Ok, because fluent will find the udf.h in its directory. But it seems my Fluent wouldn't cooperate. It turned the error to my velocity.c :(

Expecting help!
Sincerely thanks

Knight

souravsingh1987 April 19, 2010 20:17

I am facing in the same problem.. can someone please help..

pacheo May 24, 2010 03:04

Quote:

Originally Posted by knight (Post 246641)
Hello guys!
I am a newly learner of Fluent, I got some problems with my UDF file when I compiled it in Fluent.
I don't want to bother you, while I really searched everywhere but didn't find a good solution. I hope someone could help me

my fluent path:
C:\Fluent.Inc\fluent\ntbin\ntx86\fluent.exe -r6.2.16

Model exported by GAMBIT path:
E:\dissertation\fluent模型\2010-2-5\A11\a11.msh

Udf file(it is a peroidical velocity inlet)
E:\dissertation\fluent模型\2010-2-5\A11\velocity2.c

run FLUENT, READ CASE--A11.MSH,Done!
Then,DEFINE--UDF---INTERPRETED UDF---velocity2.c
It is reported that:

cpp -IC:\Fluent.Inc\fluent\fluent6.2.16/src
-IC:\Fluent.Inc\fluent\fluent6.2.16/cortex/src
-IC:\Fluent.Inc\fluent\fluent6.2.16/client/src
-IC:\Fluent.Inc\fluent\fluent6.2.16/multiport/src -I.
-DUDFCONFIG_H="<udfconfig.h>"
E:\dissertation\fluen 模型\2010-2-5\A11\velocity2.c
Error: E:\dissertation\fluent模型\2010-2-5\A11\velocity2.c: line 1: parse
error.


It's said that there is one PARSE ERROR in line 1,then I opened this velocity.c in VC++

-----------------------------------------------------------------------
#include "udf.h"
#include "stdio.h"
#include "math.h"
#include "stdlib.h"

DEFINE_PROFILE(inlet_velocity1, thread, i)
{
Domain *domain;
Thread *f_thread ;
face_t f;
float time;

// float inlet_d=0.397e-3;
// float ave_v=1.0;

// x0=-0.528e-3;
// y0=0.00000;
// z0=0.00000;
time=CURRENT_TIME;

begin_f_loop(f, thread)
{
F_PROFILE(f, thread, i) = abs(0.003*sin(2*6.283*time));
}
end_f_loop(f, thread)
}
----------------------------------------------------------------------
When compiling, VC said:
e:\dissertation\fluent模型\2010-2-5\a11\velocity2.c(1) : fatal error C1083:
Cannot open include file: 'udf.h': No such file or directory
error when running cl.exe

I remember there is no need to compile udf in VC. Just compiling it in fluent is Ok, because fluent will find the udf.h in its directory. But it seems my Fluent wouldn't cooperate. It turned the error to my velocity.c :(

Expecting help!
Sincerely thanks

Knight

u'd better not include chinese characters in your work folder.

try again.

Galileo February 21, 2011 10:42

math.h stdio.h stdlib.h udf.h in UDFs of FLUENT
 
This thread is old, but I faced similar problem and found this thinking the way out would have been discussed.

The way round would be to use this header only
#include "udf.h"

and leave out these headers:
#include "stdio.h"
#include "math.h"
#include "stdlib.h"


udf.h defines most of what is needed.

Hope this helps someone else.

cdf_user April 7, 2011 03:45

make sure you include the full path to the file when you select the file through 'browse'. same goes for udf_library in build during compiling

sirnick March 13, 2012 04:23

Thank you very much Galileo, you save me!!

nnvoro April 18, 2013 12:46

I need to use Bessel functions and complex numbers in my udf to set womersley profile in the inlet, when I leave only #include "udf.h" in the header Fluent can't interpret my udf. How can I cope with this problem?

Galileo April 27, 2013 06:00

Quote:

Originally Posted by nnvoro (Post 421582)
I need to use Bessel functions and complex numbers in my udf to set womersley profile in the inlet, when I leave only #include "udf.h" in the header Fluent can't interpret my udf. How can I cope with this problem?


I am not quite clear with what you want to do, but for you to get help, you need to post more details. For example, you need to say what the error is; are you interpreting or compiling; how complex numbers will work in a BC. Unless you are using one of the parts of a complex number, it will be difficult to code z=a+ib.. You need to be able to express the problem in simple equation or the form the equation will take.

nnvoro April 28, 2013 14:10

Quote:

Originally Posted by Galileo (Post 423490)
I am not quite clear with what you want to do, but for you to get help, you need to post more details. For example, you need to say what the error is; are you interpreting or compiling; how complex numbers will work in a BC. Unless you are using one of the parts of a complex number, it will be difficult to code z=a+ib.. You need to be able to express the problem in simple equation or the form the equation will take.

Engr, I really appreciate that you answered me. The problem was that I was trying to write my boundary conditions in a compact form, for that I used expressions which contained imaginary numbers and Bessel functions. I was taking real part of this expression which is than was used for boundary conditions. Thus I needed imaginary numbers in order to avoid bulky expressions in my udf.
Now, my problem is solved, I did the thing I was trying to avoid, I wrote my udf without using imaginary numbers and Bessel functions.

mumu678 May 1, 2013 05:29

感觉使用udf.h就可以满足需求

armanrazy May 6, 2013 06:17

salam
 
because u used a space before include

siddharth12 December 8, 2013 09:00

error while building udf
 
I am getting error while compiling udf in fluent 13.0.0

error is
module machine type 'x64' conflicts with target machine type 'X86'

please help
please....

kalaivani March 5, 2016 01:26

Parse error
 
Sir,
Sir,

I tried to work out an example in LNA in ANSYS tool . I got the result.But if i replace it by a HEMT model i get the parse error as Cant interpret this device.Please provide me a solution so that it would be helpful for me to arrive at good solutions.

zhihuawan January 16, 2018 01:37

"error:E:fluent/volume.c;line 28 parse error." The udf are as follows:
 
Quote:

Originally Posted by nnvoro (Post 423676)
Engr, I really appreciate that you answered me. The problem was that I was trying to write my boundary conditions in a compact form, for that I used expressions which contained imaginary numbers and Bessel functions. I was taking real part of this expression which is than was used for boundary conditions. Thus I needed imaginary numbers in order to avoid bulky expressions in my udf.
Now, my problem is solved, I did the thing I was trying to avoid, I wrote my udf without using imaginary numbers and Bessel functions.


Hi,nnvoro,I meet the same problem,can you help me?this is my problems.

when I interpret the udf to the fluent,it gives errors "error:E:fluent/volume.c;line 28 parse error." The udf are as follows:

/************************************************** *********************
udfexample.c
UDF for specifying volume profile boundary condition
************************************************** **********************/

#include "udf.h"

DEFINE_PROFILE(inlet_volume, thread, position)
{
real x[ND_ND]; /* this will hold the position vector */
real y, h;
face_t f;
h = -0.0009; /* inlet height in m */
begin_f_loop(f,thread)
{
F_CENTROID(x, f, thread);
y = x[1];
if (y<h)
{
F_PROFILE(f, thread, position) =1;
}
else {
F_PROFILE(f, thread, position) =0;
}
end_f_loop(f, thread)

}

obscureed January 16, 2018 04:47

Dear Zhihuawan,

You start the face loop with "begin_f_loop(f,thread) {", so you need to end it with "} end_f_loop(f,thread)" -- note the closing "}", which is currently missing.

I would highly recommend that everyone trying to write UDFs (or other code) uses a text editor that indents automatically, and that shows matching pairs of opening brackets/braces/parentheses/etc. If you don't have time to learn vim or emacs, try Notepad++ and look for auto-indent.

Also, this thread is about interpreted UDFs. I would highly recommend using compiled UDFs unless your sys-admins make it completely impossible. Interpreted UDFs are very restricted (and probably slow, though I have never tested this).

Best regards,
Ed

zhihuawan January 17, 2018 20:31

[QUOTE=obscureed;678284]Dear Zhihuawan, You start the face loop with "begin_f_loop(f
 
Quote:

Originally Posted by obscureed (Post 678284)
Dear Zhihuawan,

You start the face loop with "begin_f_loop(f,thread) {", so you need to end it with "} end_f_loop(f,thread)" -- note the closing "}", which is currently missing.

I would highly recommend that everyone trying to write UDFs (or other code) uses a text editor that indents automatically, and that shows matching pairs of opening brackets/braces/parentheses/etc. If you don't have time to learn vim or emacs, try Notepad++ and look for auto-indent.

Also, this thread is about interpreted UDFs. I would highly recommend using compiled UDFs unless your sys-admins make it completely impossible. Interpreted UDFs are very restricted (and probably slow, though I have never tested this).

Best regards,
Ed


Thank you very much .I solve my problem by your idea. but I have some questions:
(1)I want to send you the udf files, but I do not know how.
(2)I also want to compile it ,but it failed ,should I change the udf to be a compiled udf.How can do it ?
(3)Can you tell me what should learn if I want to master the udf prgramming.
Thank you very much.

zhihuawan January 17, 2018 20:56

This is the pictures about my udf and error tips.
 
2 Attachment(s)
Quote:

Originally Posted by obscureed (Post 678284)
Dear Zhihuawan,

You start the face loop with "begin_f_loop(f,thread) {", so you need to end it with "} end_f_loop(f,thread)" -- note the closing "}", which is currently missing.

I would highly recommend that everyone trying to write UDFs (or other code) uses a text editor that indents automatically, and that shows matching pairs of opening brackets/braces/parentheses/etc. If you don't have time to learn vim or emacs, try Notepad++ and look for auto-indent.

Also, this thread is about interpreted UDFs. I would highly recommend using compiled UDFs unless your sys-admins make it completely impossible. Interpreted UDFs are very restricted (and probably slow, though I have never tested this).

Best regards,
Ed

This is the pictures about my udf and error tips.

Attachment 60866

Attachment 60867

pakk January 18, 2018 02:16

Quote:

Originally Posted by zhihuawan (Post 678510)
This is the pictures about my udf and error tips.

Attachment 60866

Attachment 60867

Please show the error that you get when you try to compile the udf. Not the error that you get when you try to load the udf.
You should see a warning about line 12 or 13. The code that you used is slightly different from the code that you posted on this forum.

zhihuawan January 18, 2018 06:24

[QUOTE=pakk;678527]Please show the error that you get when you try to compile the udf
 
Quote:

Originally Posted by pakk (Post 678527)
Please show the error that you get when you try to compile the udf. Not the error that you get when you try to load the udf.
You should see a warning about line 12 or 13. The code that you used is slightly different from the code that you posted on this forum.

I do not know how to comiled the udf ,can you tell me how to do it?Yes ,I plus a "}" before the "end_f_loop(f,thread)",therefore ,it can works.

pakk January 18, 2018 07:47

Quote:

Originally Posted by zhihuawan (Post 678557)
I do not know how to comiled the udf ,can you tell me how to do it?Yes ,I plus a "}" before the "end_f_loop(f,thread)",therefore ,it can works.

You were able to find the "load" button. On the same screen, there is the "build" button. You should click the "build" button before you click the "load" button.

zhihuawan January 18, 2018 08:26

[QUOTE=pakk;678565]You were able to find the "load" button. On the same screen, there
 
Quote:

Originally Posted by pakk (Post 678565)
You were able to find the "load" button. On the same screen, there is the "build" button. You should click the "build" button before you click the "load" button.

I do as you said ,the error also exist,how can I solve it ?

pakk January 19, 2018 03:14

Quote:

Originally Posted by zhihuawan (Post 678569)
I do as you said ,the error also exist,how can I solve it ?

It depends on which errors comes on your screen after you click "build". I can not look at your screen.

Please read carefully: NOT the error that you get after clicking "load". That one you have shown me already.

obscureed January 19, 2018 12:26

On the wider question of learning UDFs and compiling UDFs:
-- Look at the help files and the tutorials.
-- I recently made a list of the steps that you have to follow to compile a UDF: see https://www.cfd-online.com/Forums/fl...d-current.html. But if you have not read any help materials at all, then this list might not make any sense.
-- When you compile, scroll back up and see if there are any compilation errors. If there are, you need to fix them before running the libudf. If they refer to specific lines in your input code, go and look at those lines. If they do not refer to your input code, something is wrong with your compiler setup -- check out pakk's helpful post from 2016: https://www.cfd-online.com/Forums/fl...ms-fluent.html

zhihuawan January 22, 2018 22:11

[QUOTE=pakk;678658]It depends on which errors comes on your screen after you click "b
 
2 Attachment(s)
Quote:

Originally Posted by pakk (Post 678658)
It depends on which errors comes on your screen after you click "build". I can not look at your screen.

Please read carefully: NOT the error that you get after clicking "load". That one you have shown me already.


now these pictures are the build result,but there are some messy code on the screen,can you tell me what is the reason?thank you.
Attachment 60954

Attachment 60955

pakk January 23, 2018 03:00

Surprisingly: yes, I can.

You get the error message:
Quote:

'nmake' is not recognized as an internal or external command
(You don't see this literally because your computer is set to a language that does not use the Latin alphabet, and the Fluent TUI is not able to show the characters of your language, but trust me, it is there.)

This means that your compiler is not set up correctly. Currently, your UDF code is not the problem.

Solve this. Look for the error message on this forum to find out how, I am no expert on this.

Ken_ August 16, 2018 10:26

I'm getting a parse error as well for my UDF file. I would really appreciate if anyone could help me with it.

UDF File:
#include "udf.h"
DEFINE_PROFILE(x_velocity_a,thread,nv)
{
float pos[3]; /* an array for the coordinates */
float y;
face_t f; /* f is a face thread index */
begin_f_loop(f, thread)
{
F_CENTROID(pos,f,thread);
y = pos[1];
F_PROFILE(f, thread, nv)
= 1.-(400.*y-1.)*(400.*y-1.);
}
end_f_loop(f, thread)
}


Error, when using Interpreted UDFs: ....... line 15: parse error.

Thank You!


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