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/)
-   -   DEFINE_ADJUST not working properly (https://www.cfd-online.com/Forums/fluent-udf/87350-define_adjust-not-working-properly.html)

akm April 18, 2011 10:09

DEFINE_ADJUST not working properly
 
as i understand define_adjust can be "used to adjust or modify FLUENT
variables that are not passed as arguments
".
in my 3phase eularian simulation i am required to modify the volume fractions of the two secondary phases, keeping the volume of primary phase same.

i have done the calculation as required in define_execute_at_end, to compute how much do the volume fractions change and hence correctly computed the value of global variables 'vf1' and 'vfpr'.

my adjust macro:

Code:

DEFINE_ADJUST(mt,d)
{
  Thread *t;
  cell_t c;
  real volf1, volf2, volf3;
  real xc[ND_ND];

  if (counter == 1)
  {
    thread_loop_c(t,d)
    {
      begin_c_loop(c,t)
      {
        Thread *fr = THREAD_SUB_THREAD(t,1);  //1st secondary phase
        Thread *to = THREAD_SUB_THREAD(t,2); //2nd secondary phase
          volf1 = C_VOF(c,fr);
          volf2 = C_VOF(c,to);
          volf3 = 1-(volf1+volf2);  //primary phase volume frac.

          if(volf1 > 0.01)
          {
            C_VOF(c,fr) = volf1 * vf1/vfpr;  //modifying the vol.fr. of 1st sec. phase
            volf1 = C_VOF(c,fr);
            C_VOF(c,to) = 1-(volf1+volf3);  //adjusting the vol. fr. of 2nd sec. phase, keeping the sum of volume fractions unity.
            volf1 = C_VOF(c,fr);
            volf2 = C_VOF(c,to);

            C_CENTROID(xc,c,t);
            Message("%g\t%g",xc[0],xc[1]);
            Message("\t%g  %g\n",volf1,volf2);
          }
      }
      end_c_loop(c,t)
    }       
  }

}


When the variables are printed from the udf, they do seem to get modified as required by the problem. But returning to solver at the end of iteration/timestep, the variables show no change when viewed as contours or even when accessed by define_execute_at_end macro.

What might be the problem in modifying the variables ??
Is there anything wrong in what i am trying to do? Please suggest an alternative.

Can anyone please help me..

Regards.


All times are GMT -4. The time now is 07:34.