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

Previous time step variable to be used in UDF

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

Like Tree10Likes
  • 1 Post By Amir
  • 4 Post By Amir
  • 1 Post By shashank312
  • 4 Post By pakk

Reply
 
LinkBack Thread Tools Display Modes
Old   July 18, 2012, 08:48
Default Previous time step variable to be used in UDF
  #1
New Member
 
CFD-user
Join Date: Jul 2012
Posts: 5
Rep Power: 6
CFD-user is on a distinguished road
Hi,

I am writing an UDF, in which I would like to use the previous time step data. Although, in FLUENT we can access previous time step data for many variables with '_M1', I would need user defined variables previous timestep rather than the standard variables.

For e.g. m(t+dt) = m(t) + ...............

so to solve the above equation for the new time step I will be needing m(t) i.e., previous time step data.

I have been keep on trying this from last few days, but could not crack.

It will be appreciated, if you can throw some light on it.

Regards...
CFD-user is offline   Reply With Quote

Old   July 18, 2012, 12:19
Default
  #2
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 739
Blog Entries: 1
Rep Power: 15
Amir is on a distinguished road
Hi,

Why didn't use other UDM for this purpose?
sbaffini likes this.
__________________
Amir
Amir is offline   Reply With Quote

Old   July 19, 2012, 08:51
Default
  #3
New Member
 
CFD-user
Join Date: Jul 2012
Posts: 5
Rep Power: 6
CFD-user is on a distinguished road
Quote:
Originally Posted by Amir View Post
Hi,

Why didn't use other UDM for this purpose?

Hi,

Thank you for your reply.

I tried earlier with UDMIs also and did not work. But, I think even UDMIs also store the current time step data only. I will try once again & see.

Regards
CFD-user is offline   Reply With Quote

Old   July 19, 2012, 12:00
Default
  #4
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 739
Blog Entries: 1
Rep Power: 15
Amir is on a distinguished road
Quote:
Originally Posted by CFD-user View Post
Hi,

Thank you for your reply.

I tried earlier with UDMIs also and did not work. But, I think even UDMIs also store the current time step data only. I will try once again & see.

Regards
It depends how you use and update such memories in order to refer to desired time step.

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   July 19, 2012, 16:28
Default
  #5
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 573
Blog Entries: 14
Rep Power: 18
sbaffini will become famous soon enough
What Amir meant to say is that you can save your current time variable in some UDMI and the older one in another UDMI and basically keep updating them as the time passes. In this case you will never need the old time values as you will always reference current time variables
sbaffini is offline   Reply With Quote

Old   July 20, 2012, 00:57
Default
  #6
New Member
 
CFD-user
Join Date: Jul 2012
Posts: 5
Rep Power: 6
CFD-user is on a distinguished road
Quote:
Originally Posted by Amir View Post
It depends how you use and update such memories in order to refer to desired time step.

Bests,
Can you please give some example in terms of UDMIs?
CFD-user is offline   Reply With Quote

Old   July 20, 2012, 00:58
Default
  #7
New Member
 
CFD-user
Join Date: Jul 2012
Posts: 5
Rep Power: 6
CFD-user is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
What Amir meant to say is that you can save your current time variable in some UDMI and the older one in another UDMI and basically keep updating them as the time passes. In this case you will never need the old time values as you will always reference current time variables
Can you please give some example in terms of UDMIs? Now I will trying with fprintf and fscan options from the file.
CFD-user is offline   Reply With Quote

Old   July 20, 2012, 02:47
Default
  #8
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 739
Blog Entries: 1
Rep Power: 15
Amir is on a distinguished road
Quote:
Originally Posted by CFD-user View Post
Can you please give some example in terms of UDMIs?
Consider for example 2 UDMs at first: UDM0, UDM1 and initialize them.
Then in your desired define-macro which does a process in each time step you have e.g.:
DEFINE_X(.....)
{
C_UDMI(...,1)=f(....)+C_UDMI(...,0); //here UDM0 refers to previous time step
.
.
.
// At last you have:
C_UDMI(...,0)=C_UDMI(...,1); // prepare UDM0 for the next time step

}

Just note to provide these commands each time steps not each iteration; i.e., if your macro executes each iteration, you need to use a if-clause to restrict the commands for each time step.

Bests,
macfly, ghost82, virgy and 1 others like this.
__________________
Amir
Amir is offline   Reply With Quote

Old   July 24, 2012, 03:56
Default
  #9
New Member
 
CFD-user
Join Date: Jul 2012
Posts: 5
Rep Power: 6
CFD-user is on a distinguished road
Quote:
Originally Posted by Amir View Post
Consider for example 2 UDMs at first: UDM0, UDM1 and initialize them.
Then in your desired define-macro which does a process in each time step you have e.g.:
DEFINE_X(.....)
{
C_UDMI(...,1)=f(....)+C_UDMI(...,0); //here UDM0 refers to previous time step
.
.
.
// At last you have:
C_UDMI(...,0)=C_UDMI(...,1); // prepare UDM0 for the next time step

}

Just note to provide these commands each time steps not each iteration; i.e., if your macro executes each iteration, you need to use a if-clause to restrict the commands for each time step.

Bests,
Thanks for your reply.
I have following doubts:
1. For the first time step what would be the value of C_UDMI(...,0)
2. Suppose even if you include it in 'if-else loop' i.e., say for the first time step I will initialise C_UDMI(...,0) in 'if' loop. And subsequently I would use this in else loop. I think I have tried this without inlcuding the if loop for each time step and did not work. I would try for each time-step instead of each iteration and come to you.

Thank you again.
CFD-user is offline   Reply With Quote

Old   July 24, 2012, 05:50
Default
  #10
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 739
Blog Entries: 1
Rep Power: 15
Amir is on a distinguished road
Quote:
Originally Posted by CFD-user View Post
1. For the first time step what would be the value of C_UDMI(...,0)
The UDM0 value would be the initial value for desire variable. (you can set it appropriately via initialize->patch or via other pre-used UDF)
Quote:
Originally Posted by CFD-user View Post
2. Suppose even if you include it in 'if-else loop' i.e., say for the first time step I will initialise C_UDMI(...,0) in 'if' loop. And subsequently I would use this in else loop. I think I have tried this without inlcuding the if loop for each time step and did not work. I would try for each time-step instead of each iteration and come to you.
It should work if executed at each time step not each iteration.

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   May 23, 2013, 18:06
Default
  #11
Member
 
Shashank
Join Date: Apr 2011
Posts: 70
Rep Power: 7
shashank312 is on a distinguished road
Since Fluent does not handle the coupling of the VOF equation and the UDS equation properly and since the source term in the VOF equation is treated implicitly for volume fraction but explicitly for the UDS variable in question, I need to use "some" variables (suppose I store them in a UDM) from the previous time step. How can I do that? I think I am asking how should I loop w.r.t time?
shashank312 is offline   Reply With Quote

Old   May 24, 2013, 16:37
Default
  #12
Member
 
Shashank
Join Date: Apr 2011
Posts: 70
Rep Power: 7
shashank312 is on a distinguished road
Amir, how and where would you use the if-clause to restrict the commands to each time step?
Baden likes this.
shashank312 is offline   Reply With Quote

Old   May 29, 2014, 03:33
Default
  #13
Member
 
Join Date: Oct 2013
Posts: 33
Rep Power: 4
Светлана is on a distinguished road
same question - how to access a variable value from previous time step - no answer in this thread
Светлана is offline   Reply With Quote

Old   May 29, 2014, 04:07
Default
  #14
Senior Member
 
Join Date: Nov 2013
Posts: 919
Rep Power: 12
pakk will become famous soon enough
Quote:
Originally Posted by Светлана View Post
same question - how to access a variable value from previous time step - no answer in this thread
Very clear answer in this thread! Store that variable in a UDM, and then access the UDM in the next time step!
sbaffini, macfly, ghost82 and 1 others like this.
pakk is offline   Reply With Quote

Old   October 18, 2015, 05:34
Default
  #15
Member
 
PranjalNewton's Avatar
 
Pranjal Singh
Join Date: Sep 2015
Posts: 34
Rep Power: 3
PranjalNewton is on a distinguished road
Quote:
Originally Posted by Amir View Post
Just note to provide these commands each time steps not each iteration; i.e., if your macro executes each iteration, you need to use a if-clause to restrict the commands for each time step.
How is this ensured? i.e. the if-clause?
PranjalNewton 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
Multiple floating objects CKH OpenFOAM Running, Solving & CFD 12 March 21, 2016 14:05
Problems with simulating TurbFOAM barath.ezhilan OpenFOAM 13 July 16, 2009 05:55
Modeling in micron scale using icoFoam m9819348 OpenFOAM Running, Solving & CFD 7 October 27, 2007 00:36
Transient simulation not converging skabilan OpenFOAM Running, Solving & CFD 12 September 17, 2007 17:48
Accessing previous time step temperature in UDF Sam Bennett FLUENT 0 February 27, 2006 11:46


All times are GMT -4. The time now is 17:11.