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/)
-   -   Why leads UDS_FLUX Example from User Guide to wrong results? (https://www.cfd-online.com/Forums/fluent-udf/231611-why-leads-uds_flux-example-user-guide-wrong-results.html)

schwaral November 11, 2020 18:49

Why leads UDS_FLUX Example from User Guide to wrong results?
 
Hi all,

Instead of using the default flux term I want to use my own flux term now. I want to modify the velocity later and so on...

Now I started testing the DEFINE_UDS_FLUX example and I noticed, that for velocity =0 at the beginning of my Inlet-Velocity-SIgnal the example ends in wrong results.

I use a simple 1D case with 10 cells. left-side is UDS-Inlet with UDS-specified-Value=0.02939, right side is UDS-Outlet with Flux=0. in The middle of Domain I have 2 Cells with a source for UDS. I notice weird behavior on the left side at Inlet for velocity in my domain =0. The UDS Value is becoming too large then. I do not know how to avoid this, but I cannot negelect this behavior.

The code from User Guide:
Code:

DEFINE_UDS_FLUX(my_uds2_flux, f, t, i) //RETURNS MASS FLOW RATE THROUGH A GIVEN FACES
{
        cell_t  c0, c1 = -1; //the cell thread index
        Thread* t0, * t1 = NULL;
        real NV_VEC(psi_vec), NV_VEC(A), flux = 0.0;

        c0 = F_C0(f, t);
        t0 = F_C0_THREAD(f, t);
        F_AREA(A, f, t);

        /* If face lies at domain boundary, use face values; */
        /* If face lies IN the domain, use average of adjacent cells. */

        if (BOUNDARY_FACE_THREAD_P(t)) /*Most face values will be available*/
        {
                real dens;

                /* Depending on its BC, density may not be set on face thread*/
                if (NNULLP(THREAD_STORAGE(t, SV_DENSITY)))
                        dens = F_R(f, t);  /* Set dens to face value if available */
                else
                        dens = C_R(c0, t0); /* else, set dens to cell value */


                NV_DS(psi_vec, =, F_U(f, t), F_V(f, t), F_W(f, t), *, dens); // F_U(f, t) = u_velocity at face

                flux = NV_DOT(psi_vec, A); /* flux through Face */
                Message0("1: %g\n", flux);
        }
        else
        {
                c1 = F_C1(f, t);      /* Get cell on other side of face */
                t1 = F_C1_THREAD(f, t);

                NV_DS(psi_vec, =, C_U(c0, t0), C_V(c0, t0), C_W(c0, t0), *, C_R(c0, t0));
                NV_DS(psi_vec, +=, C_U(c1, t1), C_V(c1, t1), C_W(c1, t1), *, C_R(c1, t1));

                flux = NV_DOT(psi_vec, A) / 2.0; /* Average flux through face */
                Message0("2: %g\n", flux);
        }

        /* ANSYS FLUENT will multiply the returned value by phi_f (the scalar's
          value at the face) to get the "complete'' advective term.  */

        return flux;
}


schwaral November 13, 2020 08:35

It seems like the 3D case works just fine but 1D is not correct after initialization. It has to be something with the code or missing information from initialization. But I initialize in the same way I do with 3d.

sacespedeszu April 10, 2023 03:49

Hi schwaral. I am facing the same problem in 3D. The UDS_FLUX Example gives me wrong results. Have you managed to solve that problem?


All times are GMT -4. The time now is 00:56.