Function1: Made Table and Constant readable in multiple formats

A typical Function1 entry can be read in one of three ways; with the
parameters in the current dictionary, in a separate sub-dict, or with
the entry itself as the dictionary; e.g.,

    // Current-dictionary form
    <entryName>     sine;
    amplitude       0.1;
    frequency       10;
    level           0.2;

    // Coeff-dictionary form
    <entryName>     sine;
    <entryName>Coeffs
    {
        amplitude       0.1;
        frequency       10;
        level           0.2;
    }

    // Entry-as-dictionary form
    <entryName>
    {
        type            sine;
        amplitude       0.1;
        frequency       10;
        level           0.2;
    }

The latter two sub-dictionary forms are needed when there are multiple
Function1 entries of the same type in a dictionary. Enclosing the
parameters in a separate sub-dictionary prevents the keywords (in this
case "amplitude", "frequency" and "level") from being duplicated.

Table and constant Function1 entries are different in that they have
special formats which allow the data to be appended directly to the
entry name; e.g;

    <entryName>         table ((0 (1 0 0)) (1 (2 0 0)));

    <entryName>         constant (1 0 0);

    // (constant can even have the "constant" keyword omitted)
    <entryName>         (1 0 0);

Table also has two optional additional controls; "outOfBounds" and
"interpolationScheme". In order for these to be written out in such a
way that the entries are not duplicated, table needs to be written out
(and therefore also read in) as one of the sub-dictionary forms. To that
effect, Table has been extended to additionally permit reading in the
three forms described previously, and to write in the coeff-dictionary
form.

    // Current-dictionary form
    <entryName>     table;
    values          ((0 (1 0 0)) (1 (2 0 0)));
    outOfBounds     repeat;
    interpolationScheme linear;

    // Coeff-dictionary form
    <entryName>     sine;
    <entryName>Coeffs
    {
        values          ((0 (1 0 0)) (1 (2 0 0)));
        outOfBounds     repeat;
        interpolationScheme linear;
    }

    // Entry-as-dictionary form
    <entryName>
    {
        type            table;
        values          ((0 (1 0 0)) (1 (2 0 0)));
        outOfBounds     repeat;
        interpolationScheme linear;
    }

For completeness and consistency, constant has also been modified so
that it can read in these forms. However, constant has no additional
control entries, which means writing a coeff-dictionary is unecessary,
so the output has not been changed.
This commit is contained in:
Will Bainbridge
2019-11-14 16:50:02 +00:00
parent e286cf4ef9
commit 0d9786651b
6 changed files with 48 additions and 35 deletions

View File

@ -96,8 +96,8 @@ public:
// Member Functions
//- Write all table data in dictionary format
virtual void writeData(Ostream& os) const;
//- Write entries only in dictionary format
virtual void writeEntries(Ostream& os) const;
// Member Operators