Fluids

Fluids

UDF using RP variable for dynamic mesh

    • bv169
      Subscriber

      Hello,

      I found a UDF to calculate pressure on a face to move the mesh (dynamic mesh) based on this. The following is an exerpt from the UDF:

      /* Get the value of the thread ID from a user-defined Scheme variable */
      #if !RP_NODE /* SERIAL or HOST */
       surface_thread_id = RP_Get_Integer("pres_av/thread-id");
       Message("\nCalculating on Thread # %d\n",surface_thread_id);
      #endif /* !RP_NODE */

       /*  To set up this user Scheme variable in cortex type */
       /* (rp-var-define 'pres_av/thread-id 6 'integer #f) */
       /* After set up you can change it to another thread's ID using : */
       /* (rpsetvar 'pres_av/thread-id 6) */

       /* Send the ID value to all the nodes */
       host_to_node_int_1(surface_thread_id); /* Does nothing in serial */

       

      I have set my rp-var using a scheme file to the thread ID of the face I am looking to calculate on. When I run the simulation I only get the output ' Message("\nCalculating on Thread # %d\n",surface_thread_id);' and then error received sigsev. I am guessing after this line the UDF has an error, but I am lost on what to fix next. 

      Here is my scheme file if that helps: 

      (define (make-new-rpvar name default type)
        (if (not (rp-var-object name))
          (rp-var-define name default type #f)))


      (rp-var-define 'pres_av/thread-id 6 'integer #f)

      (rpsetvar 'pres_av/thread-id 6)

       

      Thanks,
      Breanna 

    • Rob
      Ansys Employee

      Looking at https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v231/en/flu_udf/flu_udf_DataAccessMacros.html  and   https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v231/en/flu_udf/flu_udf_sec_user_defined_scheme_var.html   do you need that, or do you need the pressure on a surface to then do something? 

      The dynamic mesh example (reed valve) video might be useful?  https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/prod_page.html?pn=Fluent&pid=Fluent&lang=en&prodver=23.1

    • bv169
      Subscriber

      My udf calculates the average pressure on the face and then moves the face (Dynamic mesh) according to this pressure. I was using a serial UDF that was moving the mesh but it was calculating pressure wrong since it needed to be parallelized. I now am working with this parallelized UDF but the scheme variable is giving me issues. I tried to not use it and use a data access macro instead but still received errors. 

    • Rob
      Ansys Employee

      If you know the surface ID that might be a better approach, that should replace the scheme?  Otherwise, you've been running in parallel (architecture) as the true serial solver was removed a few versions back. 

    • bv169
      Subscriber

      Thanks. The UDF was working without error before trying to parallelize it. If its true that its running in parallel originally (without adding if !RP_NODE and !RP_HOST), then I can go back. The previous issue with that one was that it was outputting lots of pressure and force values in the console message, which made me think it needed to be parallelized since I was specifying a calculation of only the average pressure on the face, yet was receiving many outputs for one time step. 

    • Rob
      Ansys Employee

      The RP_HOST & RP_NODE are important as you increase the number of nodes, with default of one node it's less critical. 

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