|
[Sponsors] |
accessing a variable from the previous iteration (NOT TIMESTEP) |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 28, 2013, 03:02 |
accessing a variable from the previous iteration (NOT TIMESTEP)
|
#1 |
New Member
Aditya Pandare
Join Date: Aug 2012
Location: Pune, India
Posts: 20
Rep Power: 14 |
I want to access the pressure from the previous iteration. What is the Macro for that?
I googled it and found only this link: http://www.cfd-online.com/Forums/flu...-used-udf.html But this is to access the variable in the previous timestep (transient) since my solution is steady, I want to access pressure from the previous iteration. Please help! |
|
March 28, 2013, 11:22 |
|
#2 |
New Member
Join Date: Jan 2010
Location: Netherlands
Posts: 28
Rep Power: 16 |
The thread which you have linked (using 2 UDMs) can be applied to your problem as well..
Since you want the pressure field, you only need 1 UDM.. You only need to assign the UDM value as the pressure at previous step. Now 'previous timestep' or 'previous iteration' is simply a choice of macro. If your simulation was transient, DEFINE_EXECUTE_AT_END would run at the end of each time-step, but for steady simulation it runs at the end of each iteration.. However, if your setup is transient, and you still need the value at previous iteration, you can use the macro DEFINE_ADJUST, which runs at the beginning of each iteration (before the transport eqns are solved). |
|
April 1, 2013, 01:01 |
|
#3 |
New Member
Aditya Pandare
Join Date: Aug 2012
Location: Pune, India
Posts: 20
Rep Power: 14 |
Hello!
Thank you for your reply! according to your instructions, I have written the following code: DEFINE_EXECUTE_AT_END(pprev) { cell_t*c; Thread *mixture_thread; Domain *domain; int zoneid = 10; domain = Get_Domain(1); mixture_thread = Lookup_Thread(domain,zoneid); C_UDMI(c,t,0) = source; } Gives a parse error at the "cell_t c line". (Instead of storing the pressure in the UDM, I am storing the "source" from a previous UDF and underrelaxing it.) I think the DEFINE_EXECUTE_AT_END doesnt take cell-thread and domain as input argument. So how should I store the source value at every cell so that I can use it from one variable (as in a "for" loop in the underrelaxation UDF)? Thanks again for your reply. |
|
April 1, 2013, 06:32 |
|
#4 |
New Member
Aditya Pandare
Join Date: Aug 2012
Location: Pune, India
Posts: 20
Rep Power: 14 |
Got it to work in the following way:
DEFINE_EXECUTE_AT_END(pprev) { real prsr, alpha, pv; Thread *mixture_thread; Thread *vap_thread; Domain *domain; Domain *vdomain; int zoneid = 10; cell_t c; domain = Get_Domain(1); vdomain = Get_Domain(3); mixture_thread = Lookup_Thread(domain,zoneid); vap_thread = Lookup_Thread(vdomain,zoneid); pv = -97000; thread_loop_c(vap_thread,vdomain) { begin_c_loop(c,vap_thread) { ...... } end_c_loop(c,vap_thread) } thread_loop_c(mixture_thread,domain) { begin_c_loop(c,mixture_thread) { ...... } end_c_loop(c,mixture_thread) } } thank you @akm. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[snappyHexMesh] No layers in a small gap | bobburnquist | OpenFOAM Meshing & Mesh Conversion | 6 | August 26, 2015 10:38 |
Accessing previous time step temperature in UDF | Sam Bennett | FLUENT | 0 | February 27, 2006 11:46 |
GETVAR SUBROUTINE for additional variable in CFX | Tuks | Main CFD Forum | 0 | November 8, 2005 07:13 |
Accessing Variables from Previous Timestep | Vinayak Barve | FLUENT | 1 | March 10, 2004 08:40 |
Heat exchanger problem | chiseung | FLUENT | 16 | October 20, 2001 05:36 |