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

accessing a variable from the previous iteration (NOT TIMESTEP)

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

Reply
 
LinkBack Thread Tools Display Modes
Old   March 28, 2013, 03:02
Default 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: 5
aditya.pandare is on a distinguished road
I want to access the pressure from the previous iteration. What is the Macro for that?

I googled it and found only this link: Previous time step variable to be used in UDF

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!
aditya.pandare is offline   Reply With Quote

Old   March 28, 2013, 11:22
Post
  #2
akm
New Member
 
Join Date: Jan 2010
Location: United Kingdom
Posts: 27
Rep Power: 7
akm is on a distinguished road
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).
akm is offline   Reply With Quote

Old   April 1, 2013, 00:01
Default
  #3
New Member
 
Aditya Pandare
Join Date: Aug 2012
Location: Pune, India
Posts: 20
Rep Power: 5
aditya.pandare is on a distinguished road
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.
aditya.pandare is offline   Reply With Quote

Old   April 1, 2013, 05:32
Default
  #4
New Member
 
Aditya Pandare
Join Date: Aug 2012
Location: Pune, India
Posts: 20
Rep Power: 5
aditya.pandare is on a distinguished road
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.
aditya.pandare is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
No layers in a small gap bobburnquist OpenFOAM Native Meshers: snappyHexMesh and Others 6 August 26, 2015 09: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 04:36


All times are GMT -4. The time now is 14:50.