
[Sponsors] 
Extracting flow variables inside domain in UDF 

LinkBack  Thread Tools  Search this Thread  Display Modes 
October 26, 2019, 02:40 
Extracting flow variables inside domain in UDF

#1 
Member
Abhinand
Join Date: Jun 2016
Posts: 74
Rep Power: 6 
Hello all,
I have a question. I am doing a simulation of a turbulent boundary layer on a flat plate. I want to extract values from a specific location from the inlet and do some calculations and feed it back to the flow. I tried getting the values from the outlet, since its easy to get the thread id of the outlet Can you please suggest some ways to get the same flow parameters at a specific location from the inlet which is not the outlet Boundary? My domain is 100x70mm (2D rectangular domain) at x =0 inlet at x= 100 outlet I can get thread id using lookup_thread command of these since they are boundaries of the domain How do I get the thread id for a location at x=45mm? Thank you all 

November 12, 2019, 19:29 

#2 
Member
Joshua
Join Date: Aug 2014
Posts: 49
Rep Power: 8 
You can use a named expression + a cut plane to achieve this without needing to use a UDF (if you have v19).
There is no specific 'thread' for any generic location in the domain. 

November 12, 2019, 23:57 

#3 
Member
Abhinand
Join Date: Jun 2016
Posts: 74
Rep Power: 6 
I don't need it just for once. I need those values for every iteration and I am updating the solver variables based on the value inside the domain.
Hence I need a way to access it using a UDF only Please let me know if you have any ideas 

November 13, 2019, 00:07 

#4  
Member
Joshua
Join Date: Aug 2014
Posts: 49
Rep Power: 8 
Quote:
Even if you used a UDF, you would need to slice the geometry so you had a face thread to pull, or interpolate to the nearest cell center. 

November 13, 2019, 00:13 

#5  
Member
Abhinand
Join Date: Jun 2016
Posts: 74
Rep Power: 6 
Quote:
This is my process 1. Iterate the solution (1 time) 2. Extract flow qts and turbulence Qties at a particular location 3. Do some calculations with those values from that location inside the domain. 4. From my calculation, find a new value of values for variables in the boundary conditions and hook it to the inlet 5. Solve for one iteration 6. Loop 15 steps for a particular no of iterations 

November 13, 2019, 00:17 

#6 
Member
Joshua
Join Date: Aug 2014
Posts: 49
Rep Power: 8 
So you can split the geometry at your x location so you have two rectangles, name it 'interiorxloc' and use a named expression to evaluate your equation using the field variables as inputs and then assign that as BC to the inlet.
You'll have to be careful how you initialize the flow though. 

November 13, 2019, 00:20 

#7  
Member
Abhinand
Join Date: Jun 2016
Posts: 74
Rep Power: 6 
Quote:
However I have also done a case where I split the domain before hand to have a location interiorxloc, so that I can get a value of it's thread readily from fluent and I can access its values through UDF just like the outlet or inlet. But I faced the same problem, as when I asked to print the value of any variable except for it's coordinate, fluent throws an error like SIGSEV.... Fluent could not be started Details on the code and error is in this link Access Flow variables at an arbitrary location using UDF 

November 13, 2019, 00:57 

#8 
Member
Joshua
Join Date: Aug 2014
Posts: 49
Rep Power: 8 
SIGSEV means you tried to access some piece of data in your UDF that either isn't available, not defined, or you didn't pass enough to the UDF.
For the named expression test case I did the following: 1. Built a rectangular domain. 2. Split it into two separate halves (mirror symmetry about y axis). 3. Split the shared center edge in the middle into three sections. 4. Named the top section interior1, then interior2 for the middle, interior3 for the bottom 1/3rd of the shared edge. 5. Inserted two named expressions. 6. The first named expression summed the values of TKE on interior2. 7. The second named expression uses an IF condition that outputs a value of 3.0625 kg/s if the number of iterations<5, or the sum of TKE * (density * 1 [ms] ) as the value. I chose a random function to compute and assign, but it updates the mass flow at it the inlet accordingly. The use of the IF condition allows for the initialization to work. Named Expressions need units to match which is why I had to multiply the sum of TKE*density by 1 [m s] to kg/s. bcs_1.PNG bcs2.PNG expression1.PNG expression2.PNG mass_flow_bc.PNG 

November 20, 2019, 15:42 

#9 
Member
Abhinand
Join Date: Jun 2016
Posts: 74
Rep Power: 6 
Just to give back to the community that this problem is solved.
Thanks to this link retrieve, access flow variables on interior boundary 

Tags 
define macro, macros, thread id, udf code 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
mass flow in is not equal to mass flow out  saii  CFX  12  March 19, 2018 06:21 
Closed Domain Buoyancy Flow Problem  Madhatter92  CFX  6  June 20, 2016 22:05 
Monte Carlo Simulation: HEnergy is not convergating & high Incident Radiation  volleyHC  CFX  5  April 3, 2016 06:41 
[DesignModeler] Flow Domain of DesignModeler  swiss_zhang  ANSYS Meshing & Geometry  0  June 9, 2011 08:13 
UDF for extracting vorticity of flow  Endee  FLUENT  0  September 14, 2005 14:48 