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

Error C2223 when compiling UDRGM (occuring when using cell macros)

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By AlexanderZ
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 16, 2019, 08:45
Default Error C2223 when compiling UDRGM (occuring when using cell macros)
  #1
New Member
 
Join Date: Dec 2019
Posts: 19
Rep Power: 6
c_023 is on a distinguished road
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
c_023 is offline   Reply With Quote

Old   December 17, 2019, 01:26
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
pp is reserved name use my_pp for instance
c_023 likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   December 17, 2019, 03:33
Default
  #3
New Member
 
Join Date: Dec 2019
Posts: 19
Rep Power: 6
c_023 is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
pp is reserved name use my_pp for instance
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"
c_023 is offline   Reply With Quote

Old   December 17, 2019, 06:34
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
show your code

replace double type with real and run case in double precision
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   December 18, 2019, 05:12
Default
  #5
New Member
 
Join Date: Dec 2019
Posts: 19
Rep Power: 6
c_023 is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
show your code

replace double type with real and run case in double precision
my Code:

#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 05:25. Reason: forgot something
c_023 is offline   Reply With Quote

Old   December 19, 2019, 00:34
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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;
c_023 likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   December 19, 2019, 04:28
Default
  #7
New Member
 
Join Date: Dec 2019
Posts: 19
Rep Power: 6
c_023 is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
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;
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.
c_023 is offline   Reply With Quote

Old   December 19, 2019, 05:05
Default
  #8
New Member
 
Join Date: Dec 2019
Posts: 19
Rep Power: 6
c_023 is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
function names are define wrong
was
double RGP_density(c,t)
to be
double RGP_density(cell_t c,Thread *t)
This solution that you pointed out worked for me. The Code compiled now without Errors. The remaining Errors were just typos. Thanks again for the help.
c_023 is offline   Reply With Quote

Old   December 19, 2019, 13:11
Question Help
  #9
New Member
 
Djamila
Join Date: May 2016
Location: Algeria
Posts: 16
Rep Power: 9
djamila77 is on a distinguished road
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
djamila77 is offline   Reply With Quote

Old   December 20, 2019, 01:59
Default
  #10
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Quote:
Originally Posted by djamila77 View Post
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
in steady case there is no time, that's why it has name steady
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Reply

Tags
c2223, cell macro, compilation error, udf, udrgm


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
FvMatrix coefficients shrina OpenFOAM Running, Solving & CFD 10 October 3, 2013 14:38
UDF: Density Cell Gradient Vector Macros matteo FLUENT 0 December 1, 2007 12:14
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 04:15
Warning 097- AB Siemens 6 November 15, 2004 04:41
cell to cell relation CMB Siemens 1 December 4, 2003 04:05


All times are GMT -4. The time now is 20:15.