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

DEFINE_ADJUST to affect DEFINE_PROFILE

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 16, 2023, 03:38
Default DEFINE_ADJUST to affect DEFINE_PROFILE
  #1
New Member
 
Davide Masiello
Join Date: Jul 2022
Location: Switzerland
Posts: 2
Rep Power: 0
davide91 is on a distinguished road
Hi, I have implemented several UDFs in my simulations.
In particular, I have a boundary condition that depends on a parameter which I call FRAC.

Code:
#include "udf.h"

...
...

DEFINE_PROFILE(myBC,th,i)
{
    real FRAC = Get_Input_Parameter("my_parameter");
    begin_f_loop(f,th)
    {
        F_PROFILE(f,th,i) = FRAC*...;
    }
    end_f_loop(f,th);
}

...
...
Initially, I did not know what the value of FRAC would have to be, so I was solving the simulation using direct optimization and optimizing FRAC so that I would get the correct value of a different variable at the system outlet.
Without going too much into detail, this is based on mass balances so it is physically correct.

When seeing the optimized values of FRAC, I realised it depends on another value which can be obtained as an integral of a certain expression over a specific cell thread of my domain.
In order to avoid having to optimize FRAC for each Design Point of my simulation, I'd rather calculate it that way.
On the UDF User Manual, I found this info:

DEFINE_ADJUST is a general-purpose macro that can be used to adjust or modify ANSYS Fluent
variables that are not passed as arguments. For example, you can use DEFINE_ADJUST to modify flow
variables (for example, velocities, pressure) and compute integrals. You can also use it to integrate a
scalar quantity over a domain and adjust a boundary condition based on the result.


The last sentence seems to describe exactly what I need to do.
Therefore, I have modified by code in the following way

Code:
#include "udf.h"

real FRAC;
...
...
DEFINE_ADJUST(my_adjust,d)
{
    Thread *t = Lookup_Thread(d,7);
    real my_integral=0.;
    cell_t c;

    begin_c_loop(c,t)
    {
        my_integral += (UDS dependent expression)*C_VOLUME(c,t);
     }
     end_c_loop(c,t)
     FRAC = my_integral/... ;
}

DEFINE_PROFILE(myBC,th,i)
{
    begin_f_loop(f,th)
    {
        F_PROFILE(f,th,i) = FRAC*...;
    }
    end_f_loop(f,th);
}

...
...
After the modification, the code still runs and converges but it does not yield the same value of FRAC that is obtained via optimization. Therefore, the mass balance I am checking is also not respected.

If anyone as any idea/suggestion of why this happens I'd really appreciate it.

Have a good day.

Davide
davide91 is offline   Reply With Quote

Reply

Tags
boundary condition, define_adjust, define_profile


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
Particles dont affect simulation force_95 FLUENT 0 October 1, 2019 03:53
Aspect ratio - WHY does it affect the solution mörli Main CFD Forum 0 September 4, 2019 08:23
[ICEM] global size factor affect first layer height? ranben10 ANSYS Meshing & Geometry 1 September 20, 2017 03:18
Does <cache{ grad ( U ) }> affect somehow my turbulence fimbull OpenFOAM Running, Solving & CFD 0 August 1, 2017 08:20
How does the particles' velocity affect the energy balance equation of gas phase sy2516 OpenFOAM Running, Solving & CFD 0 April 10, 2017 15:05


All times are GMT -4. The time now is 09:41.