Fluids

Fluids

Dynamic Mesh

    • gowthamdada
      Subscriber

      How to write a UDF for pressure driven flow under dynamic mesh conditions?


      Inlet pressure used to push the pig by that i have to find velocity of pig.


      Here i have attached picture for your view.

    • Karthik R
      Administrator

      Hello,


      Please refer to the UDF manual for details on how to write the UDF. I generally tend to use an already written UDF from the manual and modify to serve my purpose (rather than starting from scratch). 


      Btw, what are planning on doing with your UDF? Just curious.


      Best Regards,


      Karthik

    • gowthamdada
      Subscriber

      /************************************************************


      * compiled UDF


      ************************************************************/


      #include "udf.h"


      static real v_prev = 0.0;


      static real time_prev = 0.0;


       


       


      DEFINE_CG_MOTION(pig,dt1,dt2,vel,time,dtime)


      {


      Domain *d;


              Thread *t1; 


              Thread *t2;


              d = Get_Domain(1);


              int ID1 = 16; int ID2 = 17;


              t1 = Lookup_Thread(d, ID1);


              t2 = Lookup_Thread(d, ID2);


              face_t f;


      real NV_VEC(A);


      real force,force1,force2, dv;


       


       


      /* reset velocities */


      NV_S(vel, =, 0.0);  /* scalar vel[0] = 0.0*/ 


      if (!Data_Valid_P())


      return; 


      /* get the thread pointer for which this motion is defined 


      t1 = DT_THREAD(dt1);


               t2 = DT_THREAD(dt2);*/


       


      /* compute pressure force on body by looping through all faces */


      force = 0.0; 


      force1=0.0; 


      force2=0.0;


      /*Fc = (2*3.14*5*0.25*10106000*0.3)/(1-0.33);*/ /*contact force= 2*pi*lp*del*E*mu/(1-nu) */ 


      begin_f_loop(f,t1)


      {


      F_AREA(A,f,t1);


              force1 += F_P(f,t1) * A[0];


      }


      end_f_loop(f,t1)


       


      begin_f_loop(f,t2)


      {


               force2 += F_P(f,t2) * A[0];


       


              } 


      end_f_loop(f,t1)


       


          force = force1-force2;


       


      /* compute change in velocity, i.e., dv = F * dt / mass - Fc*dt /mass


      velocity update using explicit Euler formula */


           dv = (time * force / 50.0);/*- (Fc*time / 50.0);*/


      if (time > (time_prev + EPSILON))


          {


            v_prev += dv;


            time_prev = time;


          }


          


      Message ("time = %f, x_vel = %f, force = %fn", time,  v_prev,force);


       


      /* set x-component of velocity */


      vel[0] = v_prev;


      }


       


      this is what i tried... but i cant able to pick results.. whats problem on this

    • Raef.Kobeissi
      Subscriber

      Hello,


      Why is your UDF very complicated? for transient pressure inlet boundary condition, the UDF is simple. You can also write to file the velocity of the solid object:








      Regards

    • gowthamdada
      Subscriber

      Sir, 


      I used the same. but i gave one translation in that 6-dof dialogue box and created dynamic mesh using layering technique but it's not working. 


      Kindly help me further

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