CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Extracting flow variables inside domain in UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 26, 2019, 02:40
Smile Extracting flow variables inside domain in UDF
  #1
Member
 
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 10
Abhinand is on a distinguished road
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
Abhinand is offline   Reply With Quote

Old   November 12, 2019, 19:29
Default
  #2
Member
 
Joshua
Join Date: Aug 2014
Posts: 49
Rep Power: 12
jbo214 is on a distinguished road
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.
jbo214 is offline   Reply With Quote

Old   November 12, 2019, 23:57
Default
  #3
Member
 
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 10
Abhinand is on a distinguished road
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
Abhinand is offline   Reply With Quote

Old   November 13, 2019, 00:07
Default
  #4
Member
 
Joshua
Join Date: Aug 2014
Posts: 49
Rep Power: 12
jbo214 is on a distinguished road
Quote:
Originally Posted by Abhinand View Post
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
You can do that with an expression. What are you trying to measure, where, and what operations are you trying to do that quantity?

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.
jbo214 is offline   Reply With Quote

Old   November 13, 2019, 00:13
Default
  #5
Member
 
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 10
Abhinand is on a distinguished road
Quote:
Originally Posted by jbo214 View Post
You can do that with an expression. What are you trying to measure, where, and what operations are you trying to do that quantity?

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.
Hi,

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 1-5 steps for a particular no of iterations
Abhinand is offline   Reply With Quote

Old   November 13, 2019, 00:17
Default
  #6
Member
 
Joshua
Join Date: Aug 2014
Posts: 49
Rep Power: 12
jbo214 is on a distinguished road
So you can split the geometry at your x location so you have two rectangles, name it 'interior-x-loc' 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.
jbo214 is offline   Reply With Quote

Old   November 13, 2019, 00:20
Default
  #7
Member
 
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 10
Abhinand is on a distinguished road
Quote:
Originally Posted by jbo214 View Post
So you can split the geometry at your x location so you have two rectangles, name it 'interior-x-loc' 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.
Can you explain this more clearly. I don't understand.
However I have also done a case where I split the domain before hand to have a location interior-x-loc, 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
Abhinand is offline   Reply With Quote

Old   November 13, 2019, 00:57
Default
  #8
Member
 
Joshua
Join Date: Aug 2014
Posts: 49
Rep Power: 12
jbo214 is on a distinguished road
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 interior-1, then interior-2 for the middle, interior-3 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 interior-2.
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 [m-s] ) 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
jbo214 is offline   Reply With Quote

Old   November 20, 2019, 15:42
Default
  #9
Member
 
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 10
Abhinand is on a distinguished road
Just to give back to the community that this problem is solved.
Thanks to this link
retrieve, access flow variables on interior boundary
Abhinand is offline   Reply With Quote

Reply

Tags
define macro, macros, thread id, udf code


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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: H-Energy 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


All times are GMT -4. The time now is 13:46.