Commit Graph

25207 Commits

Author SHA1 Message Date
2880a54373 Merge branch 'feature-expr-improvements' into 'develop'
Updates for expressions to improve robustness and support functions, external context etc.

See merge request Development/openfoam!501
2021-11-26 12:16:45 +00:00
c0adccf826 ENH: generalize volField lookups to include 'context' objects
- allows an additional HashTable of pointers to reference external
  content which not otherwise directly available via an
  objectRegistry.

  This could typically be used to provide a function-local "rho"
  to the expression evaluation.
2021-11-26 12:24:35 +01:00
643763d258 ENH: add cell/face set/zone support for patch expressions
- for cell quantities, these evaluate on the faceCells associated with
  that patch to produce a field of true/false values

- for face quantities, these simply correspond to the mesh faces
  associated with that patch to produce a field of true/false values
2021-11-26 12:24:35 +01:00
fc6239d96e ENH: add expression support for scalar/vector expression lookups
- similar idea to swak timelines/lookuptables but combined together
  and based on Function1 for more flexibility.

  Specified as 'functions<scalar>' or 'functions<vector>'.
  For example,

  functions<scalar>
  {
      intakeType table ((0 0) (10 1.2));

      p_inlet
      {
          type        sine;
          frequency   3000;
          scale       50;
          level       101325;
      }
  }

  These can be referenced in the expressions as a nullary function or a
  unary function.

  Within the parser, the names are prefixed with "fn:" (function).
  It is thus possible to define "fn:sin()" that is different than
  the builtin "sin()" function.

     * A nullary call uses time value
       - Eg, fn:p_inlet()

     * A unary call acts as a remapper function.
       - Eg, fn:intakeType(6.25)
2021-11-26 12:24:35 +01:00
e6697edb52 ENH: robuster lemon parsing
- previously simply reused the scan token, which works fine for
  non-nested tokenizations but becomes too fragile with nesting.

  Now changed to use tagged unions that can be copied about
  and still retain some rudimentary knowledge of their types,
  which can be manually triggered with a destroy() call.

- provide an 'identifier' non-terminal as an additional catch
  to avoid potential leakage on parsing failure.

- adjust lemon rules and infrastructure:

  - use %token to predefine standard tokens.
    Will reduce some noise on the generated headers by retaining the
    order on the initial token names.

  - Define BIT_NOT, internal token rename NOT -> LNOT

- handle non-terminal vector values.
  Support vector::x, vector::y and vector::z constants

- permit fieldExpr access to time().
  Probably not usable or useful for an '#eval' expression,
  but useful for a Function1.

- provisioning for hooks into function calls. Establishes token
  names for next commit(s).
2021-11-26 12:24:35 +01:00
adbcd3a19f Merge branch 'feature-functionObject-Function1' into 'develop'
Function1 objectRegistry access

See merge request Development/openfoam!499
2021-11-26 11:24:13 +00:00
adcf41bd13 ENH: add Function1 wrapping for functionObject trigger
Returns a 0/1 value corresponding to function object trigger levels.

    Usage:
    \verbatim
        <entryName> functionObjectTrigger;
        <entryName>Coeffs
        {
            triggers        (1 3 5);
            defaultValue    false;  // Default when no triggers activated
        }
    \endverbatim

ENH: add reset() method for Constant Function1

ENH: allow forced change of trigger index

- the triggers are normally increase only,
  but can now override this optionally
2021-11-26 11:22:36 +00:00
30a2fa4b27 BUG: dsmcFields fails with scoped field names 2021-11-26 11:22:36 +00:00
89ddc271c7 ENH: LimitRange Function1 - extended and renamed
Description
    Function1 wrapper that maps the input value prior to it being used by
    another Function1.

    Example usage for limiting a polynomial:
    \verbatim
        <entryName>
        {
            type            inputValueMapper;
            mode            minMax;

            min             0.4;
            max             1.4;

            value polynomial
            (
                (5 1)
                (-2 2)
                (-2 3)
                (1 4)
            );
        }
    \endverbatim

    Here the return value will be:
    - poly(0.4) for x <= 0.4;
    - poly(1.4) for x >= 1.4; and
    - poly(x) for 0.4 < x < 1.4.

    Example usage for supplying a patch mass flux for a table lookup:
    \verbatim
        <entryName>
        {
            type            inputValueMapper;
            mode            function;

            function
            {
                type            functionObjectValue;
                functionObject  surfaceFieldValue1;
                functionObjectResult sum(outlet,phi);
            }

            value
            {
                type        table;
                file        "<system>/fanCurve.txt";
            }
        }
    \endverbatim

    Where:
    \table
        Property | Description                                  | Required
        mode     | Mapping mode (see below)                     | yes
        function | Mapping Function1                            | no*
        min      | Minimum input value                          | no*
        max      | Maximum input value                          | no*
        value    | Function of type Function1<Type>             | yes
    \endtable

    Mapping modes include
    - none     : the input value is simply passed to the 'value' Function1
    - function : the input value is passed through the 'function' Function1
                 before being passed to the 'value' Function1
    - minMax   : limits the input value to 'min' and 'max' values before being
                 passed to the 'value' Function1

Note
    Replaces the LimitRange Function1 (v2106 and earlier)
2021-11-26 11:22:36 +00:00
ba45fb2cba ENH: Function1 - updated time-based Function1 usage 2021-11-26 11:22:36 +00:00
f6ee1811e7 STYLE: renamed convertTimeBase to more descriptive userTimeToTime 2021-11-26 11:22:36 +00:00
098aec4962 ENH: Function1's - added objectRegistry access 2021-11-26 11:22:36 +00:00
889bc171d9 TUT: Added example showing use of functionObject result lookup from a Function1 2021-11-26 11:22:36 +00:00
c233961d45 ENH: function objects - apply scoped name when registering objects 2021-11-26 11:22:36 +00:00
9194cd5203 ENH: Deprecated TimeFunction1 usage in favour of Function1 2021-11-26 11:22:36 +00:00
925a2e724b ENH: add caching selector to PatchFunction1
- extend handling of uniform PatchFunction1 to include new Function1
  types and pass through the objectRegistry information
2021-11-26 11:22:36 +00:00
f29eb55cee ENH: Refactored TimeFunction1 - now possible using Function1 directly 2021-11-26 11:22:36 +00:00
b9b011f5ea ENH: Added new sample Function1 2021-11-26 11:22:36 +00:00
bc2b469f9d ENH: Added new Function1: FunctionObjectValue
Returns a value retrieved from a function object result.

Usage:
    <entryName> functionObjectValue;
    <entryName>Coeffs
    {
        functionObject          <name>;
        functionObjectResult    <function object result field name>
    }
2021-11-26 11:22:36 +00:00
2c2310dc17 ENH: reference function object - retrieve reference using Function1
Note: previous behaviour to set the reference to a cell value can be recovered
by using the new 'sample' Function1
2021-11-26 11:22:36 +00:00
70b55be684 COMP: Function1 - propagated API change resulting from new objectRegistry access 2021-11-26 11:22:36 +00:00
c1a04abd96 ENH: Function1 - added optional objectRegistry reference
Function1 can now be created with an object registry, e.g. time or mesh
database. This enables access to other stored objects, e.g. fields,
dictionaries etc. making Function1 much more flexible.

Note: will allow TimeFunction1 to be deprecated
2021-11-26 11:22:36 +00:00
aeef96251f ENH: Refactored stateFunctionObject
- created new functionObjects::properties class derived from IOdictionary
  - replaces raw state IOdictionary owned by functionObjectList
  - state dictionary access/manipulators moved from stateFunctionObject
- stateFunctionObject now acts as a light wrapper around
  functionObjecties::properties
- updated dependent code
2021-11-26 11:22:36 +00:00
b19e767b8f ENH: sampledSets - added min,max,average values to the results dict 2021-11-26 11:22:36 +00:00
f078643f8c ENH: add blockFaces.vtp output for blockMesh -write-vtk 2021-11-25 20:02:09 +01:00
f459b11e24 STYLE: direct iteration over dictionary entries 2021-11-25 20:02:08 +01:00
bcf8a48c68 CONFIG: add build information into shell session
- more closely reflect what the binaries report
- report the installation path
- change PS1 case/separator to roughly correspond to package names

STYLE: adjust README to mention upcoming v2112
2021-11-25 17:36:37 +01:00
1804d3fed5 ENH: additional #word and #message dictionary directives (#2276)
- use `#word` to concatenate, expand content with the resulting string
  being treated as a word token. Can be used in dictionary or
  primitive context.

  In dictionary context, it fills the gap for constructing dictionary
  names on-the-fly. For example,

  ```
  #word "some_prefix_solverInfo_${application}"
  {
      type    solverInfo;
      libs    (utilityFunctionObjects);
      ...
  }
  ```

  The '#word' directive will automatically squeeze out non-word
  characters. In the block content form, it will also strip out
  comments. This means that this type of content should also work:

  ```
  #word {
     some_prefix_solverInfo
     /* Appended with application name (if defined) */
     ${application:+_}  // Use '_' separator
     ${application}     // The application
  }
  {
      type    solverInfo;
      libs    (utilityFunctionObjects);
      ...
  }
  ```
  This is admittedly quite ugly, but illustrates its capabilities.

- use `#message` to report expanded string content to stderr.
  For example,

  ```
  T
  {
     solver          PBiCG;
     preconditioner  DILU;
     tolerance       1e-10;
     relTol          0;
     #message "using solver: $solver"
  }
  ```
  Only reports on the master node.
2021-11-25 17:05:37 +01:00
55af2fc2c6 BUG: missing unit-normal weighting for surfaceFieldValue (fixes #2273)
- when using a vector field for weighting, it either used mag()
  or mag * area, but did not have a unit-normal projection version
2021-11-25 09:39:20 +01:00
ccb0fd9cf0 EMH: Adding layers option and writing out HR and Tdew fields for
humidityTemperature BC
2021-11-24 15:52:24 -08:00
6712548137 Merge branch 'feature-electrodeposition' into 'develop'
ENH: New suite for electrostatic deposition applications

See merge request Development/openfoam!496
2021-11-24 18:06:39 +00:00
27f4cee78d TUT: interFoam: new tutorial for electrostatic deposition 2021-11-24 18:05:58 +00:00
19f7825a04 ENH: electrostaticDeposition: new finiteVolume boundary condition 2021-11-24 18:05:58 +00:00
aaeddba466 ENH: electricPotential: new solver function object 2021-11-24 18:05:58 +00:00
fd9670d4a3 ENH: add objectRegistry handling to expressions driver
- needed for future embedding
2021-11-23 13:37:37 +01:00
fbd7b78999 ENH: make expressions::FieldAssociation a common enum
- use FACE_DATA (was SURFACE_DATA) for similarity with polySurface

ENH: add expression value enumerations and traits

- simple enumeration of standard types (bool, label, scalar, vector)
  that can be used as a value type-code for internal bookkeeping.

GIT: relocate pTraits into general traits/ directory
2021-11-23 12:53:45 +01:00
141403ed98 BUG: compare of two zero-sized faces was returning false 2021-11-23 10:31:24 +01:00
d710bb6595 TUT: Rename tutorial 2021-11-22 09:44:46 -08:00
bb7d8d0f4d BUG: mapped: make consistent with AMI. Fixes #2275 2021-11-22 12:21:13 +00:00
39d244ad91 ENH: add check for isTimeDb() into objectRegistry
- add missing time() into pointMesh

STYLE: use static_cast instead of dynamic_cast for Time -> objectRegistry
2021-11-17 19:52:33 +01:00
1af0380edc Merge branch 'feature-dictionary-reporting' into 'develop'
ENH: report dictionary defaults with Executable prefix

See merge request Development/openfoam!498
2021-11-17 17:33:01 +00:00
3d889b6dbf ENH: report dictionary defaults with Executable prefix
- provides better context when default values are accessed from
  a dictionary than reporting a source file location.
2021-11-17 16:04:46 +01:00
bb771a3caf GIT: remove spurious method declaration in regIOobject
STYLE: adjust param/return for internal readStream method
2021-11-17 16:04:40 +01:00
92d52243af ENH: support cref() and shallow copies (refPtr and tmp)
- enables building HashTables with shadowed variables

- support good() and valid() as synonyms in memory classes
2021-11-17 16:04:40 +01:00
96735dce20 ENH: expose ITstream hasPutback to allow better handling
STYLE: relocate ITstream::parseStream from static to file-scope
2021-11-17 16:04:40 +01:00
4e59ad9d8d ENH: make objectRegistry::cfindIOobject public 2021-11-15 22:13:21 +01:00
28800dcbbc LINT: fix permissions 2021-11-15 21:22:36 +01:00
effd69a005 ENH: add refPtr release() method
- releases ownership of the pointer. A no-op (and returns nullptr)
  for references.

  Naming consistent with unique_ptr and autoPtr.

DOC: adjust wording for memory-related classes

- add is_const() method for tmp, refPtr.

  Drop (ununsed and confusing looking) isTmp method from refPtr
  in favour of is_pointer() or movable() checks

ENH: noexcept for some pTraits methods, remove redundant 'inline'

- test for const first for tmp/refPtr (simpler logic)
2021-11-15 19:34:01 +01:00
9c9d6c64b5 DEFEATURE: remove general objects storage from exprResult
- unused, generally fragile.
2021-11-15 19:19:55 +01:00
adb01bddf4 ENH: use float-narrowing for ensight set writer
- replaces hand-rolled checks

STYLE: minor cleanup of ensightPTraits
2021-11-15 18:14:16 +01:00