|
[Sponsors] |
Passing variables between DEFINE_ON_DEMAND macros |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 3, 2023, 21:17 |
Passing variables between DEFINE_ON_DEMAND macros
|
#1 |
Member
BM
Join Date: Sep 2021
Posts: 35
Rep Power: 5 |
I have two define_on_demand macros called "run1" and "run2".
"run1" spits out an array x. "run2" uses x, as well as a parameter y obtained from Get_Input_Parameter, to spit out another output z, so z = z(x,y). I am trying to build a workflow that does something like this: 1. Call "run1" to get x. 2. Set a value of y, call "run2" to get z, save results. 3. Repeat previous step for different values of y. The reason I do not want to combine "run1" and "run2" into a single define_on_demand macro is because I only need to execute "run1" once. If I combine it into a single macro with "run2", then "run1" would execute every single time with "run2", which is unnecessary and potentially time-consuming. Is there a way to do this? I have considered using scheme variables, but there is no option to define an array using a scheme variable. |
|
April 9, 2023, 10:33 |
|
#2 |
Member
Odisha
Join Date: Jan 2020
Posts: 59
Rep Power: 6 |
Hi. You say that you need to execute "run1" only once. This means that while the parameter 'y' will attain different values, the array will be treated as a constant. So why don't you add that array as an input variable in your second UDF (run2). And then execute only "run2" for as many times as you want.
This will save you from having to write any scheme scripts. |
|
April 10, 2023, 01:21 |
|
#3 | |
Member
BM
Join Date: Sep 2021
Posts: 35
Rep Power: 5 |
Quote:
|
||
April 10, 2023, 03:14 |
|
#4 |
Member
Odisha
Join Date: Jan 2020
Posts: 59
Rep Power: 6 |
Hi. Maybe I'm misunderstanding. What is this "x" array exactly? Like, is it an array storing the coordinates of all mesh cells or something like that?
As you might be knowing, DEFINE_ON_DEMAND doesn't execute every iteration as it is outside the solver loop. So whatever value this "run1" is spitting out, it must be independent of the iteration number. So, you can execute "run1" once, get the array "x", and hardcode it into "run2". (UNLESS of course 'x' is something that's going to change on the fly.) |
|
April 10, 2023, 05:25 |
|
#5 | |
Member
BM
Join Date: Sep 2021
Posts: 35
Rep Power: 5 |
Quote:
|
||
Tags |
scheme, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Passing variables to a codedBC | tladd | OpenFOAM Programming & Development | 2 | May 30, 2021 15:51 |
[swak4Foam] How to define boundary condition variables by using previosly defined variables? | pawlo | OpenFOAM Community Contributions | 8 | September 13, 2020 12:37 |
Optimal tolerance and variables scaling settings | 4513645ygq | Main CFD Forum | 0 | July 28, 2020 09:56 |
Some variables not loading in Tecplot | nick.l.thomas | Tecplot | 1 | October 25, 2018 18:48 |
Passing fortran variables to C in mixed programmin | Quarkz | Main CFD Forum | 1 | January 9, 2008 07:17 |