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/)
-   -   DEFINE_ADJUST Application (https://www.cfd-online.com/Forums/fluent-udf/173103-define_adjust-application.html)

Student_GF June 13, 2016 11:35

DEFINE_ADJUST Application
 
Hi All,

I am confused on the DEFINE_ADJUST macro as there is not much in the UDF manual. Would it be possible to alter material properties (e.g. diffusivity) via DEFINE_ADJUST? In addition, can someone please explain how the DEFINE_ADJUST macro works?

Thanks all!

Bruno Machado June 14, 2016 04:02

Quote:

Originally Posted by Student_GF (Post 604671)
Hi All,

I am confused on the DEFINE_ADJUST macro as there is not much in the UDF manual. Would it be possible to alter material properties (e.g. diffusivity) via DEFINE_ADJUST? In addition, can someone please explain how the DEFINE_ADJUST macro works?

Thanks all!

DEFINE_ADJUST macro solves everything you put inside it for each iteration. You can add functions to your code and call for these inside the DEFINE_ADJUST. The diffusivity has its one macro. You can use it to alter/define the diffusivity for each iteration.

Student_GF June 14, 2016 08:51

Hi Bruno,

Thank you for the reply. Can elaborate when you say "add functions to your code and call for these inside the DEFINE_ADJUST"? Do you mean I could call on the DEFINE_ADJUST code from a DEFINE_DIFFUSIVITY code? I am asking because I am not exactly sure how DEFINE_ADJUST works as I am not sure how it can alter values in specific fields such as boundary conditions.

Thank you for the help! Much appreciated.

Bruno Machado June 14, 2016 09:02

Quote:

Originally Posted by Student_GF (Post 604814)
Hi Bruno,

Thank you for the reply. Can elaborate when you say "add functions to your code and call for these inside the DEFINE_ADJUST"? Do you mean I could call on the DEFINE_ADJUST code from a DEFINE_DIFFUSIVITY code? I am asking because I am not exactly sure how DEFINE_ADJUST works as I am not sure how it can alter values in specific fields such as boundary conditions.

Thank you for the help! Much appreciated.

define adjust does not alter values in boundary conditions. there is a specific macros for it.

You can have different functions in your code, eg

real function1(c,t)
{ . . . }

real function2(c,t)
{ . . . }

real function3(c,t)
{ . . . }

In your define adjust, you can call these functions and it will be computed each iteration

DEFINE_ADJUST(whatever,d)
{
Thread *t;
cell_t c;
real variable;
thread_loop_c (t,d)
{
begin_c_loop (c,t)
C_UDMI(c,t,0) = function1(c,t) + function2(c,t) + function3(c,t);
end_c_loop (c,t)
}
}

In this piece of code, you have 3 distinct functions and in your define adjust, you are defining an UDM as the sum of the three. This is one example, but you can apply many other purposes at it. You can also call the functions you define in the DEFINE_DIFFUSIVITY. Again, thousands of examples on internet.

Student_GF June 14, 2016 09:20

Hi Bruno,

Thank you for the help. I believe I am understanding what you are saying. Can you elaborate on if the the following is possible via the DEFINE_ADJUST macro?

I would like to alter kinetic theory results from diffusivity by a factor (e.g. 1/x^2). Would this be possible via DEFINE_ADJUST or would I have to store the values via UDMI and then somehow recall it via DEFINE_DIFFUSIVITY and something like C_PROFILE?

`e` June 14, 2016 17:53

There are a number of macros available within most hooks such as the x-velocity: C_U(c,t). However, if you alter the velocity, for example by setting it to uniform flow:

Code:

C_U(c,t) = 1.;
C_V(c,t) = 0.;
C_W(c,t) = 0.;

The solver will start with this value at the first iteration but then converge the flow field: losing your uniform flow field (technically, the DEFINE_ADJUST macro is called at the beginning of each iteration; the residuals will either be zero or never converge -- instead, say you only enabled this uniform flow at the beginning of each time step). For your case with defining the diffusivity, this material property can be modified with the DEFINE_DIFFUSIVITY macro. You shouldn't require using the DEFINE_ADJUST macro for modifying the diffusivity; what exactly is your equation you're implementing?

Student_GF June 15, 2016 09:04

Hi e,

thank you for the reply. Here is what I am trying to do. I am trying to implement something to this extent in the diffusivity field

kinetic theory * some multiplicative factor (e.g. 0.5)

I do not want to rewrite the kinetic theory equation in a UDF as it will take a long time so I was wondering if the DEFINE_ADJUST can accomplish this. The problem I am running into is that all DEFINE_ADJUST macro example I can find are storing the values via UDSI or UDMI which will then require a UDF (most likely DEFINE_DIFFUSIVITY macro) to use this value for diffusivity. Doing this will remove the kinetic theory field for diffusivity, thus this process seems like it is invalid.

If this is not possible, please tell me, so I may go along another route.

Thank you so much,
GF

`e` June 16, 2016 07:27

Check if the laminar species (C_DIFF_L) or effective species (C_DIFF_EFF) diffusivity macros return the value you're after.


All times are GMT -4. The time now is 06:30.