|
[Sponsors] |
May 22, 2013, 15:18 |
source term UDF- gettnig "error"
|
#1 |
Senior Member
Moha
Join Date: Mar 2013
Location: EU
Posts: 103
Rep Power: 0 |
Hi to all,
I am trying to define a source term as a function of "CURRENT TEMPERATURE" as its a transient analysis. indeed, this source term for a specific range of temperature will be applied when its between upper and lower temperature defined). but I gave this error : Error: CURRENT_TEMPERATURE: undeclared variable" while the temperature profile already defined by another code before reading the current code. so shouldn't it recognize by Fluent ? best regards, start the code: /************************************************** ******************* UDF that simulates M-source specifying a temperature- dependent ************************************************** ********************/ #include "udf.h" #define T_upper 290.8833 #define T_lower 296.7833 DEFINE_SOURCE(cell_source, cell, thread,SRC_ON) { real source; real temp = CURRENT_TEMPERATURE; static int SRC_ON=1; if(temp>=T_upper) { SRC_ON = 0; } if (temp < T_lower) { SRC_ON = 1; } if(SRC_ON) { source=(-0.02*pow(temp,3.))+(18.131*pow(temp,2.))-(5464.6*pow(temp,1.))+548332; } else { source = 0. } return source; } |
|
May 22, 2013, 23:05 |
|
#2 |
Senior Member
|
Code:
/********************************************************************* UDF that simulates M-source specifying a temperature- dependent **********************************************************************/ #include "udf.h" #define T_upper 290.8833 #define T_lower 296.7833 DEFINE_SOURCE(cell_source, cell, thread,eqn) { real source; real temp; static int SRC_ON=1; Domain* domain; real xc[ND_ND]; real xdist = 1.E10; cell_t c; thread *t; static cell_t c0; static thread *t0; static int FOUND = 0; if (! FOUND) { FOUND = 1; domain = Get_Domain(1); thread_loop_c(t, domain) { begin_c_loop(c,t) C_CENTROID(xc, c, t); if ( NV_MAG(xc) < xdist ) { xdist = NV_MAG(xc); c0 = c; t0 = t; } end_c_loop(c,t) } } temp = C_T(c0, t0); if(temp>=T_upper) { SRC_ON = 0; } if (temp < T_lower) { SRC_ON = 1; } if(SRC_ON) { source=(-0.02*pow(temp,3.))+(18.131*pow(temp,2.))-(5464.6*pow(temp,1.))+548332; } else { source = 0. } return source; } |
|
May 23, 2013, 05:46 |
|
#3 |
Senior Member
Moha
Join Date: Mar 2013
Location: EU
Posts: 103
Rep Power: 0 |
thank you very much for the code!
why this code have error ? as I remember, the "parse error" belongs to the parenthesis but here it seems different. would you please explain a little about this error? regards, /************************************************** ******************* UDF that simulates M-source specifying a temperature- dependent ************************************************** ********************/ #include "udf.h" #define T_upper 290.8833 #define T_lower 296.7833 DEFINE_SOURCE(cell_source, cell, thread,eqn) { real source; real temp; static int SRC_ON=1; < --------parse error. Domain* domain; parse error. real xc[ND_ND]; parse error. real xdist = 1.E10; parse error. cell_t c; parse error. thread *t; < -------- t: undeclared variable static cell_t c0; static thread *t0; static int FOUND = 0; if (! FOUND) { FOUND = 1; domain = Get_Domain(1); thread_loop_c(t, domain) { begin_c_loop(c,t) C_CENTROID(xc, c, t); if ( NV_MAG(xc) < xdist ) { xdist = NV_MAG(xc); c0 = c; t0 = t; } end_c_loop(c,t) } } temp = C_T(c0, t0); if(temp>=T_upper) { SRC_ON = 0; } if (temp < T_lower) { SRC_ON = 1; } if(SRC_ON) { source=(-0.02*pow(temp,3.))+(18.131*pow(temp,2.))-(5464.6*pow(temp,1.))+548332; } else { source = 0. } return source; } |
|
May 23, 2013, 06:40 |
|
#4 |
Senior Member
|
Some minor syntax error exist in the last post. I have corrected those errors so that the following should be complied.
Code:
#include "udf.h" #define T_upper 290.8833 #define T_lower 296.7833 DEFINE_SOURCE(cell_source, cell, thread, dS, eqn) { real source; real temp; static int SRC_ON=1; Domain* domain; real xc[ND_ND]; real xdist = 1.E10; cell_t c; Thread *t; static cell_t c0; static Thread *t0; static int FOUND = 0; if (! FOUND) { FOUND = 1; domain = Get_Domain(1); thread_loop_c(t, domain) { begin_c_loop(c,t) C_CENTROID(xc, c, t); if ( NV_MAG(xc) < xdist ) { xdist = NV_MAG(xc); c0 = c; t0 = t; } end_c_loop(c,t) } } temp = C_T(c0, t0); if(temp>=T_upper) { SRC_ON = 0; } if (temp < T_lower) { SRC_ON = 1; } if(SRC_ON) { source=(-0.02*pow(temp,3.))+(18.131*pow(temp,2.))-(5464.6*pow(temp,1.))+548332; } else { source = 0.; } dS[eqn] = 0.; return source; } |
|
May 23, 2013, 07:19 |
|
#5 |
Senior Member
Moha
Join Date: Mar 2013
Location: EU
Posts: 103
Rep Power: 0 |
still same error appear (parse error) when I interrupting the code for the below lines of the code.
real source; parse error real temp; parse error static int SRC_ON=1; parse error Domain* domain; parse error real xc[ND_ND]; parse error real xdist = 1.E10; parse error cell_t c; parse error Thread *t; parse error static cell_t c0; parse error static Thread *t0; parse error static int FOUND = 0; FOUND: undeclared variable when/why parse error usually appear ? regards, |
|
May 23, 2013, 07:32 |
|
#7 |
Senior Member
Moha
Join Date: Mar 2013
Location: EU
Posts: 103
Rep Power: 0 |
Please find the attached file.
regards, |
|
May 23, 2013, 07:39 |
|
#9 |
Senior Member
Moha
Join Date: Mar 2013
Location: EU
Posts: 103
Rep Power: 0 |
I did, but still same errors.
|
|
May 23, 2013, 07:51 |
|
#10 |
Senior Member
|
I noticed that the administrator updated the forum rules and obviously we belong to the group who do not know how to behave in a forum. This will be my last post in this thread if no additional requirement other than syntax correct. I have tested the code in the #4 post. Will you please literally copy the code in #4 post in this thread? That will save us a lot of time.
|
|
May 23, 2013, 08:13 |
|
#11 |
Senior Member
Moha
Join Date: Mar 2013
Location: EU
Posts: 103
Rep Power: 0 |
the below code is a copy of the code presented in threat #4, and corresponding errors are highlighted.
Code:
#include "udf.h" #define T_upper 290.8833 #define T_lower 296.7833 DEFINE_SOURCE(cell_source, cell, thread, dS, eqn) { real source; real temp; static int SRC_ON=1; (parse error) Domain* domain;(parse error) real xc[ND_ND];(parse error) real xdist = 1.E10;(parse error) cell_t c;(parse error) Thread *t;(parse error) static cell_t c0;(parse error) static Thread *t0;(parse error) static int FOUND = 0;(parse error) if (! FOUND) {(FOUND: undeclared variable) FOUND = 1; domain = Get_Domain(1); thread_loop_c(t, domain) { begin_c_loop(c,t) C_CENTROID(xc, c, t); if ( NV_MAG(xc) < xdist ) { xdist = NV_MAG(xc); c0 = c; t0 = t; } end_c_loop(c,t) } } temp = C_T(c0, t0); if(temp>=T_upper) { SRC_ON = 0; } if (temp < T_lower) { SRC_ON = 1; } if(SRC_ON) { source=(-0.02*pow(temp,3.))+(18.131*pow(temp,2.))-(5464.6*pow(temp,1.))+548332; } else { source = 0.; } dS[eqn] = 0.; return source; } |
|
May 23, 2013, 08:42 |
|
#12 |
Senior Member
|
(1) Compile rather than interpret the udf source file.
(2) Post the message displayed in fluent tui / terminal / log file. Do not try to interpret the error/warning message yourself. It could be misleading. |
|
May 23, 2013, 20:12 |
|
#13 |
Senior Member
Moha
Join Date: Mar 2013
Location: EU
Posts: 103
Rep Power: 0 |
According to your recommendation, the code was add into compiler but it can't be "load" its impossible to attach the .log file regard to the error appearance.
As the file can not be attach to this threat (the reason is not clear to me) anyway, I just copy/paste the content of the file here : HTML Code:
Error [cortex] [time 5/23/13 23:49:25] The UDF library you are trying to load (C:\Users\Mohammad\Desktop\Solidwork-ANSYS-FLUENT\3Dbox-workbench_files\dp0\FFF-10\Fluent\Solidwork-ANSYS-FLUENT) is not compiled for 3d on the current platform (win64). The system cannot find the path specified. C:\Users\Mohammad\Desktop\Solidwork-ANSYS-FLUENT\3Dbox-workbench_files\dp0\FFF-10\Fluent\C:\Users\Mohammad\Desktop\Solidwork-ANSYS-FLUENT\3Dbox-workbench_files\dp0\FFF-10\Fluent\Solidwork-ANSYS-FLUENT\win64\3d\libudf.dll |
|
May 23, 2013, 21:26 |
|
#14 |
Senior Member
|
You can find some clue from this thread(http://www.cfd-online.com/Forums/flu...amic-mesh.html). I do not know windows much so I am not be able to help you. The wired thing I heard from one thread is that they also invoke the 'sed' command from the 'makefile' for windows distribution. If you find 'sed' in the libudf/src directory, then maybe you need to install the 'sed.exe' utility. Now I am a bit concerned whether you have compiled your udf successfully or not.
|
|
May 24, 2013, 01:20 |
|
#15 |
Member
Shashank
Join Date: Apr 2011
Posts: 74
Rep Power: 15 |
I think the above problem occurs if you haven't installed Microsoft Visual C++.
|
|
May 28, 2013, 06:59 |
|
#16 |
Senior Member
Moha
Join Date: Mar 2013
Location: EU
Posts: 103
Rep Power: 0 |
||
May 28, 2013, 10:34 |
|
#17 |
Member
Shashank
Join Date: Apr 2011
Posts: 74
Rep Power: 15 |
Are your path variables properly set?
|
|
May 28, 2013, 11:50 |
|
#18 |
Senior Member
Moha
Join Date: Mar 2013
Location: EU
Posts: 103
Rep Power: 0 |
As I tried many proposals and now I am not sure if I have every things correctly.
would you please explain more how to do that properly ? for now, my error belongs to the link problem :attached file (I change the type to .txt regarding to attach problem file) LINK : fatal error LNK1181: cannot open input file 'm.C' regards, |
|
May 29, 2013, 13:46 |
|
#19 | |
Senior Member
Moha
Join Date: Mar 2013
Location: EU
Posts: 103
Rep Power: 0 |
Quote:
Finally, the .c file compiled and loaded ! as I tried so many proposals, I have to bring the workable method here (even though its for specific OS) win 7 x64 bit first the UDF file should be saved as (name).c =====.>(important not capital c) then with only SDK command prompt (preferred Install a Software Development Kit (SKD) for 64bit systems. This may be the difference between 32bit and 64bit systems. I have used the .NET Framework 2.0 Software Development Kit (SDK) (x64) from 2006 [5] ) in my PC other versions 7.0 and 7.1 even work. Start FLUENT from the SDK command prompt. Do not use the Visual Studio command prompt, use the SDK command prompt! Go to the directory your case is in and type 'fluent'. regards, |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF for energy source term | engloly | Fluent UDF and Scheme Programming | 11 | June 25, 2017 07:05 |
pisoFoam compiling error with OF 1.7.1 on MAC OSX | Greg Givogue | OpenFOAM Programming & Development | 3 | March 4, 2011 18:18 |
UDF Source Term | Christian | FLUENT | 4 | August 1, 2009 06:53 |
The source term of UDF | summer | FLUENT | 0 | August 24, 2006 18:44 |
UDFs for Scalar Eqn - Fluid/Solid HT | Greg Perkins | FLUENT | 0 | October 11, 2000 04:43 |