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/)
-   -   UDM value for stopping calculation based on convergence criteria (https://www.cfd-online.com/Forums/fluent-udf/230383-udm-value-stopping-calculation-based-convergence-criteria.html)

schwaral September 21, 2020 09:20

UDM value for stopping calculation based on convergence criteria
 
Hi, I want to interrupt my calculation based on convergence criteria. My criteria should be the value I store in tthe UDM. Somehow I don't manage to store the value in the UDM with my UDF. I activate 1 UDM in fluent.

I receive an error, that is most likely becauce I use the loops not correctly.
when I just message0 the value of my criteria (fnew*fprev) in the console, everything works great. When I build in the loops and want to set the UDM to 0 or 1 it fails.

Error: Error: received a fatal signal (Segmentation fault).
Error Object: #f

UDF:
Code:

DEFINE_ADJUST(adjust_UDS_bc, d)
{
        Thread* t;
        cell_t c;
        face_t f;
        thread_loop_c(t, d);
        {
                if ((fnew * fprev) <= 0)
                {
                        begin_c_loop(c, t)
                        {
                                C_UDMI(c, t, 0) = 1;
                        }
                        end_c_loop(c, t)
                        Message0(" UDM: %lf \n", fnew * fprev);
                }
                if ((fnew * fprev) > 0)
                {
                        begin_c_loop(c, t)
                        {
                                C_UDMI(c, t, 0) = 0;
                        }
                        end_c_loop(c, t)
                        Message0(" UDM: %lf \n", fnew* fprev);
                }
        }
}


Maybe someone has a better understanding of the loops and can help

AlexanderZ October 5, 2020 03:35

Code:

DEFINE_ADJUST(adjust_UDS_bc, d)
{
        Thread* t;
        cell_t c;
        face_t f;
        Message0(" UDM: %lf \n", fnew * fprev);
        thread_loop_c(t, d);
        {
                begin_c_loop(c, t)
                {
                        if ((fnew * fprev) <= 0) C_UDMI(c, t, 0) = 1;
                        else C_UDMI(c, t, 0) = 0;
                }
                end_c_loop(c, t)
        }
}

fnew * fprev suppose to be defined somewhere else

schwaral October 5, 2020 07:52

Quote:

Originally Posted by AlexanderZ (Post 784431)

fnew * fprev suppose to be defined somewhere else

Yes, These two variable are defined globally and calculated in a diffrent UDF. I think that is not the problem?

AlexanderZ October 6, 2020 03:38

did you try the code, I've attached above?


All times are GMT -4. The time now is 15:38.