Fluids

Fluids

Dynamic mesh

    • Santu Golder
      Subscriber

      Hi, 

      I am doing dynamic mesh for my simulation using UDF. What code can I use in UDF to give the distance that the moving body can travel? I want to limit the distance to be traveled between 0 to 0.25 (m). And it is an oscillation of a solid body.

      Following is the equation that is applied to give the motion. 

      vel = 0.03*sin(1.1416*time/10.);

      Santu 

    • Prashanth
      Ansys Employee

      Hi 

      DEFINE_CG_MOTION can be used. You can also check a example case in the UDF manual.

    • Santu Golder
      Subscriber

      Hi  Prashanth,

       

      Thank you for your reply. I've coded the equation as follows:

      # include "udf.h"

      static real velx = 0.0;

      DEFINE_CG_MOTION(box,dt,vel,omega,time,dtime)
      {
          NV_S(vel, =, 0.0);
          NV_S(omega, =, 0.0);

          velx = 0.01*sin(1.1416*time/10.);
          vel[1] = velx;
          Message("time = %f, vel[1] = %f\n", time, vel[1]);
      }

      But for giving the limit to move the moving box, which one should I add:

      if (!Data_Valid_P())
      return;

      or 

      any other loop that I need to apply.

       

    • Prashanth
      Ansys Employee

      Sure, you can use if and else to limit the motion

    • Santu Golder
      Subscriber

      Hi,

      Can you please help me to apply the if and else statement to limit the motion? Mine is not working at all.

       

      Regards

      Santu

    • Prashanth
      Ansys Employee

      Hi, Can you check out this dynamic mesh robotic arm tutorial that uses something similar:

       

    • Santu Golder
      Subscriber

       

       

      Hi Prashant, 

      I’ve applied the following code for limiting the motion. But it did not work, My motion is sinusoidal and the length is 0 m to 0.2m. I want to limit it to 0.18 m and the box will return its initial position. It is a to and fro motion of piston in a piston chamber. 

      # include “udf.h”

      static real velx = 0.0;

      DEFINE_CG_MOTION(box,dt,vel,omega,time,dtime)
      {
          NV_S(vel, =, 0.0);
          NV_S(omega, =, 0.0);

          velx = 0.05*sin(3.1416*time/10.);

          if (time<=5)
              vel[1] = velx;
          else
              vel[1] = velx;

          Message(“time = %f, vel[1] = %f\n”, time, vel[1]);
      }

      Regards

      Santu 

       

       

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