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

compiling fails: UDF for extracting mixture fraction data

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 17, 2015, 12:21
Default compiling fails: UDF for extracting mixture fraction data
  #1
New Member
 
Torsten
Join Date: Jun 2015
Posts: 4
Rep Power: 11
Nekrokeks is on a distinguished road
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
Nekrokeks is offline   Reply With Quote

Old   June 17, 2015, 12:52
Default
  #2
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 13
upeksa is on a distinguished road
#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.
upeksa is offline   Reply With Quote

Old   June 18, 2015, 07:46
Default
  #3
New Member
 
Torsten
Join Date: Jun 2015
Posts: 4
Rep Power: 11
Nekrokeks is on a distinguished road
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 is offline   Reply With Quote

Old   June 20, 2015, 07:56
Default
  #4
New Member
 
Torsten
Join Date: Jun 2015
Posts: 4
Rep Power: 11
Nekrokeks is on a distinguished road
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!
Nekrokeks is offline   Reply With Quote

Old   June 22, 2015, 05:03
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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.
pakk is offline   Reply With Quote

Old   June 22, 2015, 08:37
Default
  #6
New Member
 
Torsten
Join Date: Jun 2015
Posts: 4
Rep Power: 11
Nekrokeks is on a distinguished road
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
Nekrokeks is offline   Reply With Quote

Reply


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
fluent udf, saving data in udf mohsen zendehbad Fluent UDF and Scheme Programming 15 June 14, 2017 00:23
UDF DPM_BC with F_UDMI not storing data balki Fluent UDF and Scheme Programming 3 June 6, 2016 23:10
multiphase turbulance case floating error harsha_kulkarni OpenFOAM Running, Solving & CFD 3 February 18, 2016 06:06
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Meshing & Mesh Conversion 12 May 2, 2013 11:52
mixture fraction Sheng Chen Main CFD Forum 0 October 6, 2004 02:33


All times are GMT -4. The time now is 01:34.