CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   compiling fails: UDF for extracting mixture fraction data (https://www.cfd-online.com/Forums/fluent-udf/154582-compiling-fails-udf-extracting-mixture-fraction-data.html)

Nekrokeks June 17, 2015 11:21

compiling fails: UDF for extracting mixture fraction data
 
Hello everyone,

I am working on implementing a UDF to postprocess my combustion data. I want to extract the mixture fraction data in combination with the corresponding z-coordinate of my oven (rotary kiln).
I think I have a script that would give me my data, but I am having trouble compiling it into fluent.
I do have Microsoft Visual Studios installed...

Heres my Code:
Code:

#include "udf.h"
#include "sg_mem.h"


DEFINE_ON_DEMAND(mixture_fraction)
{
    Domain *d;
    cell_t c;
    Thread *t;
    d = Get_Domain(1);
    float x[3];
   

    thread_loop_c(t,d)                /*loop over all cell-threads in the domain*/
    {
        begin_c_loop(c,t)            /*loop over all cells in the cell-threads*/
        {
            if (C_FMEAN(c,t) >= 0.058)    /*stoiciometric criterion*/
            {
            C_CENTROID(x,c,t);
            C_UDMI(c,t,0) = C_FMEAN(c,t);       
            C_UDMI(c,t,1) = x[2];        /*coordiantes of checked cells saved*/
            }
        }
        end_c_loop(c,t)
    }
}

And the resulting error messages are:

error C2143 mistake in syntax: ";" is missing in front of "typ"
error C2065 "x": not declared
error C2109: index requires an array or a pointer

Sadly I cant even find my syntax mistake here... Its my first UDF, I really do not have an eye for this, yet. :/

Thanks for your help!

Nekro

upeksa June 17, 2015 11:52

#include "udf.h"
#include "sg_mem.h"


DEFINE_ON_DEMAND(mixture_fraction)
{
Domain *d;
cell_t c;
Thread *t;
real x[3];
d = Get_Domain(1);


thread_loop_c(t,d) /*loop over all cell-threads in the domain*/
{
begin_c_loop(c,t) /*loop over all cells in the cell-threads*/
{
if (C_FMEAN(c,t) >= 0.058) /*stoiciometric criterion*/
{
C_CENTROID(x,c,t);
C_UDMI(c,t,0) = C_FMEAN(c,t);
C_UDMI(c,t,1) = x[2]; /*coordiantes of checked cells saved*/
}
}
end_c_loop(c,t)
}
}

It works now: You must declare your variables before starting your code.

Nekrokeks June 18, 2015 06:46

Hello upeksa, thanks for your answer.
I tried compiling the script with your change but it still doesnt work somehow... In fact I am getting an additional error:
"C2275: "real": unvalid usage of this typ as an expression

I thought if I say "float" that I do declare my variable right there... Is that incorrect?
Do you have more suggestions?

Thanks

Nekro

Nekrokeks June 20, 2015 06:56

Hm so nobody here has seen a similar problem?:/
I feel like it almost must be something with the compiling problem, but I am not experienced enough to know what to change.
The UDF itself is pretty simple and I keep starring at it without knowing what else could be wrong concerning the syntax....
I m glad for any hint!

pakk June 22, 2015 04:03

You can use float, but make sure you define it before you assign something to d. The important change that upeksa made was not changing "float" to "real", but moving the line up.

Nekrokeks June 22, 2015 07:37

Ohhhh wow.
Thank you so much pakk that you explained this nooby mistake to me = )
Thats awesome - it reads in the file! You just made my day!
Thank you:)


All times are GMT -4. The time now is 10:22.