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/)
-   -   urgent! Help! Define mass source on boundary cells used UDF (https://www.cfd-online.com/Forums/fluent-udf/234648-urgent-help-define-mass-source-boundary-cells-used-udf.html)

ssetay March 14, 2021 02:22

urgent! Help! Define mass source on boundary cells used UDF
 
1 Attachment(s)
Hi, friends

I am using UDF to define a mass source on the boundary cells,here's my code.
My case is this: particles and water flow in a pipe, and I want to define a mass source for the particle phase in the pipe wall cells.
When I compile this UDF, it works normally, but the volume fraction of particles at the wall has not changed. According to my UDF, the volume fraction of the particle phase in the pipe wall cells should be reduced. I don't know where the error is, but the UDF can work well after compilation. Can anyone help me? Any suggestions will be appreciated!

code:


Code:

//* You are storing source in User defined memory under DEFINE_ON_DEMAND. Then you are using UDMI(c0,t0,0) in DEFINE_SOURCE *//
#include "udf.h"
//get the boundary cells
DEFINE_ON_DEMAND(selecting_the_cells)
{
#if !RP_HOST
        Domain *d;
        Thread *t, *tc, *t0;
        face_t f;
        cell_t c, c0;
        d = Get_Domain(1);
        tc = Lookup_Thread(d, 9); //Get boundary thread, wall zone ID is 9
        //Loop through all the cell threads in the domain
        thread_loop_c(t, d)
        {
                //Loop through the cells in each cell thread
                begin_c_loop(c, t)
                {
                        C_UDMI(c, t, 0) = 0;
                }
                end_c_loop(c, t)
        }

        begin_f_loop(f, tc)
        {
                c0 = F_C0(f, tc);
                t0 = THREAD_T0(tc);
                C_UDMI(c0, t0, 0) = 1;
        }
        end_f_loop(f, tc)
#endif
}

DEFINE_SOURCE(mass_source, c, t, dS, eqn)
{
        real source;
        if (C_UDMI(c, t, 0) > 0.)
        {
                source = -1000.;
                dS[eqn] = 0.;
        }
        else
        {
                source = 0.;
                dS[eqn] = 0.;
        }
        return source;
}


pakk March 14, 2021 04:29

"According to my UDF, the volume fraction of the particle phase in the pipe wall cells should be reduced."

I don't see that. According to your UDF, UDM 0 should be zero everywhere, except at the wall where it is one. Does that part work?

Why that should mean that the volume fraction changes: that depends on how you use UDM 0... Not part of this UDF, but elsewhere in your model.

ssetay March 14, 2021 20:06

Thanks for your suggestion, and sorry for my late reply.

"I don't see that. According to your UDF, UDM 0 should be zero everywhere, except at the wall where it is one. Does that part work?"
To be honest, I want to use UDM0 to distinguish wall cells. As you just said, UDM0 is 1 in the wall cells and 0 in other cells; In this way, I can specify the source in the wall cell in the following if statement (if (C_UDMI(c, t, 0)> 0.)). Is there anything wrong with this? please give me some advice.

"Why that should mean that the volume fraction changes: that depends on how you use UDM 0... Not part of this UDF, but elsewhere in your model."
I'm sorry I didn't understand you. I am a UDF rookie... Do you mean there is a problem with my UDF0 usage method?


Any suggestions will be appreciated.
best wishes

pakk March 15, 2021 01:30

I hadn't noticed the second UDF.

AlexanderZ March 17, 2021 21:46

you code seems to be correct,
do you see what you want, when making contour of C_UDMI_0 ?
are you sure, that -1000 is value which you want? check units

ssetay March 18, 2021 05:27

Thanks Reply! Now it works great because I forgot to load it...


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