|
[Sponsors] |
September 10, 2017, 15:15 |
UDF Compiling error
|
#1 |
New Member
Mostafa Mehdipoor
Join Date: Sep 2017
Posts: 6
Rep Power: 9 |
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. |
|
September 10, 2017, 16:53 |
|
#2 |
Senior Member
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0 |
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" |
|
September 11, 2017, 06:15 |
|
#3 |
New Member
Mostafa Mehdipoor
Join Date: Sep 2017
Posts: 6
Rep Power: 9 |
Thank you for your answer.
I replace " " in my UDF but I have previous error, aslo. |
|
September 11, 2017, 06:29 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Have you previously compiled udfs, or is this the first time that you try?
|
|
September 11, 2017, 07:25 |
|
#5 |
New Member
Mostafa Mehdipoor
Join Date: Sep 2017
Posts: 6
Rep Power: 9 |
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. |
|
September 11, 2017, 07:31 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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? |
|
September 16, 2017, 03:02 |
|
#7 | |
New Member
Mostafa Mehdipoor
Join Date: Sep 2017
Posts: 6
Rep Power: 9 |
Quote:
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. |
||
September 18, 2017, 04:35 |
|
#8 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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? |
|
September 18, 2017, 06:33 |
|
#9 | |
New Member
Mostafa Mehdipoor
Join Date: Sep 2017
Posts: 6
Rep Power: 9 |
Quote:
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. |
||
|
|
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 |