|
[Sponsors] |
January 9, 2012, 10:19 |
User Defined Memory
|
#1 |
New Member
Gomatam Sreekar
Join Date: Jul 2011
Posts: 12
Rep Power: 15 |
I use a nonlinear k-e model and the Reynolds Stress is stored in the User defined memory. Is it possible to clear that user defined memory after a set number of iterations while running the case??
|
|
January 14, 2012, 17:31 |
|
#2 |
Senior Member
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16 |
Sure. Is it a transient case or a steady-state case? The define_adjust macro will run once per iteration, and thus you'd need to simply hook your reset macro (with appropriate logic) into define_adjust.
I haven't tried the code below, but it should give you an idea of what to do. Code:
#include "udf.h" int IterCounter=1; DEFINE_ADJUST(adjust_fcn,d) { Thread *t; cell_t c; /*reset if iterations > 2000 */ if(IterCounter>2000) { IterCounter=0; thread_loop_c(t,d) { if (FLUID_THREAD_P(t)) { begin_c_loop_all(c,t) { for (i = 0; i < n_udm; i++) { /*This loops over all UDM locations and resets them to 0.*/ /* Implement your own values or logic here*/ C_UDMI(c, t, i) = 0.0; } } end_c_loop_all(c,t) } } } IterCounter=IterCounter+1; } |
|
January 17, 2012, 03:46 |
|
#3 |
New Member
Gomatam Sreekar
Join Date: Jul 2011
Posts: 12
Rep Power: 15 |
Thanks for the code. It's a transient code. Will it make any difference if it's a steady case? If so, how?
|
|
January 17, 2012, 10:10 |
|
#4 |
Senior Member
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16 |
I asked because doing something based on iterations in a transient code doesn't make a lot of sense (while they're correlated with flow time, it's not a fixed relationship, and you'd be resetting at random intervals). By iterations, do you mean time step?
ComputerGuy |
|
January 17, 2012, 10:13 |
|
#5 |
New Member
Gomatam Sreekar
Join Date: Jul 2011
Posts: 12
Rep Power: 15 |
Yes. By iterations I mean the time steps. Is it possible to delete that data at the completion of a case. If I'm running the case for 100seconds, is there someway to delete the user defined memory after 100s from the data file?
|
|
January 17, 2012, 10:19 |
|
#6 |
Senior Member
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16 |
Yes. The simple fix to the code below should clear the UDM after 100 seconds. It's a define on demand to prevent running every iteration for flow times beyond 100s
Code:
#include "udf.h" DEFINE_ON_DEMAND(eraseudm) { Thread *t; Domain *d; cell_t c; real current_time; current_time = CURRENT_TIME; d = Get_Domain(1); if(current_time>100) { IterCounter=0; thread_loop_c(t,d) { if (FLUID_THREAD_P(t)) { begin_c_loop_all(c,t) { for (i = 0; i < n_udm; i++) { /*This loops over all UDM locations and resets them to 0.*/ /* Implement your own values or logic here*/ C_UDMI(c, t, i) = 0.0; } } end_c_loop_all(c,t) } } } } ComputerGuy |
|
May 18, 2012, 18:18 |
|
#7 |
New Member
moon
Join Date: Feb 2012
Posts: 26
Rep Power: 14 |
this is my udf to calculate gradient of temperature dt/dy,it write me error fluent reveice .....()
what's wrong ? #include "udf.h" DEFINE_ON_DEMAND(store_grad) { Domain* d; Thread *t; cell_t c; d=Get_Domain(1); thread_loop_c(t,d) { begin_c_loop(c,t) { C_UDMI(c,t,0)=C_T_G(c,t)[1]; } end_c_loop(c,t) } } thx |
|
May 19, 2012, 05:56 |
|
#8 | |
Senior Member
|
Quote:
Did you patch the UDM before use?
__________________
Amir |
||
Tags |
k-e model, udf, user defined memory |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Trouble setting user scalar and user memory names | tstorm | FLUENT | 6 | November 23, 2022 04:58 |
How can I allocate user defined memory? | MASOUD | Fluent UDF and Scheme Programming | 1 | November 20, 2014 03:12 |
user defined sourcen term | xck1986 | CFX | 1 | July 8, 2010 09:35 |
user defined turbulence model | manuutin | STAR-CD | 5 | October 14, 2009 06:29 |
Gradient of a User defined Variable | Ramadas | CFX | 2 | August 21, 2007 10:19 |