Tracking interfacial cells in 2 phase VOF

PawanPawan India Member Posts: 15

I am modeling laser melting of a solid using Solidification/Melting and VOF with an inert gas as the primary phase and the metal as the secondary phase. I want to apply the laser and other heat losses(convection and radiation) at the interface of the gas and the metal. When the laser melts the solid, the surface deforms and the interface location changes continuously. For this, I need to track the interfacial cells continuously at every iteration. The interfacial cells will have a volume fraction of the secondary phase in a given range(say 0.05 to 1) but this value changes in the cells at every iteration due to melting.

I am not an expert in writing UDFs and have started just a few months back. From what I understand, I can get the index of the interfacial cells using F_C0 and F_C1 and update these using DEFINE_ADJUST.

Can someone please give some hints on the correct way of doing this? Any help is much appreciated. Thanks in advance.


  • KremellaKremella Posts: 3,123Admin


    Do you wish to track this information for post-processing purposes? Or do you need to extract this information and pass this along to the solver?


  • PawanPawan IndiaPosts: 107Member

    @Kremella Thanks for your reply. I want to apply my source terms in these interfacial cells only and the position of interfacial cells will change at every iteration as the laser melts the surface. SO I hope that I should use DEFINE_ADJUST. Next is to get the index of the interfacial cells. For this, maybe I can use F_C0 and F_C1 and store the index in a UDM. I have written a code by taking a help from different online sources. But as I said that I am not an expert so I am not confident that the code is right.

  • PawanPawan IndiaPosts: 107Member

    @Kremella I have written a UDF for tracking the interfacial cells at every iteration using DEFINE_ADJUST. The UDF compiles without any error but the simulation crashes and FLUENT closes as soon as I start the calculation. Can you please give some advice about the UDF? I have been stuck with this for a long time now. Here is my UDF:

    DEFINE_ADJUST(adjust_interface, domain)


    Thread *t;

    Thread **pt;

    cell_t c;

    face_t f;

    face_t ftop;

    cell_t c0;

    cell_t c1;

    cell_t ca;

    cell_t cb;

    int phase_domain_index = 1;

    real zunit[ND_ND];

    real ZDOT;

    real es[ND_ND];

    real ds;

    real A[ND_ND];

    real A_by_es;

    real dr0[ND_ND];

    real dr1[ND_ND];


    if (FLUID_THREAD_P(t))


    Thread *ppt = pt[phase_domain_index];

    begin_c_loop(c,t)                                    // This will loop over all the cells in the domain


    real xc[ND_ND];


    NV_D(zunit, = ,0,0,1);

    int n;

    int top;

    C_UDMI(c,t,7) = xc[2];

    C_UDMI(c,t,8) = C_VOF(c,ppt);

    c_face_loop(c, t, n)                                // This will loop over all the faces of a cell and n is the local face index number


    f = C_FACE(c,t,n);


    ZDOT = NV_DOT(es,zunit);

    ca = F_C1(f,t);

    cb = F_C0(f,t);

    if(ZDOT == 1 && 0.05 < C_VOF(cb,ppt) < 1 && C_VOF(ca,ppt) == 0)


    top = n;


    ftop = C_FACE(c,t,top);                            // ftop is the global face index number. C_FACE converts local face index number, n to global face index number, ftop


    c1 = F_C1(ftop,t);                                 // c1 is the index of face's neighbouring C1 cell

    c0 = F_C0(ftop,t);                                 // c0 is the index of face's neighbouring C0 cell

    /* This is the volume fraction condition */

    if (C_VOF(c1,ppt) = 0.0 && 0.05 < C_VOF(c0,ppt) < 1)


    C_UDMI(c,t,9) = c0;

    C_UDMI(c,t,10) = c1;






    The error is thrown at the line if (FLUID_THREAD_P(t))

  • sdebsdeb Posts: 327Forum Coordinator


    You might consider creating a Cell Register with desired Liquid Fraction Range. Then patch a UDM (say value of 1) using this cell register that you created.

    You can patch it at a certain frequency using "Execute Commands" .

    That way you will have the information of the interface in the UDM and can further use it in other UDFs.



Sign In or Register to comment.