CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Extracting flow variables inside domain in UDF (https://www.cfd-online.com/Forums/fluent-udf/221704-extracting-flow-variables-inside-domain-udf.html)

Abhinand October 26, 2019 01:40

Extracting flow variables inside domain in UDF
 
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

jbo214 November 12, 2019 18:29

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.

Abhinand November 12, 2019 22:57

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

jbo214 November 12, 2019 23:07

Quote:

Originally Posted by Abhinand (Post 749608)
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.

Abhinand November 12, 2019 23:13

Quote:

Originally Posted by jbo214 (Post 749611)
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

jbo214 November 12, 2019 23:17

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.

Abhinand November 12, 2019 23:20

Quote:

Originally Posted by jbo214 (Post 749613)
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
https://www.cfd-online.com/Forums/sh...d.php?t=222085

jbo214 November 12, 2019 23:57

5 Attachment(s)
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.

Attachment 73262

Attachment 73263

Attachment 73264

Attachment 73265

Attachment 73266

Abhinand November 20, 2019 14:42

Just to give back to the community that this problem is solved.
Thanks to this link
https://www.cfd-online.com/Forums/sh...d.php?t=112095


All times are GMT -4. The time now is 16:10.