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

Change UDS Inlet Typ with UDF possible?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 13, 2020, 10:42
Default Change UDS Inlet Typ with UDF possible?
  #1
Member
 
Deutschland
Join Date: Jun 2020
Location: https://t.me/pump_upp
Posts: 43
Rep Power: 6
schwaral is on a distinguished road
Send a message via ICQ to schwaral Send a message via AIM to schwaral Send a message via Yahoo to schwaral
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.
schwaral is offline   Reply With Quote

Old   August 14, 2020, 01:21
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
schwaral likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   August 26, 2020, 11:52
Default
  #3
Member
 
Deutschland
Join Date: Jun 2020
Location: https://t.me/pump_upp
Posts: 43
Rep Power: 6
schwaral is on a distinguished road
Send a message via ICQ to schwaral Send a message via AIM to schwaral Send a message via Yahoo to schwaral
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.
schwaral is offline   Reply With Quote

Old   August 27, 2020, 11:57
Default
  #4
Member
 
Deutschland
Join Date: Jun 2020
Location: https://t.me/pump_upp
Posts: 43
Rep Power: 6
schwaral is on a distinguished road
Send a message via ICQ to schwaral Send a message via AIM to schwaral Send a message via Yahoo to schwaral
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);

}
}
schwaral is offline   Reply With Quote

Old   August 30, 2020, 20:59
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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_ADJUST is macro which is executed before iteration (or timestep if transient)
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
AlexanderZ is offline   Reply With Quote

Old   August 31, 2020, 08:48
Default
  #6
Member
 
Deutschland
Join Date: Jun 2020
Location: https://t.me/pump_upp
Posts: 43
Rep Power: 6
schwaral is on a distinguished road
Send a message via ICQ to schwaral Send a message via AIM to schwaral Send a message via Yahoo to schwaral
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:
Originally Posted by AlexanderZ View Post

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*/

#if !RP_NODE /*execute on host or in serial */
#endif
}
Unfortunately I received an error because of the last line in your Scheme. I deleted that and now it works fine. So I think the magic was the correction of my UDF.

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

Old   September 9, 2020, 14:44
Default
  #7
Member
 
Deutschland
Join Date: Jun 2020
Location: https://t.me/pump_upp
Posts: 43
Rep Power: 6
schwaral is on a distinguished road
Send a message via ICQ to schwaral Send a message via AIM to schwaral Send a message via Yahoo to schwaral
Quote:
Originally Posted by AlexanderZ View Post
try this code

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
}
Is there any possibility to make this work in parallel mode on local machine?

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

Old   September 16, 2020, 10:10
Default
  #8
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
try to add line
Code:
node_to_host_int_1(fnew )
after you've calculated it
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   September 17, 2020, 09:47
Default
  #9
Member
 
Deutschland
Join Date: Jun 2020
Location: https://t.me/pump_upp
Posts: 43
Rep Power: 6
schwaral is on a distinguished road
Send a message via ICQ to schwaral Send a message via AIM to schwaral Send a message via Yahoo to schwaral
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.
schwaral is offline   Reply With Quote

Reply

Tags
boudary condition, fluen, flux, udf, uds


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
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


All times are GMT -4. The time now is 21:14.