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

DEFINE_ADJUST for limiting values of UDS

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 14, 2012, 12:26
Default DEFINE_ADJUST for limiting values of UDS
  #1
New Member
 
Toni Pujol
Join Date: Jun 2009
Posts: 6
Rep Power: 16
tsagaro is on a distinguished road
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)
}
}
tsagaro is offline   Reply With Quote

Old   March 14, 2012, 22:08
Default
  #2
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
Quote:
Originally Posted by tsagaro View Post
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.
gearboy is offline   Reply With Quote

Old   March 15, 2012, 03:27
Default How to limit the value of a UDS (like temperature)
  #3
New Member
 
Toni Pujol
Join Date: Jun 2009
Posts: 6
Rep Power: 16
tsagaro is on a distinguished road
So, is there any way to limit the value of a UDS like temperature in the "limits" option in the "run calculation" dialog box?
tsagaro is offline   Reply With Quote

Old   March 15, 2012, 19:29
Default
  #4
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
Quote:
Originally Posted by gearboy View Post
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)
}
}
gearboy is offline   Reply With Quote

Old   March 16, 2012, 09:09
Default
  #5
New Member
 
Toni Pujol
Join Date: Jun 2009
Posts: 6
Rep Power: 16
tsagaro is on a distinguished road
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.
tsagaro is offline   Reply With Quote

Old   March 18, 2012, 06:13
Default
  #6
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
Quote:
Originally Posted by tsagaro View Post
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.
gearboy is offline   Reply With Quote

Old   August 20, 2012, 20:30
Default
  #7
New Member
 
Pablo Cornejo Olivares
Join Date: Mar 2009
Location: Concepción, Chile
Posts: 5
Rep Power: 17
pablo is on a distinguished road
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
pablo is offline   Reply With Quote

Old   August 24, 2012, 05:35
Default
  #8
New Member
 
Toni Pujol
Join Date: Jun 2009
Posts: 6
Rep Power: 16
tsagaro is on a distinguished road
No, I did not find the solution.
tsagaro is offline   Reply With Quote

Old   August 27, 2012, 07:58
Default
  #9
New Member
 
Anton Khokhlov
Join Date: Aug 2012
Location: Moscow
Posts: 4
Rep Power: 13
antonk67 is on a distinguished road
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

Last edited by antonk67; August 28, 2012 at 01:24.
antonk67 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Preventing negative scalar (UDS) values?? Matthew Brannock FLUENT 5 September 1, 2020 12:32
UDS stored to UDM do not show the same values swati_mohanty FLUENT 0 December 3, 2010 03:46
Doubts UDS Flux, UDS Unsteady for VOF model kel85uk FLUENT 0 March 17, 2010 08:53
strange node values @ solid/fluid interface - help JB FLUENT 2 November 1, 2008 12:04
Setting fixed values with UDS Andrew Garrard FLUENT 3 February 2, 2004 10:00


All times are GMT -4. The time now is 19:45.