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

UDF Compiling error

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 10, 2017, 15:15
Default UDF Compiling error
  #1
New Member
 
Mostafa Mehdipoor
Join Date: Sep 2017
Posts: 6
Rep Power: 9
M.Meh is on a distinguished road
I have a domain consisting of 8 point (node). I want to read a txt file for each point and import them as source term for x momentum source. My UDF form for read text is as


#include "udf.h"
#include <math.h>
float x[9],y[9],fx[9];
DEFINE_ON_DEMAND(read_data)
{
FILE *rfile;
int i;
rfile = fopen("newdata.txt","r");
for (i=1;i<9;i++)
{
fscanf(rfile,"%f",&x[i]);
fscanf(rfile,"%f",&y[i]);
fscanf(rfile,"%f",&fx[i]);
}
fclose(rfile);

}

and My text file as
((inlet point 8)
(x
0.0
0.001
0.002
0.003
0.0
0.001
0.002
0.003
)
(y
0.0
0.0
0.0
0.0
0.001
0.001
0.001
0.001
)
(fx
-1.019200000*10^6
-1.019200000*10^6
-1.019200000*10^6
-1.019200000*10^6
-1.019200000*10^6
-1.019200000*10^6
-1.019200000*10^6
-1.019200000*10^6
)
)
(for simplicity I use a value for all points as source).
Now, I have two problems:
1. Above UDF compiling give an error

E:\program\visual studio\VC\include\math.h(482) : error C2059: syntax error : ','
E:\program\visual studio\VC\include\math.h(482) : error C2143: syntax error : missing ')' before 'constant'
E:\program\visual studio\VC\include\math.h(482) : error C2143: syntax error : missing '{' before 'constant'
E:\program\visual studio\VC\include\math.h(482) : error C2059: syntax error : 'constant'
E:\program\visual studio\VC\include\math.h(482) : error C2059: syntax error : ')'
..\..\src\ReadText.c(7) : warning C4129: 'Y' : unrecognized character escape sequence
..\..\src\ReadText.c(7) : warning C4129: 'D' : unrecognized character escape sequence
..\..\src\ReadText.c(7) : warning C4129: 'S' : unrecognized character escape sequence

Done.

2. I dont know how write a UDF for use each fx as x momentum source?

Please help me.
M.Meh is offline   Reply With Quote

Old   September 10, 2017, 16:53
Default
  #2
Senior Member
 
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0
CeesH is on a distinguished road
well, the error seems to be in math.h.
I recall FLUENT has some issues using the <> notation for headers. What if you replace it by "math.h"
CeesH is offline   Reply With Quote

Old   September 11, 2017, 06:15
Default
  #3
New Member
 
Mostafa Mehdipoor
Join Date: Sep 2017
Posts: 6
Rep Power: 9
M.Meh is on a distinguished road
Thank you for your answer.
I replace " " in my UDF but I have previous error, aslo.
M.Meh is offline   Reply With Quote

Old   September 11, 2017, 06:29
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Have you previously compiled udfs, or is this the first time that you try?
pakk is offline   Reply With Quote

Old   September 11, 2017, 07:25
Default
  #5
New Member
 
Mostafa Mehdipoor
Join Date: Sep 2017
Posts: 6
Rep Power: 9
M.Meh is on a distinguished road
Hi
Thank you for your answer.
This is first time I compile a udf file. I have firstly "nmake" error and then "x copy".
After search in cfd-online, and use from it, I could eliminate these errors according to some comments.
Now I have this error mentioned.
Please help me.
M.Meh is offline   Reply With Quote

Old   September 11, 2017, 07:31
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
One thing you can do is to remove the math.h line, I don't think you need it at all.

I see "Visual Studio" in your folder name. Are you aware that you should compile the udf in the program Fluent?
pakk is offline   Reply With Quote

Old   September 16, 2017, 03:02
Default
  #7
New Member
 
Mostafa Mehdipoor
Join Date: Sep 2017
Posts: 6
Rep Power: 9
M.Meh is on a distinguished road
Quote:
Originally Posted by pakk View Post
One thing you can do is to remove the math.h line, I don't think you need it at all.

I see "Visual Studio" in your folder name. Are you aware that you should compile the udf in the program Fluent?

Hello,
I remove the math.h line but I have previous error.
I wane compile the udf by Fluent program as
Define---> user defined---> functions---> compiled.
This is a part of my project namely I want read a data file and use them as source for momentum. Please guide me.
Thank you.
M.Meh is offline   Reply With Quote

Old   September 18, 2017, 04:35
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
So you don't include math.h anymore, but Fluent still gives an error message about math.h? Strange.
Are you sure that you are changing the correct file?
pakk is offline   Reply With Quote

Old   September 18, 2017, 06:33
Default
  #9
New Member
 
Mostafa Mehdipoor
Join Date: Sep 2017
Posts: 6
Rep Power: 9
M.Meh is on a distinguished road
Quote:
Originally Posted by pakk View Post
So you don't include math.h anymore, but Fluent still gives an error message about math.h? Strange.
Are you sure that you are changing the correct file?

Yes, fluent still give an error message about math.h.
I think maybe my text file for reading is wrong, How to make a text file for this problem? with which format? text? dat? or ...
Do I write data as row or column?
Do I write only source values or both source value and coordinate point? Please help me.
What do you mean from changing the file? I don't understand?

thank you.
M.Meh 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
error compiling modified applications yvyan OpenFOAM Programming & Development 21 March 1, 2016 05:53
[swak4Foam] installing funkySetFields igo OpenFOAM Community Contributions 1 November 20, 2012 21:16
[swak4Foam] groovyBC: problems compiling: "flex: not found" and "undefined reference to ..." sega OpenFOAM Community Contributions 12 February 17, 2010 10:30
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 11:23
user subroutine error CFDUSER CFX 2 December 9, 2006 07:31


All times are GMT -4. The time now is 14:02.