CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Error Using UDF for Multiphase Mass Transfer Problem (https://www.cfd-online.com/Forums/fluent/153310-error-using-udf-multiphase-mass-transfer-problem.html)

Ajinkya May 22, 2015 08:02

Error Using UDF for Multiphase Mass Transfer Problem
 
Hi,

I am trying to implement a simple UDF to understand bubble growth using a VOF model. The purpose of the UDF is to identify zones where interface lies and put a constant source term. Below is the UDF.

Code:

#include "udf.h"
#include "mem.h"
#include "sg.h"
#include "sg_mphase.h"
#include "sg_vof.h"
#include "flow.h"

DEFINE_MASS_TRANSFER(mass_trnsfr, c, mixture_thread, from_phase_index, from_species_index, to_phase_index, to_species_index)
{
  Thread *tp_l, *tp_v;
  real rate;
  tp_v = THREAD_SUB_THREAD(mixture_thread, to_phase_index);
  tp_l = THREAD_SUB_THREAD(mixture_thread, from_phase_index);
  real EPS;
  EPS = 0.05;
  if ((EPS < C_VOF(c,tp_l))&&(C_VOF(c,tp_l)<1-EPS))
    {
      rate = 0.01;
    }
  else
    {
      rate = 0;
    }
  return rate;

}

So now, while I interpret it, it gives the following error:
Line 7: Syntax error

If I compile it, it successfully gets compiled, but when I go to the Interactions tab to use the UDF, it says:
No user-defined functions have been loaded.

Please let me know.

I am using a linux (Red Hat Enterprise Edition) 64 bit computer. The FLUENT version is 14.0.0.

Thanks,
Ajinkya

Ajinkya May 23, 2015 06:15

Found the error. Basically, what I think is happening, is that when you declare a variable (variable EPS is of type real) and when you define a variable (EPS = 1e-3) are two seperate things in C. It is important that all your variable declarations be at the start of the function. (eg. double EPS, tolval, y1, y2; int x1, x2; etc.) and then followed by the respective definitions (eg. x1 = 3; y1= 2.21143; etc.).
Failing to do so, the C comiler detects this as an error. This is not a limitation while using C++. Only C.


All times are GMT -4. The time now is 13:14.