|
[Sponsors] |
How to avoid running macro for every cell and use it once per time step? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 20, 2016, 10:52 |
How to avoid running macro for every cell and use it once per time step?
|
#1 |
New Member
Andrei
Join Date: Sep 2016
Posts: 1
Rep Power: 0 |
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 |
|
September 20, 2016, 11:07 |
|
#2 |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
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. |
|
September 21, 2016, 06:33 |
|
#3 |
New Member
Andrei
Join Date: Sep 2016
Posts: 1
Rep Power: 0 |
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! |
|
September 21, 2016, 07:03 |
|
#4 | |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
Quote:
|
||
|
|