|
[Sponsors] |
UDF to Define Species Mass Fraction on mass flow-Inlet |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 28, 2020, 09:44 |
UDF to Define Species Mass Fraction on mass flow-Inlet
|
#1 |
Member
abdo
Join Date: Apr 2018
Posts: 42
Rep Power: 7 |
hello guys, I try for days to write a small UDF to specify the species mass fraction at 2d inlet reactive channel such I am new in c++ programming..
this is my udf: #include "mem.h" #define Y_CH4_in 0.032; #define Y_O2_in 0.225; #define t0 = 573; DEFINE_PROFILE(mass_fraction, t, i) { thread *t0; face_t f; face *f; cell_t c,c0; int i; begin_f_loop(f, t) { t0 = t_t0(t); c0 = face_c0(f, t) F_PROFILE(f,t,i) = Y_CH4_in 0.032; F_PROFILE(f,t,i) = Y_O2_in 0.225; } end_f_loop(f,t) } I open the fluent from VS and I try fo compile it but I found many errors... this is the errors: (system "copy "C:\PROGRA~1\ANSYSI~1\v190\fluent"\fluent19.0.0\sr c\udf\makefile_nt.udf "libudf\win64\2ddp_node\makefile" ") 1 file(s) copied. (chdir "libudf")(chdir "win64\2ddp_node")# Generating ud_io1.h udf.c ..\..\src\udf.c(8): error C2065: 'thread': undeclared identifier ..\..\src\udf.c(8): error C2059: syntax error: '=' ..\..\src\udf.c(10): error C2065: 'face': undeclared identifier ..\..\src\udf.c(10): warning C4552: '*': result of expression not used ..\..\src\udf.c(12): error C2082: redefinition of formal parameter 'i' ..\..\src\udf.c(15): error C2143: syntax error: missing ';' before '=' ..\..\src\udf.c(17): error C2064: term does not evaluate to a function taking 337 arguments Done. I am confused and I am thankful for any suggestion! |
|
October 28, 2020, 11:06 |
|
#2 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
Hi Khaledhmz,
OK, here are some initial hints: You want #include "udf.h", not mem.h. Try to follow one of the examples in the manual. The preprocessor macro #define does not need a semicolon at the end. The basic meaning of "#define XXX YYY" is that the preprocessor does a find-and-replace, finding every instance of XXX and replacing it with YYY. This is not 100% true -- for example, it will avoid instances of XXX inside quoted strings, and so on -- but it's a start. The variable i is defined as a parameter in DEFINE_PROFILE, which is why you get an error message about Line 12. Delete Line 12. Go through the compiler errors, and try to fix them, starting with the first one. In the current case, this complains that it knows nothing about the name (or identifier) "thread". Fix this, remembering that C is case-sensitive. Given your preprocessor #define lines, this line: Code:
F_PROFILE(f,t,i) = Y_CH4_in 0.032; Code:
F_PROFILE(f,t,i) = 0.032; 0.032; Code:
F_PROFILE(f,t,i) = 0.032 0.032; Code:
#define Y_CH4_in 0.032 F_PROFILE(f,t,i) = Y_CH4_in; Good luck! Ed |
|
October 31, 2020, 09:45 |
new warnings
|
#3 | |
Member
abdo
Join Date: Apr 2018
Posts: 42
Rep Power: 7 |
Quote:
hi bro , thank you for the replying I corrected some errors but still I have some warning when I compiled it the warning printed in fluent secreen is: (system "copy "C:\PROGRA~1\ANSYSI~1\v190\fluent"\fluent19.0.0\sr c\udf\makefile_nt.udf "libudf\win64\2ddp_node\makefile" ") 1 file(s) copied. (chdir "libudf")(chdir "win64\2ddp_node")# Generating ud_io1.h udf.c c:\users\khaled hmz\desktop\c++\libudf\src\udf.c(13) : warning C4789: buffer 'x' of size 8 bytes will be overrun; 8 bytes will be written starting at offset 8 # Generating udf_names.c because of makefile udf.obj udf_names.c # Linking libudf.dll because of makefile user_nt.udf udf_names.obj udf.obj Microsoft (R) Incremental Linker Version 14.16.27043.0 Copyright (C) Microsoft Corporation. All rights reserved. Creating library libudf.lib and object libudf.exp Done. and this error also ; > Copied C:\Users\KHALED hmz\Desktop\c++/udf.c to libudf\src Creating user_nt.udf file for 2ddp_host ... (system "copy "C:\PROGRA~1\ANSYSI~1\v190\fluent"\fluent19.0.0\sr c\udf\makefile_nt.udf "libudf\win64\2ddp_host\makefile" ") 1 file(s) copied. (chdir "libudf")(chdir "win64\2ddp_host")# Generating ud_io1.h udf.c ..\..\src\udf.c(14): error C2064: term does not evaluate to a function taking 337 arguments Creating user_nt.udf file for 2ddp_node ... (system "copy "C:\PROGRA~1\ANSYSI~1\v190\fluent"\fluent19.0.0\sr c\udf\makefile_nt.udf "libudf\win64\2ddp_node\makefile" ") 1 file(s) copied. (chdir "libudf")(chdir "win64\2ddp_node")# Generating ud_io1.h udf.c ..\..\src\udf.c(14): error C2064: term does not evaluate to a function taking 337 arguments Done. thank you |
||
October 31, 2020, 10:06 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
The only warning is about line 13. What is on line 13 of your new code? We can't see that.
|
|
October 31, 2020, 11:46 |
|
#5 |
Member
abdo
Join Date: Apr 2018
Posts: 42
Rep Power: 7 |
||
October 31, 2020, 15:46 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Then your code is completely different from what you posted above. Put the full code here, otherwise we have to guess.
|
|
October 31, 2020, 16:26 |
|
#7 | |
Member
abdo
Join Date: Apr 2018
Posts: 42
Rep Power: 7 |
Quote:
okey, this is my full code: #include "udf.h" #include "mem.h" #define Y_CH4_in 0.032 #define Y_O2_in 0.225 DEFINE_PROFILE(mass_fraction, t, i) { double x[1]; double y; face_t f; begin_f_loop(f, t) { F_CENTROID(x, f, t); y = x[1] F_PROFILE(f, t, i) = Y_CH4_in; F_PROFILE(f, t, i) = Y_O2_in; } end_f_loop(f, t) } |
||
October 31, 2020, 16:57 |
|
#8 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Quote:
You still have to add code to distinguish mixture gases, but I don't remember how that is. |
||
October 31, 2020, 17:58 |
|
#9 |
Member
abdo
Join Date: Apr 2018
Posts: 42
Rep Power: 7 |
You still have to add code to distinguish mixture gases, but I don't remember how that is.
did you mean should separate them,every mass fraction had a different symbol? |
|
October 31, 2020, 22:04 |
|
#10 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
||
November 2, 2020, 07:11 |
|
#11 |
Member
abdo
Join Date: Apr 2018
Posts: 42
Rep Power: 7 |
ah okey
thank's for helping |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF Error for defining 2D circular mass flow rate inlet type | R.Velayati | Fluent UDF and Scheme Programming | 1 | July 8, 2019 01:54 |
UDF to Define Species Mass Fraction on Velocity-Inlet | MiBe | Fluent UDF and Scheme Programming | 3 | August 3, 2017 05:36 |
Define mass flow profile with regards to species mass fraction | danS | Fluent UDF and Scheme Programming | 0 | June 20, 2017 07:21 |
Surface Integrals of Species Mass Flow to Wall Incorrect | koad | FLUENT | 4 | January 12, 2016 17:38 |
Installing OF 1.6 on Mac OS X | gschaider | OpenFOAM Installation | 129 | June 19, 2010 10:23 |