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/)
-   -   Make FLUENT stop calculations automatically (https://www.cfd-online.com/Forums/fluent-udf/252373-make-fluent-stop-calculations-automatically.html)

kele October 14, 2023 08:04

Make FLUENT stop calculations automatically
 
Hello everyone, I combined udf and scheme to make FLUENT automatically stop calculating when the wall temperature and pressure reach conditions. But it is not possible to realize it.here is my code with many references. thank you:)
Code:

#include "udf.h"
#include "math.h"
#include "var.h"

DEFINE_ADJUST(interrupt_1, d)
{

        cell_t cell;
        Thread* thread;
        Domain* domain;
        real temp, pressure, NV_VEC(dist);
        int ID = 12; 
        face_t f;
        Thread* t;
        cell_t c0, c1;

        domain = Get_Domain(1);


        thread = Lookup_Thread(domain, ID);



          begin_f_loop(f, thread)
            {
                      c0 = F_C0(f, thread);
                      c1 = F_C1(f, thread);


                      if (THREAD_ID(thread) == ID)
                      {
                              t = THREAD_T0(thread);
                              if (c0 != -1)
                              {

                                        temp = C_T(c0, t);
                                        pressure = C_P(c0, t);

                                        if (temp > 250.0 && pressure > 140)
                                        {

                                                        RP_Set_Integer("interrupt/flag",5); 
                                                        Message("Temperature exceeds 2500K and Pressure exceeds 1.4MPa. Stopping simulation...\n");
                                        }
                              }
                      }
            }
          end_f_loop(f, thread)                       
}

schemem code
Code:

(rp-var-define 'interrupt/flag 0 'integer #f)
(define (interrupt-end-of-timestep)
  (if (> (%rpgetvar 'interrupt/flag) 0)
      (begin (cx-interrupt-end-of-timestep))))


AlexanderZ October 16, 2023 00:18

https://www.cfd-online.com/Forums/fl...lculation.html


All times are GMT -4. The time now is 21:26.