In the last post of this series the general structure of a dictionary was introduced. We will now see the basic structure of entries. The first point to make is that entries in OpenFOAM® dictionaries can be of several types but they all follow the key/value format, at least in a broad sense.
The generic format of an entry is:
key is an identifier and
value can have different forms. Technically speaking a subdictionary is also an entry, but it was implemented differently in terms of formatting, so I will leave that out in this description.
One of the most common forms of entries are what I will call coefficients. Coefficients can be dimensioned or not, depending on how the implementation was carried out in the code. The simplest form is the following:
In case a coefficient has a dimension, then its format becomes:
nu [0 2 -1 0 0 0 0] 0.01;
In older versions of OpenFOAM® the format used to be:
nu nu [0 2 -1 0 0 0 0] 0.01;
In short, the dimensionSet and the numerical value constitute the actual value on the key/value pair of the dictionary. Note that the value is not necessarily a scalar. It can be a vector:
locationInMesh (0 0 1);
or, in the dimensioned case:
U [0 1 -1 0 0 0 0] (0 1 0);
Lists can be used as values in the key/value pair of dictionaries (common in fields initialized with non-uniform values):
internalField nonuniform List<vector>
300 // Number of elements
(0 1 1) // Elements
(0 1 2)
Note that lists may or may not require the number of elements before the list content start, depending on the corresponding type used in C++ code
Another type of entry is what in OpenFOAM® is identified as
word (do not confuse this term with the word numerical type of programming languages: word in OpenFOAM® is essentially a single-word string!). Several examples of this type of entry were shown in the previous post
In an entry of this type, a single word is the value of the key/value pair.
More complex versions of this type of entry, where the value is a string rather than a single word are also possible. For example, when specifying numerical schemes, entries like the following are encountered:
div(phi,U) Gauss limitedLinearV 1;
The format of these entries depends on the context where they are used, consequently it is pointless to try to extract general rules, since they would be ad-hoc to the specific context.
OpenFOAM implements the bool type calling it
Switch, to allow for different input options from
true/false. For example,
on/off are allowed. The syntax of the corresponding entry is however unaffected:
This is a brief summary of the most commonly encountered types of entries found in dictionaries.
Enjoy and stay tuned! 🙂
This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks. Alberto Passalacqua is not associated to OpenCFD Ltd.