Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Fluent UDS Interchange “Inlet UDS Value” to “Inlet UDS Flux” by using UDF???

    • schwaral
      Subscriber
      Hello, nis it possibble to change the type of UDS Boundary by using a UDF? I have a periodic FLow and when the flow is reversed, I want to have a UDS Flux instead of a UDS Value at the Boundary.Or is there any way to transform a UDS Value into a UDS Flux and the other way around?n
    • DrAmine
      Ansys Employee
      Yes you can use UDF to change the boundary for UDS.nYou require however scheme to change the type of input.nSo you require both.nAlternative is what you are mentioning: perhaps you use single UDF which accommodate your input either into Flux or fixed value (solving a sort of equation).n
    • schwaral
      Subscriber
      Thanks for the reply!nCould you give me some advise on the alternative approach? nI noticed when I use a certain Flux at Inlet and a Flux=0 at Outlet my Scalar Value becomes larger with each timestep. But I don't want this behavior. So I use a UDS Value at Inlet. nif I want to transfer a UDS Value into a Flux without this behavior of a rising Scalar in my domain with each timestep i think I need to consider time effect . But I am not to sure how. Should I store the Values of previous timesteps in the UDM and subtract them or is there a way ti work with time derivative?nI could only find in the userguide that flux is (density*velocity*cellface*Scalar) so basically [kg/s]*Scalar.nI am a little bit confused with the mathematics here :/
    • Rob
      Forum Moderator
      Remember scalars don't have a material so don't have a density, otherwise they're modelled in exactly the same way. n
    • schwaral
      Subscriber
      I will try this as again. In the meantime I worked on the approach with TUI and UDF.nI followed this thread:/forum/discussion/7062/changing-boundary-condition/p1nIt seems that it almost works fine. The first timestep works fine but with the start of the 2nd timestep I face this error below. When I initialze the solution again, the error happens already in the first timestep. Do you have any suggestion why this happens? I simply copy and pasted the scheme code into the execute commands line. I hope that is correct. n(condn((=(rpgetvar 'veldirect) 0)n(ti-menu-load-string define/boundary-conditions/velocity-inlet/9 yes yes no 5 no 0 no 1 no 0 no 300 no yes no 0.5)n)n((=(rpgetvar 'veldirect) 1)n(ti-menu-load-string define/boundary-conditions/velocity-inlet/9 yes yes no 5 no 0 no 1 no 0 no 300 yes no 0)n)n)nError:GENERAL-CAR-CDR:invalid argument [1]:improper listnError Object: The hooked UDF:DEFINE_ADJUST(adjust_UDS_bc, d)n{ntint zone_ID = 9;ntThread* t = Lookup_Thread(d, zone_ID);ntint r;ntr = RP_Get_Integer(veldirect);ntif (fnew >= 0)nt{nttRP_Set_Integer(veldirect, 0);nttprintf( veldirect:%d
      , r);nt}ntelsent{nttRP_Set_Integer(veldirect, 1);nttprintf( veldirect:%d
      , r);nt}n}n
    • schwaral
      Subscriber
      Thanks I will try it again. In the meantime I worked on the approach with UDF and TUI. I followed this thread: /forum/discussion/7062/changing-boundary-condition/p1. The first Timestep works fine but with the start of the second timestep I face an error. When I initialize the case again, the error happens rigth away. I simplay copy and pasted the code below into the execute commands line. Do you have any suggestion wheter the problem is because of the code or a diffrent reason? This is the output: nnnThe hooked UDF: nn
    • DrAmine
      Ansys Employee
      You might use %rpgetvar instead of rpgetva (like in /forum/discussion/7062/changing-boundary-condition/p1)n
    • schwaral
      Subscriber
      I had it like this already, checked it now again but the same error appears.nnLike you can see in the output above, the variable r is not printed. When I use the UDF without the execute command, then the value is printed occasionally, but not at every timestep. Maybe this has something to do with that? I compiled my UDF as well and did not interpret it. Hooked it properly as well. Everything in the Internet I can find regarding this error sounds like it is caused because of system compatibility?I also tried now to setup the whole case again but it did not help unfortunally. n
    • DrAmine
      Ansys Employee
      Use Message0 instead of printing. That is a buffer issue.n
    • schwaral
      Subscriber
      great now it is printing every timestep but the error is obviously still existentn
    • DrAmine
      Ansys Employee
      Check if the TUI commands to change Boundary condition are working fine by just only executing them.nI would rather rely on Fluent expression if you are just changing the parameter of the same boundary condition and not change its kind.n
    • schwaral
      Subscriber
      Yes they work fine. I am constantly checking if the yes no yes yes yes.... is correct.nThat is exactly the problem, that I want to change the kind of boundary conditions since I am not able to transfer a UDS Value into a UDS Flux without summing up my Scalar with every timestep. nI want: non one side UDS Scalar gradient = 0 --> so I use UDS_Flux = 0. non the other side UDS Value = x (or please tell me how to write the same as UDS Flux).I do not understand how the flux works. Everything I can find in the UserGuide is nFrom what I can see during the calculation with Flux = x at Inlet and Flux =0 at outet, that witch each timestep another x is added. So I end up having infinite number of x in my domain. n
    • schwaral
      Subscriber
      I figured out, that you cannot just copy and paste the scheme code into the line under execute commands. First you have to write your code in one single line and then copy and paste it.The last problem I have now: nhow to write as a string. I think in the TUI, if I want to use an UDF, I have to call it with (nameofmyUDF). But you can't type in questionmarks in scheme. n(cond((=(%rpgetvar 'veldirect) 0)(ti-menu-load-string define/boundary-conditions/velocity-inlet/9 yes yes yes yes udf unsteady_x_velocity_Mund::libudf no 0 no 1 no 0 no yes no 0.8)nnSo the error appears for udf and unsteady_x_velocity_Mund::libudf. Let me know if this is not possible. Because then it would not be possible to select a UDF with scheme?.best regardsn
    • DrAmine
      Ansys Employee
      You might put everything in a journal file and under the execute command you request reading that as journal file.n
    • DrAmine
      Ansys Employee
      Okay the pint is pure Scheme programming. You can escape the via \ like innn(ti-menu-load-string /define/user-defined/compiled-functions load \libudfexec\)nnor using format.n
    • schwaral
      Subscriber
      thanks again everything is working. It is only not changing the BC. printing my variable, that is used for the if statement (veldirect) changes from 0 to 1 but the scheme code treats it as 0 all the time.nnthanks for your help n
    • schwaral
      Subscriber
      when i check with (rpgetvar 'var_name) the value is always 0. But my UDF is pretty simple and calculates the value correct. So the UDF is used not rigth before the journal file is adressed. But how can I change that. I tried to call the udf from the journal file but then everything is messed up. Are you sure that the order of my procedure is correct? nn
    • DrAmine
      Ansys Employee
      Which UDF?n
    • schwaral
      Subscriber
      It is the UDF from above. My Workflow: Define RP-Variable --> Set RP Variable with UDF --> USE RP Variable with scheme. I had a closer look and scheme is not using the value that I set with the UDF but always the initialized rp Value from defining the rp variable at the beginning. Somehow this workflow can't be right. UDF itself is working fine. Define RP Variable is working fine. Scheme itself is working fine. When I interrupt the simulation and check by hand rpvalue it is always the initialized value and not the one calculated by the udf. nWhat I noticed as well: When I execute the UDF on demand in the output is written: veldir=1 (that is what my UDF calculates for my rpvar named veldir. When I check with (rpgetvar 'veldir) rigth after that, the value = 0 (that is the initialized value of the rpvar). So the UDF and scheme is somhow not talking about the same variable.nn
    • schwaral
      Subscriber
      Here is the whole Output of one Iteration. You can see vel dir is set to 1. But scheme thinks it is not 1 and uses the else statement. If I would call the UDF_on_demand by hand and check the rpvar by hand it would show me a value of 0. nn
    • schwaral
      Subscriber
      Is this maybe a problem?.** WARNING: Automatically switched to run in parallel -t1 mode. **n** Detected non-parallelized UDF usage, enabling parallel usage. **n** If you encounter any issues, please re-run with -t0 flag. **n****************************************************************************n
    • schwaral
      Subscriber
      If someone has the same problem. I think I solved it by using #if !RP_NODEso the UDF looks like this now: nI am still not sure if I should use the node_to_host_int_1. But it works without it just fine.Something I noticed as well is a huge reduction in performance due to the execute on demmand. Would be interesting to know how to optimise that.nn
    • DrAmine
      Ansys Employee
      Right after executing the on demand to modify the rpvar in the udf can you check the value of that rp variable?n
    • DrAmine
      Ansys Employee
      And one would need to set rp variables at host. All nodes will get that value after one iteration. Actually it should work without any compiler directive for node or host in the recent versions I am using. You can learn here by adding in the messaging %d for myid to check the values on corresponding nodes and hosts.n
Viewing 23 reply threads
  • The topic ‘Fluent UDS Interchange “Inlet UDS Value” to “Inlet UDS Flux” by using UDF???’ is closed to new replies.