|
[Sponsors] |
August 13, 2020, 10:42 |
Change UDS Inlet Typ with UDF possible?
|
#1 |
Member
|
Hello,
does anyone know if it is even possible to change the UDS Inlet Typ from "UDS Value" to "UDS Flux" by using an UDF? My problem is, I have an oscillating flow. So my Inlet becomes the Outlet and the other way arround. With my UDS I want to have at the UDS-Outlet always a gradient = 0. That is equal to UDS Flux = 0. At the Inlet I want to have always a specified "UDS Value" (to adress the relativ humidity) So when my velocity changes from positiv to negativ my UDS-Inlet becomes my UDS-Outlet and I need to define a UDS Flux=0 instead a certain value. I hope my problem is undestandable. PS: Or is there any other possibility instead of stopping by hand the Simulation and switching the UDS_boundary_types? Last edited by schwaral; August 13, 2020 at 14:05. |
|
August 14, 2020, 01:21 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
you can change type of Boundary Condition from UDF,
but it is possible with scheme + TUI commands if I were you, I would make: 1 flag variable in scheme 2 Read it in fluent 3 Apply value to flag (depends on your criteria) 4 Get value of flag in scheme 5 Change/not change boundary condition
__________________
best regards ****************************** press LIKE if this message was helpful |
|
August 26, 2020, 11:52 |
|
#3 |
Member
|
I think I figured out something but I don't understand, why this scheme if statement is now not working. Like you can see my variable (veldirect) that I want to use for changing the BC is printed and calculated correctly. But scheme seems not to use this variable correct. It thinks it is always 0.
reversed flow in 20 faces on pressure-outlet 11. 900 7.1974e-03 4.2344e-05 2.3118e-06 1.3848e-16 1.0680e-05 0:00:00 1 veldirect: 1 reversed flow in 20 faces on pressure-outlet 11. 901 5.9673e-03 4.3454e-05 2.0997e-06 1.3159e-16 6.8316e-06 0:00:00 0 (ti-read-journal "testjournal.jou") Reading journal file testjournal.jou... > (cond ((= (%rpgetvar 'veldirect) 1) (ti-menu-load-string "define/boundary-conditions/velocity-inlet/9 yes yes yes yes udf velinlet::libudf no 0 no 1 no 0 no 300 yes no 0") ) ((= (%rpgetvar 'veldirect) 0) (ti-menu-load-string "define/boundary-conditions/velocity-inlet/9 yes yes yes yes udf velinlet::libudf no 0 no 1 no 0 no 300 no yes no 0.8") ) ) define/boundary-conditions/velocity-inlet/9(inlet) yes yes yes yes udf velinlet::libudf no 0 no 1 no 0 no 300 no yes no 0.8#t #f I have tried diffrent ways to use if statement in scheme but it is always the same result. It thinks veldirect = 0. Why does this happen :/ The only thing I can see is weird is that veldirct is not calculated for the last iteration. I calculate it with a DEFINE_ADJUST UDF Last edited by schwaral; August 27, 2020 at 11:58. |
|
August 27, 2020, 11:57 |
|
#4 |
Member
|
when I use (rpgetvar 'var_name) to check the Value it shows me 0. So I think I have to use the UDF in a diffrent way, that calculates veldirect.
DO you have any Idea how can I set the value so my journal gets the actual calculated value and not somehow a 0? My UDF is DEFINE_ADJUST(adjust_UDS_bc, d) { int zone_ID = 9; Thread* t = Lookup_Thread(d, zone_ID); if (fnew >= 0) { RP_Set_Integer("veldirect", 0); } else { RP_Set_Integer("veldirect", 1); } } |
|
August 30, 2020, 20:59 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
try this code
Code:
(if (= (%rpgetvar 'veldirect) 1) (ti-menu-load-string "define/boundary-conditions/velocity-inlet/9 yes yes yes yes udf velinlet::libudf no 0 no 1 no 0 no 300 yes no 0") (ti-menu-load-string "define/boundary-conditions/velocity-inlet/9 yes yes yes yes udf velinlet::libudf no 0 no 1 no 0 no 300 no yes no 0.8") ) (ti-menu-load-string "define boundary-conditions velocity-inlet 9 () yes yes yes yes udf velinlet::libudf no 0 no 1 no 0 no 300 no yes no 0.8#t #f ") DEFINE_EXECUTE_AT_END is macro which is executed after iteration if you've defined somehow criteria for condition yor udf will looks something like this Code:
**** calculated fnew here **** node_to_host_int_1(count); /*transfer data to host, put it inside inside macro | if you are using v19.0 or above*/ DEFINE_ADJUST(adjust_UDS_bc, d) { #if !RP_NODE /*execute on host or in serial */ if (fnew >= 0) { RP_Set_Integer("veldirect", 0); } else { RP_Set_Integer("veldirect", 1); } #endif }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
August 31, 2020, 08:48 |
|
#6 | |
Member
|
Thanks for the response. My UDF looked like that except these two lines down below. I added them now and my UDF is identical with yours.
Quote:
I noticed some significant preformance reduction that I think is because of using parallel on 0 nodes. When I switch to serial the change of BC does not work anymore. Do you have any ideas for that? Last edited by schwaral; August 31, 2020 at 13:39. |
||
September 9, 2020, 14:44 |
|
#7 | |
Member
|
Quote:
When I start in parallel my variavle fnew is computet correctly but this adjust_udf ist printing the wrong value. 0 instead 1. In serial mode is everything fine. I tried already different versions and without #if !RP_NODE. So the result in parallel is at the moment, that the BC are not switching at all. Last edited by schwaral; September 10, 2020 at 09:34. |
||
September 16, 2020, 10:10 |
|
#8 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
try to add line
Code:
node_to_host_int_1(fnew )
__________________
best regards ****************************** press LIKE if this message was helpful |
|
September 17, 2020, 09:47 |
|
#9 |
Member
|
I added this line and changed it to node_to_host_double_1(fnew ) because my fnew is of the typ double.
Unfortunatelly now my BC are all the time the same and not switching. My rpvar is now always = 1. Fnew seems to be calculated correctly. Do I need to prepare the UDF in which fnew is calculated for parallel usage further more? Or is it a problem that I have define fnew globally? If it helps, in the File below is my Code for calculating fnew. It is basically a simple Fourier Trafo. |
|
Tags |
boudary condition, fluen, flux, udf, uds |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
2D rotating detonation simulation - UDF inlet BC | Tianxu | FLUENT | 10 | July 27, 2020 03:28 |
UDF Velocity profile at inlet | aar007 | Fluent UDF and Scheme Programming | 1 | June 28, 2020 23:43 |
2-D phase change heat transfer UDF | arunraj | FLUENT | 1 | May 25, 2020 13:21 |
UDF profile: Fluent method for coupling inlet and outlet | I-mech | Fluent UDF and Scheme Programming | 0 | May 10, 2014 11:36 |
please, would anyone help me with this UDF, inlet temperature change with time | Juun | Fluent UDF and Scheme Programming | 2 | March 18, 2014 11:03 |