Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Error with Mesh Deformation

    • Pavitra Attanayake
      Subscriber

      Hi,

      I'm new to Ansys Fluent and am trying to learn how to deform a mesh. Specifically, I have a chamber of the heart that I need to contract with each heartbeat. I'm trying to start simple by just having the mesh undergo deformations in all 3 axes using a sinusoidal function (see the code below). The code compiles, loads, and runs without issue but when I try to Preview Mesh Motion, there is absolutely no change to the mesh at all and I'm stumped, can anyone help me out? 

      UDF:

      #include "udf.h"
       
      DEFINE_GRID_MOTION(deform_mesh, domain, dt, time, dtime)
      {
          real amplitude = 10.0;
          real frequency = 60;
          real displacement_x = amplitude * sin(2.0 * M_PI * frequency * time);
          real displacement_y = amplitude * cos(2.0 * M_PI * frequency * time);
          real displacement_z = amplitude * sin(2.0 * M_PI * frequency * time);
       
          Thread *t;
          Node *v;
       
          /* Loop over all nodes in the domain */
          thread_loop_nodes(t, domain)
          {
              begin_node_loop(v, t)
              {
                  real coord[ND_ND];
                  NV_V(coord, =, NODE_COORD(v));
       
                  coord[0] += displacement_x;
                  coord[1] += displacement_y;
                  coord[2] += displacement_z;
       
                  NV_S(NODE_COORD(v), =, coord);
              }
              end_node_loop(v, t)
          }
      }
       
      I imported this UDF and assigned it to the interior zone of the heart (I also tried using it with the wall, just to make sure that wasn't my issue). From there, I tried to Preview and have tried multiple time steps, frequencies, amplitudes, etc to no avail. I've also tried making the mesh more/less refined. Here is an example of what I see when I run the Preview, there is no change in any of the numbers except for the time: 
       

      Updating mesh to time 4.67700e+03 (step = 00180)...

      Dynamic Mesh Statistics:

      Minimum Volume = 5.44652e-15

      Maximum Volume = 3.02548e-08

      Maximum Cell Skew = 9.76395e-01 (cell zone 3)

      Warning: maximum cell skewness exceeds 0.95.

      Minimum Orthogonal Quality = 2.36051e-02 (cell zone 3)

      Warning: minimum orthogonal quality less than 0.05.

      Maximum Face Skew = 8.78838e-01 (face zone 1)

       

      done.

      Updating mesh to time 4.70700e+03 (step = 00181)...

      Dynamic Mesh Statistics:

      Minimum Volume = 5.44652e-15

      Maximum Volume = 3.02548e-08

      Maximum Cell Skew = 9.76395e-01 (cell zone 3)

      Warning: maximum cell skewness exceeds 0.95.

      Minimum Orthogonal Quality = 2.36051e-02 (cell zone 3)

      Warning: minimum orthogonal quality less than 0.05.

      Maximum Face Skew = 8.78838e-01 (face zone 1)

       

      done.

      Updating mesh to time 4.73700e+03 (step = 00182)...

      Dynamic Mesh Statistics:

      Minimum Volume = 5.44652e-15

      Maximum Volume = 3.02548e-08

      Maximum Cell Skew = 9.76395e-01 (cell zone 3)

      Warning: maximum cell skewness exceeds 0.95.

      Minimum Orthogonal Quality = 2.36051e-02 (cell zone 3)

      Warning: minimum orthogonal quality less than 0.05.

      Maximum Face Skew = 8.78838e-01 (face zone 1)

       

      done.

      Updating mesh to time 4.76700e+03 (step = 00183)...

      Dynamic Mesh Statistics:

      Minimum Volume = 5.44652e-15

      Maximum Volume = 3.02548e-08

      Maximum Cell Skew = 9.76395e-01 (cell zone 3)

      Warning: maximum cell skewness exceeds 0.95.

      Minimum Orthogonal Quality = 2.36051e-02 (cell zone 3)

      Warning: minimum orthogonal quality less than 0.05.

      Maximum Face Skew = 8.78838e-01 (face zone 1)

       

      done.

      Updating mesh to time 4.79700e+03 (step = 00184)...

      Dynamic Mesh Statistics:

      Minimum Volume = 5.44652e-15

      Maximum Volume = 3.02548e-08

      Maximum Cell Skew = 9.76395e-01 (cell zone 3)

      Warning: maximum cell skewness exceeds 0.95.

      Minimum Orthogonal Quality = 2.36051e-02 (cell zone 3)

      Warning: minimum orthogonal quality less than 0.05.

      Maximum Face Skew = 8.78838e-01 (face zone 1)

       

      done.

      Updating mesh to time 4.82700e+03 (step = 00185)...

      Dynamic Mesh Statistics:

      Minimum Volume = 5.44652e-15

      Maximum Volume = 3.02548e-08

      Maximum Cell Skew = 9.76395e-01 (cell zone 3)

      Warning: maximum cell skewness exceeds 0.95.

      Minimum Orthogonal Quality = 2.36051e-02 (cell zone 3)

      Warning: minimum orthogonal quality less than 0.05.

      Maximum Face Skew = 8.78838e-01 (face zone 1)

       

      done.

      Updating mesh to time 4.85700e+03 (step = 00186)...

      Dynamic Mesh Statistics:

      Minimum Volume = 5.44652e-15

      Maximum Volume = 3.02548e-08

      Maximum Cell Skew = 9.76395e-01 (cell zone 3)

      Warning: maximum cell skewness exceeds 0.95.

      Minimum Orthogonal Quality = 2.36051e-02 (cell zone 3)

      Warning: minimum orthogonal quality less than 0.05.

      Maximum Face Skew = 8.78838e-01 (face zone 1)

       

      done.

      Updating mesh to time 4.88700e+03 (step = 00187)...

      Dynamic Mesh Statistics:

      Minimum Volume = 5.44652e-15

      Maximum Volume = 3.02548e-08

      Maximum Cell Skew = 9.76395e-01 (cell zone 3)

      Warning: maximum cell skewness exceeds 0.95.

      Minimum Orthogonal Quality = 2.36051e-02 (cell zone 3)

      Warning: minimum orthogonal quality less than 0.05.

      Maximum Face Skew = 8.78838e-01 (face zone 1)

       

      done.

      Updating mesh to time 4.91700e+03 (step = 00188)...

      Dynamic Mesh Statistics:

      Minimum Volume = 5.44652e-15

      Maximum Volume = 3.02548e-08

      Maximum Cell Skew = 9.76395e-01 (cell zone 3)

      Warning: maximum cell skewness exceeds 0.95.

      Minimum Orthogonal Quality = 2.36051e-02 (cell zone 3)

      Warning: minimum orthogonal quality less than 0.05.

      Maximum Face Skew = 8.78838e-01 (face zone 1)

       

      done.

      Updating mesh to time 4.94700e+03 (step = 00189)...

      Dynamic Mesh Statistics:

      Minimum Volume = 5.44652e-15

      Maximum Volume = 3.02548e-08

      Maximum Cell Skew = 9.76395e-01 (cell zone 3)

      Warning: maximum cell skewness exceeds 0.95.

      Minimum Orthogonal Quality = 2.36051e-02 (cell zone 3)

      Warning: minimum orthogonal quality less than 0.05.

      Maximum Face Skew = 8.78838e-01 (face zone 1)

       

      done.

    • Federico
      Ansys Employee

      Hello, 

      can you try something like this, where you loop over the cells of your deforming zonne?

      Node *node_p  
      begin_c_loop (f, tf)
          {
            c_node_loop (f, tf, n)
              {
                node_p = C_NODE (f, tf, n);
                if (NODE_POS_NEED_UPDATE (node_p))
                  {
                    NODE_POS_UPDATED (node_p);
                    xold = NODE_X (node_p);                        
                    xnew = xold+delta_x;
                    NODE_X (node_p) = xnew;
                  }
              }
          }
        end_c_loop (f, tf);
       
      where NODE_POS_NEED_UPDATE(node_p) is ensures that the position gets updated only than once for any given time step (if running in parallel). 
      Also, use CURRENT_TIME instead of time to access flow_time variable.
      Note that we can only provide limited support for customization. Hence, the above is only a general suggestion and we cannot guarantee that it will work as intended for your application.
Viewing 1 reply thread
  • The topic ‘Error with Mesh Deformation’ is closed to new replies.