https://linen.dev logo
is there any clean way to grab a value from a file...
# programming
o
is there any clean way to grab a value from a file in dictionaries? for example, defining Ux=10 in a 'variables file' and then in the U file use something like:
value uniform (foamFind(Ux,filePath) 0 0)
? should I simply sed the thing directly using bash? I am having a lot of trouble with this, not that i can am not able of doing my simulation, but i can not find a 'clean' way to do it, and then the hole folder with all the simulations in a parametric study that i re runned several times becomes really hard to find 'what i changed'/'what this simulation was for'. currently my workflow is: 1. master bash script where i loop over a list of a variable 2. master script copies base case folder and seds the variable to change in respective file (such as 0.orig/U) 3. runs the ./Allrun of the copied case folder. i did in the past also: 1. master bash script where i loop over a list of a variable 2. master script copies base case folder and seds the variable to change in a variables.sh file inside the copied case folder 3. runs the ./Allrun which itself reads the variables.sh file and changes respectibly the desired file, (such as 0.orig/U) and then runs the simulation the second i would say is a little bit 'cleaner' but by any means clean. the first makes more complex the master script, where the second the Allrun i would like (if exist, but doubt since i never saw it used in foam files) do something in the middle, where the files would 'look for' on the variables.sh file and have a default value. or other people around do it in a different way? it gets convoluted quite fast and would like to clean my workflow. maybe using python? i dont know... just curious what others do here