Getting more out of system/controlDict
With OpenFOAM-1.6, the functions
entry in system/controlDict changed
from being a primitive entry to a dictionary entry. Even although the old
format is still supported, the added flexibility of the dictionary entry
means that you probably should be using the new form.
Previously
If you wanted to somehow centralized the values, for example, for an easier setup, you’d have a problem.
Now
Using dictionary entries, you can harness the #include
dictionary
directive combined with the "~OpenFOAM/"
expansion for much easier
configuration:
where the files are found under the usual expansion hierarchy and can thus
be defined on a per-user basis or for the entire site. We also added in some
default steadyState
settings while we were at it.
In this example we also took advantage of the dictionary merge functionality
to first include the function1
, and then subsequently merge in some custom
values into it.
If we also remember about the little-used #remove
dictionary directive, we
can even write something like this:
which can be included like this:
to remove particular elements again.
In addition to the extra flexibility, the new dictionary form is internally slightly more efficient too.
The #remove directive currently does not actually work as I suggested, since the remove action is restricted to the current dictionary scope and thus does not affect other dictionary contents when merged. For example,
dict { foo xxx; bar yyy; } dict { baz zzz; #remove foo }This only removes 'foo' from the current scope (the second dict), since it occurs before the dictionary merge does.