Volume Fraction Gradient

    • AnthonyB08

      Hi all,

      I need some advice/assistance in evaluating a drift flux, see image below. 

      I am able to extract the velocities and VOF, but I am struggling to extract the gradient of the VOF. I have done some research on this topic and have found the following 

      Source I have read regarding this task : 

      1. https://www.cfd-online.com/Forums/fluent-udf/240253-gradient-volume-fraction-c_vof_g.html
      2. https://forum.ansys.com/forums/topic/fluent-udf-command-c_vof_g-causing-error-crash/
      3. https://www.cfd-online.com/Forums/fluent-udf/196046-problems-acces-vof-gradients-source-udf.html
      4. https://www.cfd-online.com/Forums/fluent-udf/218643-how-get-data-mass-fraction-udf-2.html

      Based on my research, prior to resorting to this forum, I experimented with two methods. The first method was directly taken from a forum post with some editing to fit my simulation while the second method was given to me by a friend who used Ansys back in 2018-2019. 

      Method 1. Use Define Adjust, Define Demand, and UDS to calculate, store, and describe the gradient of VOF


      Method 2. Loop through all cells to extract the gradient after the first iteration. For this method solve/set/expert freed memory was set to yes but it returned a warning that this is not compatible with parallel simulation. So I attempted to re-start fluent with 0 processors in the parallel tab, but it auto-reverted to 1. 


      The first method is returning an error and the second is returning a zero gradient value. I have read the section on gradients and reconstructed gradients in the ANSYS UDF manual, but it was no help in developing the code If I am being honest. 

    • Rob
      Ansys Employee

      The Fluent solver is entirely parallel now, but with 1 core set it's sort of serial. Most of the issues with parallel and UDFs are linked to double counting cells on the partitions rather than causing a failure in the code. 

      There's a note somewhere about retaining data,    /solve/set/advanced/retain-temporary-solver-mem   You may need that for the gradients. 

      • AnthonyB08

        Hi Rob,

        I apologize, I was wrong in saying that the ANSYS UDF manual was no help. I eventually figured out my problem. I will snap shot the code below for other users with similar interests. Also,  /solve/set/advanced/retain-temporary-solver-mem  only works in serial, as this as well gives me a warning saying this is not compatible with parallel simulation. 


        Step 1. Copy and paste ANSY UDF manual code (section 

        Step 2. Enable UDS with UDM of 1 

        Step 3. Turn off the UDS equation in the control 

        Step 4. Extract UDS value and take the gradient of the UDS (see below) 

    • Rob
      Ansys Employee

      Thanks for posting a solution. 

      Just to clarify, the warning re not retaining data in parallel is linked to adapted meshes in parallel. So, if the mesh hasn't been adapted it ought to work. 

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