Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Need help in 6dof udf with a face loop

    • Burhan Ibrar
      Subscriber

      Hello Dear,

      I hope this thread will find you well.

      I am doing a very simple test where i use 6dof udf but in that udf i want to get the velocity from the actual results. The main problem is complex but i receive the same error as shown below. I just want to have some results in my udf through looping or some other way which i do not know. I also wrote the UDF here below for reference. The thing is that when i do not use a loop then it works fine but i need to have a loop to get the velocity or some other variable from the results.

      I hope you understand the problem and give me feedback asap with your experience. Thank you.


      UDF:

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

      SDOF property compiled UDF with external forces/moments

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

      #include "udf.h"

      static real acc = 4.631;

      static real mass = 5;

      static real velocity;





      DEFINE_SDOF_PROPERTIES(acce, prop, dt, time, dtime)

      {



      prop[SDOF_MASS] =5;

      prop[SDOF_IXX] = 5.2e-5;

      prop[SDOF_IYY] = 4.1667e-3;

      prop[SDOF_IZZ] = 1;

      prop[SDOF_ZERO_TRANS_X] = False;/* boolean, allow translation in x-direction */

      prop[SDOF_ZERO_TRANS_Y] = True; /* boolean, suppress translation in y-direction */

      prop[SDOF_ZERO_TRANS_Z] = True; /* boolean, suppress translation in z-direction */

      prop[SDOF_ZERO_ROT_X] = True; /* boolean, suppress rotation around x-axis */

      prop[SDOF_ZERO_ROT_Y] = True; /* boolean, suppress rotation around y-axis */

      prop[SDOF_ZERO_ROT_Z] = True; /* boolean, allow rotation around z-axis */



      {

      if(time >= 0) {

      Thread *f_thread;

      face_t f;

      velocity=0;

      begin_f_loop(f, f_thread)

      {

      velocity += F_U(f, f_thread);

      }

      end_f_loop(f, f_thread)


      Message(" V1 %d /n",velocity);


      prop[SDOF_LOAD_F_X] = mass*acc;


      }


      }


      }



      Error:

      "V1 0 /n

      =========================


      ==============

      ================================================== ================================================== ============


      Node 5: Process 20896: Receiv============================================ ==============

      ========================================


      Node 1: Proc=================ess 20948: Received signal ====================SIGSEGV.


      ================================================== ============================================

      =========================================



      =============================Node 3: Process 20648: Received si=ed signal gn======================SIGSEGV.


      ================================================== =al SI========G===============================

      S==EG====V.

      =======


      No======

      ============


      Node 0: Prde 2: Process 17612: Received sig=====================o========================= ========================================

      ============ncess 1936: Received signal Sal SIGSEGV.


      =========================IGSEGV.


      ================================================== ================================================== ========


      Node 4: ===========Process 10852: Rece======ived signal SIGSEGV.===



      ================================================== =======================

      ==================


      999999: mpt_accept: error: accept failed: No such file or directory"

    • Surya Deb
      Ansys Employee
      Hello,
      You f_thread seems undefined. You need to fetch the f_thread. You can use Lookup_Thread macro. check here [https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v211/en/flu_udf/flu_udf_sec_special_macros.html?q=lookup%20thread].
      Also check your logic regarding the summation of the velocity.
      Regards SD

    • Burhan Ibrar
      Subscriber
      Hello sdeb thank you so much for your reply and it helped me a lot. But i have a problem where i am using overset model and now what i did that i define the motion on walls and for overset fluid domain i defined relative motion and UDF with only properties e.e mass, rotation and translation. Is this the right way to do it because when i define the same udf with motion on both then i get errors.
      2nd thing is that i have attached the code below when i used my calculation for (#if !RP_HOST) and solving it parallel but in results i have variable output 6 times and every variable has a different value. If you can help me to get the one value which should be equal to the one we can see in dynamic mesh window. What i understood from manual that all variable values which i see in console are from different nodes and now i want to let them communicate so get the right value which i do not know yet.
      And for writing a file with variables like time and velocity should i also use #if !RP_HOST or #if RP_NODE, etc.?
      your help will really appreciated. thank you.

      /*******************************************************
      SDOF property compiled UDF with external forces/moments
      *******************************************************/
      #include "udf.h"

      static real acc = 4.631;
      static real mass = 5;
      static real velocity, vel, area_tot, area[3];
      DEFINE_SDOF_PROPERTIES(acce, prop, dt, time, dtime)
      {


      prop[SDOF_MASS] =5;
      prop[SDOF_IXX] = 8.333e-4;
      prop[SDOF_IYY] = 4.1667e-3;
      prop[SDOF_IZZ] = 5.2e-5;
      prop[SDOF_ZERO_TRANS_X] = False;/* boolean, allow translation in x-direction */
      prop[SDOF_ZERO_TRANS_Y] = True; /* boolean, suppress translation in y-direction */
      prop[SDOF_ZERO_TRANS_Z] = True; /* boolean, suppress translation in z-direction */
      prop[SDOF_ZERO_ROT_X] = True; /* boolean, suppress rotation around x-axis */
      prop[SDOF_ZERO_ROT_Y] = True; /* boolean, suppress rotation around y-axis */
      prop[SDOF_ZERO_ROT_Z] = False; /* boolean, allow rotation around z-axis */
      {
      #if !RP_HOST
      Thread *t;
      face_t f;
      Domain *domain;
      int nid;
      domain = THREAD_DOMAIN (DT_THREAD (dt));
      nid = THREAD_ID (DT_THREAD (dt));
      t = Lookup_Thread (domain, nid);

      velocity=0.0;
      area_tot=0;
      #endif

      #if !RP_HOST
      begin_f_loop(f, t)
      if (PRINCIPAL_FACE_P(f, t))
      {
      F_AREA(area,f,t);
      area_tot += NV_MAG(area);
      velocity += F_U(f, t)*NV_MAG(area);
      }
      end_f_loop(f, t)



      /*area_tot=PRF_GRSUM1(noface);
      velocity=PRF_GRSUM1(velocity);*/
      #if RP_NODE
      vel = velocity/area_tot;

      Message("\nV1 %f Area Total %f /n",vel, area_tot);
      #endif

      #endif

    • Burhan Ibrar
      Subscriber

      hello sdeb Please read above. I forgot to quote your message.
    • Burhan Ibrar
      Subscriber

      The results are as follows. Initially the variable V1 has 6 different values but after some time only one has a value and other has ind value which i do not understand. And in later stages the value is equal to the one in dynamic mesh. I need to have only one accurate value which you can see in 2nd results which i can use further in my program for comparison. First results
      V1 0.004384 Area Total 0.001615 /n done.
      Updating mesh at time level N...
      V1 0.004380 Area Total 0.009207 /n
      V1 0.004389 Area Total 0.004913 /n
      V1 0.004389 Area Total 0.005528 /n
      V1 0.004385 Area Total 0.001727 /n
      V1 0.004380 Area Total 0.000947 /ndone.

      2nd Results
      V1 -nan(ind) Area Total 0.000000 /n done.
      Updating mesh at time level N...
      V1 -nan(ind) Area Total 0.000000 /n
      V1 0.030577 Area Total 0.023936 /n
      V1 -nan(ind) Area Total 0.000000 /n
      V1 -nan(ind) Area Total 0.000000 /n
      V1 -nan(ind) Area Total 0.000000 /ndone.
    • Surya Deb
      Ansys Employee
      Hello,
      It is not possible to check your entire UDF. But I think you might be missing commands to transfer from node to host after global summing.
      Check this link for a parallel UDF example. [https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v212/en/flu_udf/flu_udf_sec_parallel_example.html?q=parallel]

      Regards SD
    • Burhan Ibrar
      Subscriber
      Thank you Sdeb,
      Issue is resolved.
Viewing 6 reply threads
  • The topic ‘Need help in 6dof udf with a face loop’ is closed to new replies.
[bingo_chatbox]