How to check by UDF if a cell zone has a source term?

Valérie Gelbgras
Valérie Gelbgras Member, Employee Posts: 157
First Answer Solution Developer Community of Practice Member 5 Likes Ansys Employee
✭✭✭✭
edited June 2023 in Fluids

How to check by UDF if a cell zone has a source term?

Tagged:

Answers

  • Valérie Gelbgras
    Valérie Gelbgras Member, Employee Posts: 157
    First Answer Solution Developer Community of Practice Member 5 Likes Ansys Employee
    ✭✭✭✭
    Answer ✓

    We can use THREAD_VAR(t).cell.sources

    This return 0 is there is no source term and 1 is there is a source term.

    Here is an example of DEFINE_ON_DEMAND using this function.

    #include "udf.h"
    int zoneID = 2;
    
    DEFINE_ON_DEMAND(check_if_zone_has_source)
    {
        Thread *t;
        Domain *domain = Get_Domain(1);
        t = Lookup_Thread(domain, zoneID);
        Message0("\n\n %d \n\n", THREAD_VAR(t).cell.sources);
    }