Commit Graph

83 Commits

Author SHA1 Message Date
Andrew Heather
538d749220 REL: Updated headers to version v2006 2020-06-29 17:27:54 +01:00
Andrew Heather
ae2ab06312 REL: Release preparations 2019-12-23 09:49:23 +00:00
Mark Olesen
1cf795a40f ENH: use exprString expansions for #eval
- follows the principle of least surprise if the expansion behaviour
  for #eval and expressions (eg, exprFixedValue) are the same.  This
  is possible now that we harness the regular stringOps::expand()
  within exprString::expand()
2019-12-17 09:47:51 +01:00
Mark Olesen
c2123452b1 ENH: generalize string expression evaluation
- replace stringOps::toScalar with a more generic stringOps::evaluate
  method that handles scalars, vectors etc.

- improve #eval to handle various mathematical operations.
  Previously only handled scalars. Now produce vectors, tensors etc
  for the entries. These tokens are streamed directly into the entry.
2019-12-09 19:44:23 +01:00
Mark Olesen
9e6683f7bc ENH: add conditionals to #eval (string to scalar)
Example,

     ($radius > 10) ? sin(degToRad(45)) : cos(degToRad(30))

- protect division and modulo against zero-divide.

- add scanner/parser debugging switches in the namespace,
  selectable as "stringToScalar". For example,

    debug parser:  foamDictionary -debug-switch stringToScalar=2
    debug scanner: foamDictionary -debug-switch stringToScalar=4
    debug both:    foamDictionary -debug-switch stringToScalar=6
2019-11-19 14:22:03 +01:00
Andrew Heather
fdf8d10ab4 Merge commit 'e9219558d7' into develop-v1906 2019-12-05 11:47:19 +00:00
OpenFOAM bot
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
Mark Olesen
177f4b79fe ENH: use direct scanning mode when lexing #eval expressions 2019-11-01 19:13:50 +01:00
Mark Olesen
6b5492e3bd ENH: code simplification, improvements for reading dictionary variables
- Now accept '/' when reading variables without requiring
  a surrounding '{}'

- fix some degenerate parsing cases when the first character is
  already bad.

  Eg, $"abc" would have previously parsed as a <$"> variable, even
  although a double quote is not a valid variable character.

  Now emits a warning and parses as a '$' token and a string token.
2019-10-08 18:43:38 +02:00
Mark Olesen
46225279c0 ENH: improvements to stringOps::expand operations
- add toScalar evaluation, embedded as "${{EXPR}}".

  For example,

    "repeat ${{5 * 7}} times or ${{ pow(3, 10) }}"

- use direct string concatenation if primitive entry is only a string
  type. This prevents spurious quotes from appearing in the expansion.

     radius  "(2+4)";
     angle   "3*15";
     #eval   "$radius*sin(degToRad($angle))";

     We want to have
         '(2+4)*sin(degToRad(3*15))'
     and not
         '"(2+4)"*sin(degToRad("3*15"))'

ENH: code refactoring

- refactored expansion code with low-level service routines now
  belonging to file-scope. All expansion routines use a common
  multi-parameter backend to handle with/without dictionary etc.
  This removes a large amount of code duplication.
2019-10-07 08:27:19 +02:00
Mark Olesen
bd35981feb ENH: stringOps::toScalar improvements
- add floor/ceil/round methods
- support evaluation of sub-strings

STYLE: add blockMeshDict1.calc, blockMeshDict1.eval test dictionaries

- useful for testing and simple demonstration of equivalence
2019-10-04 17:50:55 +02:00
Mark Olesen
836d3a849f ENH: add stringOps::toScalar and dictionary #eval directive
- the #eval directive is similar to the #calc directive, but for evaluating
  string expressions into scalar values. It uses an internal parser for
  the evaluation instead of dynamic code compilation. This can make it
  more suitable for 'quick' evaluations.

  The evaluation supports the following:
    - operations:  - + * /
    - functions:  exp, log, log10, pow, sqrt, cbrt, sqr, mag, magSqr
    - trigonometric:  sin, cos, tan, asin, acos, atan, atan2, hypot
    - hyperbolic:  sinh, cosh, tanh
    - conversions:  degToRad, radToDeg
    - constants:  pi()
    - misc: rand(), rand(seed)
2019-09-30 16:40:32 +02:00
Mark Olesen
b5342c166c ENH: handle keyType type (literal/regex) as enum instead of bool
- makes its use somewhat clearer and allows more future options
2019-08-20 13:48:05 +02:00
Andrew Heather
be44dcaf1f RELEASE: Version clean-up for release 2019-06-25 11:51:19 +01:00
OpenFOAM bot
154029ddd0 BOT: Cleaned up header files 2019-02-06 12:28:23 +00:00
Mark Olesen
22b659d7c0 ENH: export FOAM_API in dictionary (issue #1158)
- uses the value of foamVersion::api, which should be reliable.
2019-01-07 19:04:50 +01:00
Andrew Heather
9231534efa STYLE: Updating version to v1812 2018-12-19 18:07:52 +00:00
Mark Olesen
c6520033c9 ENH: rationalize dictionary access methods
- use keyType::option enum to consolidate searching options.
  These enumeration names should be more intuitive to use
  and improve code readability.

    Eg,   lookupEntry(key, keyType::REGEX);
    vs    lookupEntry(key, false, true);

  or

    Eg,   lookupEntry(key, keyType::LITERAL_RECURSIVE);
    vs    lookupEntry(key, true, false);

- new findEntry(), findDict(), findScoped() methods with consolidated
  search options for shorter naming and access names more closely
  aligned with other components. Behave simliarly to the
  methods lookupEntryPtr(), subDictPtr(), lookupScopedEntryPtr(),
  respectively. Default search parameters consistent with lookupEntry().

    Eg, const entry* e = dict.findEntry(key);
    vs  const entry* e = dict.lookupEntryPtr(key, false, true);

- added '*' and '->' dereference operators to dictionary searchers.
2018-10-15 16:16:12 +02:00
Andrew Heather
6e35bcda70 ENH: Updated config for release v1806 2018-06-28 12:56:00 +01:00
Mark Olesen
d318a630b6 ENH: add directive '#sinclude' (or '#includeIfPresent' as long name)
- consistency with make and more succinct.

- reduce code duplication in findEtcFiles.
2018-05-28 13:38:03 +02:00
Mark Olesen
2fde6c3ab0 ENH: improve handling of mismatched brackets, forgotten ';' (issue #762)
- flags the following type of problems:

  * mismatches:

        keyword  mismatch ( set of { brackets ) in the } entry;

  * underflow (too many closing brackets:

        keyword  too many ( set of ) brackets ) in ) entry;

- a missing semi-colon

        dict
        {
           keyword  entry with missing semi-colon
        }

  will be flagged as 'underflow', since it parses through the '}' but
  did not open with it.

Max monitoring depth is 60 levels of nesting, to avoid incurring any
memory allocation.
2018-04-25 09:55:00 +02:00
Mark Olesen
3d608bf06a ENH: remove reliance on the Xfer class (issue #639)
This class is largely a pre-C++11 holdover. It is now possible to
simply use move construct/assignment directly.

In a few rare cases (eg, polyMesh::resetPrimitives) it has been
replaced by an autoPtr.
2018-03-05 13:28:53 +01:00
Mark Olesen
f2ba618c19 STYLE: consistency in using argList::addArgument, argList::addOption 2017-11-22 12:54:28 +01:00
Mark Olesen
61534989df ENH: simplify primitiveEntry parsing code, move append new tokens
- simplify string output code
2017-11-05 22:07:17 +01:00
Mark Olesen
4e48beffd4 ENH: support "one-shot" changes to the dictionary inputMode (issue #429)
- Instead of relying on #inputMode to effect a global change it is now
  possible (and recommended) to a temporary change in the inputMode
  for the following entry.

     #default   : provide default value if entry is not already defined
     #overwrite : silently remove a previously existing entry
     #warn      : warn about duplicate entries
     #error     : error if any duplicate entries occur
     #merge     : merge sub-dictionaries when possible (the default mode)

  This is generally less cumbersome than the switching the global
  inputMode. For example to provide a set of fallback values.

      #includeIfPresent "user-files"
      ...
      #default value uniform 10;

  vs.

      #includeIfPresent "user-files"
      #inputMode protect
      ...
      value uniform 10;
      #inputMode merge    // _Assuming_ we actually had this before

  These directives can also be used to suppress the normal dictionary
  merge semantics:

     #overwrite dict { entry val; ... }
2017-07-29 17:44:22 +02:00
Mark Olesen
2fdc6b161a ENH: support full-scoping for keywords as lvalue (issue #429)
- patterns only supported for the final element.

  To create an element as a pattern instead of a word, an embedded
  string quote (single or double) is used for that element.
  Any of the following examples:

      "/top/sub/dict/'(p|U).*"     100;
      "/top/sub/dict/'(p|U).*'"    100;
      "/top/sub/dict/\"(p|U).*"    100;
      "/top/sub/dict/\"(p|U).*\""  100;

  are equivalent to the longer form:

      top
      {
          sub
          {
              dict
              {
                  "(p|U).*"     100;
              }
          }
      }

  It is not currently possible to auto-vivify intermediate
  dictionaries with patterns.

    NOK   "/nonexistent.*/value"   100;
    OK    "/existing.*/value"      100;

- full scoping also works for the #remove directive

        #remove "/dict1/subdict2/entry1"
2017-07-20 10:58:05 +02:00
Mark Olesen
5148e4f860 STYLE: manage dictionary inputMode directly within entry class
- The logic for switching input-mode was previously completely
  encapsulated within the #inputMode directive, but without any
  programming equivalent. Furthermore, the encapsulation in inputMode
  made the logic less clear in other places.

  Exposing the inputMode as an enum with direct access from entry
  simplifies things a fair bit.

- eliminate one level of else/if nesting in entryIO.C for clearer logic

- for dictionary function entries, simply use
  addNamedToMemberFunctionSelectionTable() and avoid defining a type()
  as a static. For most function entries the information is only used
  to get a name for the selection table lookup anyhow.
2017-08-03 07:14:17 +02:00
Mark Olesen
cc290b7c02 ENH: improve dictionary parsing behaviour for ill-formed entries (closes #510)
- mostly associated with forgotten quotes around "(abd|def)" ...

- Address different potential problems:

      (key) { key1   entry1; }
      (key) { key1   entry1; };    // <- Note trailing ';'
      (key) entry2;
2017-07-19 11:00:44 +02:00
Mark Olesen
84e47f2d2a ENH: cleanup dictionary code
- use typedefs and new features/methods
- file-scope template to avoid code duplication.
2017-07-06 12:58:04 +02:00
Mark Olesen
ffe3e0e425 ENH: allow '^' as anchor for dictionary scoping (issue #429)
- The existing ':' anchor works for rvalue substitutions
  (Eg, ${:subdict.name}), but fails for lvalues, since it is
  a punctuation token and parse stops there.
2017-04-25 11:57:21 +02:00
Mark Olesen
f05be160e2 BUG: dictionary entries not being properly merged/overwritten (closes #418)
STYLE: update dictionary documentation
2017-03-03 11:36:24 +01:00
Mark Olesen
6d5db96ad9 ENH: subdict output with leading name (issue #255)
- Introduce dictionary::writeEntries for better code-reuse.

  Before
  ======
      os << nl << indent << "name";
      dict.write(os);

  After
  =====
      dict.write(os, "name");
2016-06-09 18:33:56 +01:00
Andrew Heather
f0c3e8d599 STYLE: Updated version to 'plus' 2015-12-22 23:14:17 +00:00
Andrew Heather
8837a89237 STYLE: Updated links from openfoam.org to openfoam.com 2015-12-09 15:03:05 +00:00
OpenFOAM-admin
9fb26d59d3 GIT: Repo update 2014-12-11 08:35:10 +00:00
OpenFOAM-admin
fbb3ddf2c4 Updated for release 2.3.0 2014-02-17 10:21:46 +00:00
mattijs
7da6784897 ENH: testDict: key substitution 2013-05-08 14:11:13 +01:00
mattijs
6dc4de7d3f ENH: dictionary: recursive variable expansion 2012-10-15 16:00:03 +01:00
mattijs
78a7cdf7f3 ENH: Test-dictionary: test dictionary variable expansion 2012-10-12 17:52:52 +01:00
mattijs
87bab77daf ENH:dictionary: allow scoped variable lookup (using '.') 2012-09-12 09:14:43 +01:00
Henry
c2dd153a14 Copyright transfered to the OpenFOAM Foundation 2011-08-14 12:17:30 +01:00
OpenFOAM-admin
c720299876 ENH: Reverted back to version dev 2011-06-17 10:08:20 +01:00
mattijs
4f47ff0219 STYLE: dictionaries: update version number 2011-06-10 17:22:56 +01:00
mattijs
b89f6082b0 STYLE: dictionary headers 2011-04-06 20:35:56 +01:00
Mark Olesen
4aafea74a9 COMP: removed calcEntry bits missed in b4dae1a5ab 2011-02-24 11:35:24 +01:00
andy
eaef8d482b STYLE: Updated 1991 start copyright year to 2004 2011-01-14 16:08:00 +00:00
andy
099cc39e2e Revert "STYLE: 2011 copyright date."
This reverts commit b18f6cc1ce.
2011-01-05 18:24:29 +00:00
graham
b18f6cc1ce STYLE: 2011 copyright date. 2011-01-05 11:14:26 +00:00
Mark Olesen
499d48cfdb STYLE: uniform 'Test-' prefix for all applications/test
- easier to clean, avoid confusion with 'real' applications, etc.
2010-11-23 16:26:04 +01:00
graham
28345247a7 STYLE: Fixing code style requirements for more files - those not
picked up by a copyright change.
2010-07-29 11:28:44 +01:00