Skip to content
Snippets Groups Projects
  1. Dec 13, 2019
  2. Dec 09, 2019
    • Mark OLESEN's avatar
      ENH: generalize string expression evaluation · c2123452
      Mark OLESEN authored
      - 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.
      c2123452
  3. Oct 31, 2019
  4. Nov 10, 2019
  5. Oct 07, 2019
    • Mark OLESEN's avatar
      ENH: improvements to stringOps::expand operations · 46225279
      Mark OLESEN authored
      - 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.
      46225279
  6. Sep 30, 2019
    • Mark OLESEN's avatar
      ENH: add stringOps::toScalar and dictionary #eval directive · 836d3a84
      Mark OLESEN authored
      - 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)
      836d3a84
  7. Sep 24, 2019
  8. Aug 07, 2019
  9. Feb 06, 2019
  10. Dec 13, 2018
  11. Dec 12, 2018
    • Mark OLESEN's avatar
      ENH: support search modes for etcFiles() · 172c36c2
      Mark OLESEN authored
      - similar to the foamEtcFile script -mode=... option, the specific
        search location (user/group/other) can now also specified for
        string expansions and as a numerical value for etcFile()
      
        For example, if searching for group or other (project) controlDict,
        but not wishing to see the user controlDict:
      
          1.  foamEtcFile -mode=go controlDict
      
          2.  fileName dictFile("<etc:go>/controlDict");
              dictFile.expand();
      
          3.  etcFile(controlDict, false, 0077);
      
        The default behaviour for searching all contexts is unchanged.
      
          1.  foamEtcFile controlDict
      
          2.  fileName dictFile("<etc>/controlDict");
              dictFile.expand();
      
          3.  etcFile(controlDict);
      172c36c2
  12. Nov 23, 2018
  13. Nov 21, 2018
  14. Sep 11, 2018
  15. Mar 28, 2018
  16. Apr 10, 2018
    • Mark OLESEN's avatar
      ENH: additional text expansion shortcuts (issue #792) · a9741cea
      Mark OLESEN authored
      Support the following expansions when they occur at the start of a
      string:
      
          Short-form       Equivalent
          =========       ===========
            <etc>/          ~OpenFOAM/   (as per foamEtcFile)
            <case>/         $FOAM_CASE/
            <constant>/     $FOAM_CASE/constant/
            <system>/       $FOAM_CASE/system/
      
      These can be used in fileName expansions to improve clarity and reduce
      some typing
      
           "<constant>/reactions"   vs  "$FOAM_CASE/constant/reactions"
      a9741cea
  17. Feb 21, 2018
  18. Feb 08, 2018
  19. Nov 13, 2017
  20. Nov 05, 2017
  21. Nov 23, 2017
    • Mark OLESEN's avatar
      ENH: improvements to stringOps format and split functions · d49929b2
      Mark OLESEN authored
      - split now optionally retains empty substrings.
        Added split on fixed field width.
      
      - Foam::name() now formats directly into string buffer, which a
        removes one layer of copying and also avoids using a non-constexpr
        in the temporary.
      
      STYLE: explicit type narrowing on zero-padded output for ensight
      d49929b2
  22. Nov 22, 2017
  23. Nov 20, 2017
  24. Aug 14, 2017
  25. Oct 27, 2017
    • Mark OLESEN's avatar
      ENH: allow passing of comparator to sortToc methods · 0a62fd2f
      Mark OLESEN authored
      - this increases the flexibility of the interface
      
      - Add stringOps 'natural' string sorting comparison.
        Digits are sorted in their natural order, which means that
            (file10.txt file05.txt file2.txt)
        are sorted as
            (file2.txt file05.txt file10.txt)
      
      STYLE: consistent naming of template parameters for comparators
      
        - Compare for normal binary predicates
        - ListComparePredicate for list compare binary predicates
      0a62fd2f
  26. Jul 20, 2017
  27. Feb 24, 2017
    • Mark Olesen's avatar
      ENH: support default/alternate values for env-vars in dictionary lookup · 9810c68e
      Mark Olesen authored
      - was previously only within string expansions, but cover dictionaries
        as well for consistency
      
      ENH: replace the never-used fileName::caseName() functionality
      
      - stringOps::inplaceReplaceVar() is more general
      
           stringOps::inplaceReplaceVar(myfile, "FOAM_CASE");
      
      STYLE: relax parameter passing when calling some POSIX 'query' functions.
      
      - A std::string is sufficient since the functions use a plain C-string.
        Eg, getEnv("SOMETHING").
        Retain more stringent Foam::word for things like setEnv, since this
        could be useful.
      9810c68e
  28. Jul 01, 2016
    • Mark Olesen's avatar
      ENH: provide formatting version of Foam::name() (issue #253) · cae7ce37
      Mark Olesen authored
      - there are some cases in which the C-style sprintf is much more
        convenient, albeit problematic for buffer overwrites.
      
        Provide a formatting version of Foam::name() for language
        primitives that is buffer-safe.
      
        Returns a Foam::word, so that further output will be unquoted, but
        without any checking that the characters are indeed entirely valid
        word characters.
      
        Example use,
            i = 1234;
            s = Foam::name("%08d", i);
            produces '00001234'
      
        Alternative using string streams:
      
            std::ostringstream buf;
            buf.fill('0');
            buf << setw(8) << i;
            s = buf.str();
      
        Note that the format specification can also be slightly more complex:
      
           Foam::name("output%08d.vtk", i);
           Foam::name("timing=%.2fs", time);
      
      It remains the caller's responsibility to ensure that the format mask
      is valid.
      cae7ce37
  29. Oct 12, 2012
  30. Aug 14, 2011
  31. Mar 18, 2011
  32. Mar 02, 2011
  33. Feb 23, 2011
  34. Feb 22, 2011