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/)
-   -   UDF Parse Error - Initializing VOF for Multiphase Simulation (https://www.cfd-online.com/Forums/fluent-udf/201210-udf-parse-error-initializing-vof-multiphase-simulation.html)

denbjornen April 25, 2018 02:07

UDF Parse Error - Initializing VOF for Multiphase Simulation
 
I'm having a hard time writing a UDF for patching the volume fraction for a phase in my domain at the start of a solution.

Big picture: I am running a 2-way coupled transient FSI simulation that has a transient frame motion angular velocity UDF. To make things more complex, the simulation is also multiphase (water & air).

Ordinarily, I'd just patch the air region using by marking the cells; but this does not seem to save the initialization state for system coupling and I get errors. I've been looking into solving this problem that initializes the VOF from a UDF at the start of the solution process. But if somebody has a more elegant solution, I'm all ears. I have little experience in C (I prefer python) so I'm quite irritated by what I think is probably a very simple error. The following UDF is taken from:
https://www.sharcnet.ca/Software/Flu...udf/node98.htm

Code:

/*****************************************************************
  UDF for initializing phase volume fraction                   
******************************************************************/

#include "udf.h"
/* domain pointer that is passed by INIT function is mixture domain  */
DEFINE_INIT(patch_vof, mixture_domain)
{
        int phase_domain_index;
        cell_t cell;
        Thread *cell_thread;
        Domain *subdomain;
        real xc[ND_ND];
  /* loop over all subdomains (phases) in the superdomain (mixture) */
  sub_domain_loop(subdomain, mixture_domain, phase_domain_index)
  {
    /* loop if secondary phase  */
    if (DOMAIN_ID(subdomain) == 3)     

    /* loop over all cell threads in the secondary phase domain  */
    thread_loop_c (cell_thread,subdomain)
    {
        /* loop over all cells in secondary phase cell threads  */
        begin_c_loop_all (cell,cell_thread)
        {
            C_CENTROID(xc,cell,cell_thread);
                       
            if -0.35<NODE_X(xc[0])<0.35 && 0.0<NODE_Y(xc[1])<0.2 && -0.05<NODE_Z(xc[2])<0.05
                                C_VOF(cell,cell_thread) = 1.;
            else
                                C_VOF(cell,cell_thread) = 0.;
        }
        end_c_loop_all (cell,cell_thread)
    }

  }
}

When trying to interpret this UDF in Fluent, I get "parse error" for the if and else lines. I'm really not sure if the structure of the "if" statement is correct, regarding "xc" and the NODE functions (I really don't know what they do). I just need to initialize the volume fraction to 1 inside of the bounds, to 0 outside of the bounds.

I found a thread:
https://www.cfd-online.com/Forums/fl...egion-udf.html

That claims to have a working UDF, but I've tested it and it does not work. It makes use of ND_SUM and sqrt, but the "if" statement doesn't seem to be evaluating anything (just a sqrt of a sum). I really don't know what to do; but I feel that it should be extremely simple to an experienced UDF programmer.

Thanks


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