|
[Sponsors] |
Error C2223 when compiling UDRGM (occuring when using cell macros) |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 16, 2019, 09:45 |
Error C2223 when compiling UDRGM (occuring when using cell macros)
|
#1 |
New Member
Join Date: Dec 2019
Posts: 19
Rep Power: 7 |
Hello,
I have been Looking for a solution to this Problem across this Forum but did not find anything helpful. I wrote a User Defined Real Gas Model and want to compile this UDF. When Compiling, Fluent Returns the following error: 'error C2223: left of "->storage" must point to struct/union' I get the error for every line where I have the following Code: double PP = C_P(c,t); is it not possible to declare and assign a local variable in that way inside something like this: double_RGP_density(c,t) { double PP = C_P(c,t); … } inside a UDRGM UDF? I also tried declaring and then assigning, like this: double PP; PP = C_P(c,t); buit this also yields an error… Has anyone experienced the same compilation error? Thanks in advance |
|
December 17, 2019, 02:26 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
pp is reserved name use my_pp for instance
__________________
best regards ****************************** press LIKE if this message was helpful |
|
December 17, 2019, 04:33 |
|
#3 |
New Member
Join Date: Dec 2019
Posts: 19
Rep Power: 7 |
Thanks for the answer. I changed PP to MY_PP but the error is still the same. Is there Maybe a certain header I need to include for C_P(c,t) to work?
So far, I included the following: #include "udf.h" #include "stdio.h" #include "ctype.h" #include "stdarg.h" #include "mem.h" #include "arrays.h" |
|
December 17, 2019, 07:34 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
show your code
replace double type with real and run case in double precision
__________________
best regards ****************************** press LIKE if this message was helpful |
|
December 18, 2019, 06:12 |
|
#5 | |
New Member
Join Date: Dec 2019
Posts: 19
Rep Power: 7 |
Quote:
#include "udf.h" #include "stdio.h" #include "ctype.h" #include "stdarg.h" #include "mem.h" #include "arrays.h" #define numPressure 100 #define numTemp 100 #define MW 28.96546 #define RGAS (UNIVERSAL_GAS_CONSTANT/MW) static int (*usersMessage)(char *,...); static void (*usersError)(char *,...); DEFINE_ON_DEMAND(I_do_nothing) { /* This is a dummy function to allow us to use */ /* the Compiled UDFs utility */ } void RGP_error(int err, char *f, char *msg) { if (err) usersError("Real_error (%d) from function: %s\n%s\n",err,f,msg); } void RGP_Setup(Domain *domain, cxboolean vapor_phase, char *filename, int (*messagefunc)(char *format, ...), void (*errorfunc)(char *format, ...)) { /* Use this function for any initialization or model setups*/ usersMessage = messagefunc; usersError = errorfunc; usersMessage("\nLoading Real Library: %s\n", filename); } double RGP_density(c,t) { int iP; int iT; double P[numPressure]; double T[numTemp]; double RHO[numPressure][numTemp]; double T1; double T2; double P1; double P2; double MY_PP = C_P(c,t); double MY_TT = C_T(c,t); double RHO11; double RHO12; double RHO21; double RHO22; double T2T1; double P2P1; double P2MY_PP; double MY_PPP1; double MY_TTT1; double T2MY_TT; double interpRHO; double R1; double R2; FILE *Tfile; FILE *Pfile; FILE *RHOfile; Tfile = fopen("Tstruct.csv","r"); Pfile = fopen("Pstruct.csv","r"); RHOfile = fopen("RHOstruct.csv","r"); int counter1 = 0; float buffer; while (counter1 < numPressure) { fscanf(Pfile,"%f",&buffer); P[counter1] = buffer; counter1 += 1; } int counter2 = 0; while (counter2 < numTemp) { fscanf(Tfile,"%f",&buffer); T[counter2] = buffer; counter2 += 1; } int counterP = 0; int counterT = 0; for (counterP = 0; counterP < numPressure; ++counterP) { for (counterT = 0; counterT < numTemp; ++counterT) { fscanf(RHOfile,"%f,",&buffer); RHO[counterP][counterT] = buffer; } } for (iP = 0; iP < numPressure; ++iP) { if (MY_PP <= P[iP] && MY_PP >= P[iP-1]) { for (iT = 0; iT < numTemp; ++iT) { if (MY_TT <= T[iT] && MY_TT >= T[iT-1]) { T1 = T[iT - 1]; T2 = T[iT]; P1 = P[iP - 1]; P2 = P[iP]; RHO11 = RHO[iP - 1][iT - 1]; RHO12 = RHO[iP - 1][iT]; RHO21 = RHO[iP][iT - 1]; RHO22 = RHO[iP][iT]; break; } } } } T2T1 = T2 - T1; P2P1 = P2 - P1; T2MY_TT = T2 - MY_TT; P2MY_PP = P2 - MY_PP; MY_PPP1 = MY_PP - P1; MY_TTT1 = MY_TT - T1; interpRHO = 1.0 / (P2P1 * T2T1) * ( RHO11 * P2MY_PP * T2MY_TT + RHO21 * MY_PPP1 * T2MY_TT + RHO12 * P2MY_PP * MY_TTT1 + RHO22 * MY_PPP1 * MY_TTT1 ); return interpRHO; fclose(Tfile); fclose(Pfile); fclose(RHOfile); } [then the same for all other properties, and in the end:] UDF_EXPORT RGAS_Functions RealGasFunctionList = { RGP_Setup, /* initialize */ RGP_density, /* density */ RGP_enthalpy, /* enthalpy */ RGP_entropy, /* entropy */ RGP_specific_heat, /* specific_heat */ RGP_mw, /* molecular_weight */ RGP_speed_of_sound, /* speed_of_sound */ RGP_viscosity, /* viscosity */ RGP_thermal_conductivity, /* thermal_conductivity */ RGP_rho_t, /* drho/dT |const p */ RGP_rho_p, /* drho/dp |const T */ RGP_enthalpy_t, /* dh/dT |const p */ RGP_enthalpy_p /* dh/dp |const T */ }; "Tstruct.csv" and "Pstruct.csv" are 1D-arrays with pressure and temperature Points, "RHOstruct.csv" is a 2D-array with Density[i,j] corresponding to the P[i] and T[j] Pressure and Temperature. The UDF takes the Pressure and Temperature and performs bilinear Interpolation to return the Density (and all other properties which i excluded because it is >1000 lines of Code. The Code works well when just used within a C-Compiler without the UDF-specific commands. I know the Code will be very slow but this is not an issue as it will only be called once to create lookup tables. P.S. I tried changing "double" to "real" and run in double precision but the error message stays the same... Last edited by c_023; December 18, 2019 at 06:25. Reason: forgot something |
||
December 19, 2019, 01:34 |
|
#6 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
function names are define wrong
was double RGP_density(c,t) to be double RGP_density(cell_t c,Thread *t) also all variables should be define in the top all function, for instance this will be a problem: int counter2 = 0; to be int counter2; counter2 = 0;
__________________
best regards ****************************** press LIKE if this message was helpful |
|
December 19, 2019, 05:28 |
|
#7 |
New Member
Join Date: Dec 2019
Posts: 19
Rep Power: 7 |
Thanks for the help, with your tips I got rid of the C2223 error. Now a bunch of new Errors turned up, like "C2081: "Thread": Name is not valid". I'll try to fix the Errors and will post the working Code if I get it to work.
|
|
December 19, 2019, 06:05 |
|
#8 |
New Member
Join Date: Dec 2019
Posts: 19
Rep Power: 7 |
||
December 19, 2019, 14:11 |
Help
|
#9 |
New Member
Djamila
Join Date: May 2016
Location: Algeria
Posts: 16
Rep Power: 10 |
hi all ,
I need you help please , my question is: How plotting a curve as a function of time on fluent in the steady case? Thanks |
|
December 20, 2019, 02:59 |
|
#10 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
in steady case there is no time, that's why it has name steady
__________________
best regards ****************************** press LIKE if this message was helpful |
|
Tags |
c2223, cell macro, compilation error, udf, udrgm |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
FvMatrix coefficients | shrina | OpenFOAM Running, Solving & CFD | 10 | October 3, 2013 15:38 |
UDF: Density Cell Gradient Vector Macros | matteo | FLUENT | 0 | December 1, 2007 13:14 |
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues | michele | OpenFOAM Meshing & Mesh Conversion | 2 | July 15, 2005 05:15 |
Warning 097- | AB | Siemens | 6 | November 15, 2004 05:41 |
cell to cell relation | CMB | Siemens | 1 | December 4, 2003 05:05 |