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 for limiting values of UDS (https://www.cfd-online.com/Forums/fluent-udf/98601-define_adjust-limiting-values-uds.html)

tsagaro March 14, 2012 12:26

DEFINE_ADJUST for limiting values of UDS
 
Hi everybody,

I am simulating a system that includes a user defined scalar that is bounded (it cannot be higher than 1). Therefore, I have written the following DEFINE_ADJUST code, compiled (built and loaded) and hooked. No error is given. However, it does not work (the result is the same as with no DEFINE_ADJUST source code). I am using Fluent 13.0.
I would appreciate your help.



#include "udf.h"
DEFINE_ADJUST(limit_UDS,d)
{
Thread *t;
cell_t c;
{
begin_c_loop_c(t,d)
if(C_UDSI(c,t,0)>1.)
C_UDSI(c,t,0)=1.
end_c_loop(c,t)
}
}

gearboy March 14, 2012 22:08

Quote:

Originally Posted by tsagaro (Post 349467)
Hi everybody,

I am simulating a system that includes a user defined scalar that is bounded (it cannot be higher than 1). Therefore, I have written the following DEFINE_ADJUST code, compiled (built and loaded) and hooked. No error is given. However, it does not work (the result is the same as with no DEFINE_ADJUST source code). I am using Fluent 13.0.
I would appreciate your help.



#include "udf.h"
DEFINE_ADJUST(limit_UDS,d)
{
Thread *t;
cell_t c;
{
begin_c_loop_c(t,d)
if(C_UDSI(c,t,0)>1.)
C_UDSI(c,t,0)=1.
end_c_loop(c,t)
}
}

It's dangerous to do so. Because during the iteration, Fluent will give the UDS value. In your adjust function, you force the UDS value to your value. And In Fluent's iteration period, Fluent set UDS to its value. What will be the ultimate value?

Therefore, forcing a UDS value in adjust function only should be used to rule temporary value which is unreasonable, like upper temperature limit 5000K in Fluent. You can't alway force the UDS to your value during the whole iteration. I mean you should force UDS value only when the value is out of reasonable range.

tsagaro March 15, 2012 03:27

How to limit the value of a UDS (like temperature)
 
So, is there any way to limit the value of a UDS like temperature in the "limits" option in the "run calculation" dialog box?

gearboy March 15, 2012 19:29

Quote:

Originally Posted by gearboy (Post 349513)
It's dangerous to do so. Because during the iteration, Fluent will give the UDS value. In your adjust function, you force the UDS value to your value. And In Fluent's iteration period, Fluent set UDS to its value. What will be the ultimate value?

Therefore, forcing a UDS value in adjust function only should be used to rule temporary value which is unreasonable, like upper temperature limit 5000K in Fluent. You can't alway force the UDS to your value during the whole iteration. I mean you should force UDS value only when the value is out of reasonable range.

I think you should read more about the UDF Manual. Here is the example.

#include "udf.h"
DEFINE_ADJUST(limit_UDS,d)
{
Thread *t;
cell_t c;
thread_loop_c(t, d) /*loops over all cell threads in domain*/
{
begin_c_loop(c, t) /* loops over cells in a cell thread */
{
if(C_UDSI(c,t,0)>1.)
{
C_UDSI(c,t,0)=1.
}
}
end_c_loop(c, t)
}
}

tsagaro March 16, 2012 09:09

I am sorry but I forgot to write the

thread_loop_c(t, d)

line in my first message. So, my define_adjust is equal to yours but simply does not work.

In any case, thank you for your replies.

gearboy March 18, 2012 06:13

Quote:

Originally Posted by tsagaro (Post 349852)
I am sorry but I forgot to write the

thread_loop_c(t, d)

line in my first message. So, my define_adjust is equal to yours but simply does not work.

In any case, thank you for your replies.

You can try using DEFINE_EXECUTE_AT_END. I think it will work.

pablo August 20, 2012 20:30

Have the same problem.
Did you find some solution?
Do not why hooking define_adjust doesn't work.
I appreciate whatever clue to solve this...

best regards

tsagaro August 24, 2012 05:35

No, I did not find the solution.

antonk67 August 27, 2012 07:58

Maybe it is not too straightforward, but consider the following:
1) If the scheme for transport equation is monotonous, the solution should be within limits set by boundary conditions, if we disregard the source term.
2) Accordingly, it is much better to formulate the source term in such a manner that it will preserve the solution within the necessary limits (or decrease the iteration parameter/time step).
3) If you adjust the solution, it will go out of limits upon the next iteration in a most unpleasant manner anyway due to (2).

Just take a look at http://www.cfd-online.com/Forums/flu...ds-values.html


All times are GMT -4. The time now is 12:35.