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

How to avoid running macro for every cell and use it once per time step?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 20, 2016, 10:52
Default How to avoid running macro for every cell and use it once per time step?
  #1
R J
New Member
 
Andrei
Join Date: Sep 2016
Posts: 1
Rep Power: 0
R J is on a distinguished road
Hello!

I am trying to solve following problem.
The DEFINE_SOURCE macro is used to add source term to a volume. This term is constant through whole volume and only varies in time.
The source term is calculated by a different function (F2) every time step based on the other model parameters.

The problem I encounter is if I save the source term as a real number in F2, then DEFINE_SOURCE macro calls the F2 for every cell within a single time step, thus significantly affecting computational time.

My question is whether there is a way to define the source term in the F2, so it is called only once by DEFINE_SOURCE macro or maybe there is a different way to make it happen only once within a single time step?

I really hope I was clear with my explanations and solution is somewhere there. Thanks to all reading and answering
R J is offline   Reply With Quote

Old   September 20, 2016, 11:07
Default
  #2
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13
Bruno Machado is on a distinguished road
The source term is read every iteration by Fluent, different than DEFINE_EXECUTE_AT_END, which is read at the end of each iteration if steady state or at the end of each time step if transient.

Not sure this solves your problem, but is something worth trying. In a DEFINE_EXECUTE_AT_END macro, create a UDM and define it as F2. In your source term, define the source = UDM you created, so in that case, the calculation will be done only once (at the end of each time step). When you initialize, do not forget to initialize this UDM as the value of the source for the first time step.
Bruno Machado is offline   Reply With Quote

Old   September 21, 2016, 06:33
Default
  #3
New Member
 
Andrei
Join Date: Sep 2016
Posts: 1
Rep Power: 0
Royal_J is on a distinguished road
Thank you a lot.
That is exactly what I was thinking of!

Still I get an error when compile the UDF that for this UDM void cannot be converted to real, while in the UDF manual that is what they are doing

Will keep on investigating.
Thank you for the valuable advice once again!
Royal_J is offline   Reply With Quote

Old   September 21, 2016, 07:03
Default
  #4
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13
Bruno Machado is on a distinguished road
Quote:
Originally Posted by Royal_J View Post
Thank you a lot.
That is exactly what I was thinking of!

Still I get an error when compile the UDF that for this UDM void cannot be converted to real, while in the UDF manual that is what they are doing

Will keep on investigating.
Thank you for the valuable advice once again!
why UDM void? can you shre the piece of code you are trying to implement so I can have a look at it?
Bruno Machado is offline   Reply With Quote

Reply


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



All times are GMT -4. The time now is 22:29.