CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Efficient usage of multiple DEFINE_SOURCE (https://www.cfd-online.com/Forums/fluent-udf/236958-efficient-usage-multiple-define_source.html)

jhz June 23, 2021 18:43

Efficient usage of multiple DEFINE_SOURCE
 
Hello,

Currently, I'm using the DEFINE_SOURCE macro for both x and y momentum source terms, but the computation is duplicated across the macros. The logic is to use DEFINE_SOURCE to loop through cells, calculate values based on cell variables, and then conditionally impose an x/y momentum source term. In one instance of DEFINE_SOURCE, the values for both x/y momentum is already solved for, but two separate instances are still needed when hooking the macro, leading to duplicated computations.

Can anyone suggest a more efficient implementation that doesn't require the duplication of DEFINE_SOURCE? I thought about using arrays/UDMs to store the source terms so that in the 1st DEFINE_SOURCE, x/y terms are calculated and stored with x imposed, and in the 2nd DEFINE_SOURCE look up the y terms based on some cell identifier and impose. However, I think lookup operations don't scale well with number of cells. Any advice is appreciated!

AlexanderZ June 24, 2021 01:15

show the code you are using


All times are GMT -4. The time now is 04:21.