Commit Graph

4 Commits

Author SHA1 Message Date
6c8732df5b dictionary: Set the default scoping syntax to 'slash'
The new optional 'slash' scoping syntax is now the default and provides a more
intuitive and flexible syntax than the previous 'dot' syntax, corresponding to
the common directory/file access syntax used in UNIX, providing support for
reading entries from other dictionary files.

In the 'slash' syntax
    '/' is the scope operator
    '../' is the parent dictionary scope operator
    '!' is the top-level dictionary scope operator

Examples:

    internalField 3.4;

    active
    {
        type            fixedValue;
        value.air       $internalField;
    }

    inactive
    {
        type            anotherFixedValue;

        value           $../active/value.air;
        anotherValue    $!active/value.air;

        sub
        {
            value           $../../active/value.air;
            anotherValue    $!active/value.air;
        }
    }

    "U.*"
    {
        solver GAMG;
    }

    e.air
    {
        $U.air;
    }

    external
    {
        value $testSlashDict2!active/value.air;
    }

    active2
    {
        $testSlashDict2!active;
    }

If there is a part of the keyword before the '!' then this is taken to be the
file name of the dictionary from which the entry will be looked-up using the
part of the keyword after the '!'.  For example given a file testSlashDict containing

    internalField 5.6;

    active
    {
        type            fixedValue;
        value.air       $internalField;
    }

entries from it can be read directly from another file, e.g.

    external
    {
        value $testSlashDict2!active/value.air;
    }

    active2
    {
        $testSlashDict2!active;
    }

    which expands to

    external
    {
        value           5.6;
    }

    active2
    {
        type            fixedValue;
        value.air       5.6;
    }

These examples are provided in applications/test/dictionary.

The the default syntax can be changed from 'slash' to 'dot' in etc/controlDict
to revert to the previous behaviour:

OptimisationSwitches
{
.
.
.
    // Default dictionary scoping syntax
    inputSyntax slash;  // Change to dot for previous behaviour
}

or within a specific dictionary by adding the entry

See applications/test/dictionary/testDotDict.
2020-07-23 20:36:51 +01:00
163324d837 foamDictionary: Added support for the new dictionary "slash" syntax
Maintains backward compatibility with the current "dot" syntax.
2019-07-11 19:43:40 +01:00
cd910ed6b8 dictionary::inputSyntaxEntry: Completed support for specifying the default syntax in etc/controlDict 2019-07-11 00:16:30 +01:00
a7b8425690 dictionary: Added experimental "slash" syntax
A new optional "slash" scoping syntax is now provided which is more intuitive
than the current "dot" syntax as it corresponds to the common directory/file
access syntax used in UNIX, and avoids limitations of the "dot" (see below)
e.g.

internalField 3.4;

active
{
    type            fixedValue;
    value.air       $internalField;
}

inactive
{
    type            anotherFixedValue;

    value           $../active/value.air;
    anotherValue    $:active/value.air;

    sub
    {
        value           $../../active/value.air;
        anotherValue    $:active/value.air;
    }
}

"U.*"
{
    solver GAMG;
}

e.air
{
    // This does expand
    $U.air;
}

"#inputSyntax slash;" selects the new "slash" syntax.
"../" refers to the parent directory.
":" refers to the top-level directory.

The corresponding dictionary using the current "dot" syntax is

internalField 3.4;

active
{
    type            fixedValue;
    value.air       $internalField;
}

inactive
{
    type            anotherFixedValue;

    value           $..active.value.air;
    anotherValue    $:active.value.air;

    sub
    {
        value           $...active.value.air;
        anotherValue    $:active.value.air;
    }
}

"U.*"
{
    solver GAMG;
}

e.air
{
    // This doesn't expand
    $U.air;
}

Note that the "$U.air" expansion does not work in this case due to the
interference between the use of '.' for scoping and phase-name.
This is a fundamental problem which prompted the development of the new more
intuitive and flexible "slash" syntax.

The new syntax also allows a for planned future development to access entries
in directories in other files, e.g.

active
{
    type            fixedValue;
    value.air       $FOAM_CASE/internalFieldValues/value.air;
}

or

active
{
    type            fixedValue;
    value.air       :../internalFieldValues/value.air;
}
2019-07-09 16:45:07 +01:00