Fluids

Fluids

Update BC at every iteration by UDF

    • ehsan.sadeghi
      Subscriber

      I have the following UDF for changing BC for a UDS in every iteration until it reaches a desired condition. Basically what I want to do is check C_UDSI values of UDS0 on inlet faces and if its value is equal to E_peek assign C_UDSI of UDS1 to q. I am using adjust function to get the values of q and store it in UDMI to later use it in F_PROFILE.

      I am not sure if the way that I have implmented this UDF is correct, cause when I hook it and run the simulation, Fluent gives error. The UDF gets compiled without any error. I appreciate if you can give me some hints to know where is the problem in my code.

      Thanks

      DEFINE_ADJUST (UDF_adjust, d)

      {

      /*Domain definition variables */

      Thread *t;

      cell_t c;

      face_t f;

      /*q_density tracking variables*/

      real q_star=0;

      real q;

      real w = 0.1;

      real E_peek = (3E6*1.0) + (9E4/(sqrt(1.0/0.1)));




      /* Do nothing if gradient isn't allocated yet. */

      if (! Data_Valid_P())

      return;




      thread_loop_f(t,d)

          {

              begin_f_loop(c,t)

              {

      if (fabs(F_UDMI(f,t,3)-E_peek) <= 0.001)

      {

      q = F_UDSI(c, t, 1);

      }

      else

      {

      q_star = F_UDSI(c, t, 1)*(F_UDMI(f,t,3)/E_peek);

      q = w*q_star+(1.0-w)*F_UDSI(c, t, 1);

      }

              }

              end_f_loop(c,t)

          }

      }

    • Rob
      Ansys Employee

      What error are you getting? 

      • ehsan.sadeghi
        Subscriber
        ===================================================================================

        = BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES

        = RANK 0 PID 1228 RUNNING AT PC-ANSYS-157

        = EXIT STATUS: -1 (ffffffff)
    • Rob
      Ansys Employee

      Anything above that? 

      • ehsan.sadeghi
        Subscriber

        Fluent gets closed after appearing this message. I found in the logs the following error:

        Cortex received a fatal signal (SEGMENTATION VIOLATION).
    • Rob
      Ansys Employee

      Knocking the solver over takes some doing. If you open the transcript has the solver done an interation (or few) and then failed or failed before doing an iteration? 

      Note, I'm not going to debug or do much with the UDF. It's beyond what we're able to support on here, and my UDF coding skills aren't all that high. 

    • ehsan.sadeghi
      Subscriber
      Problem solved! the face values were not saved in UDMI
    • Rob
      Ansys Employee

      Excellent. I think there's a UDM for faces too, so have a look at the face-cell data macros. 

Viewing 5 reply threads
  • You must be logged in to reply to this topic.