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)
This commit is contained in:
Mark Olesen
2021-11-18 18:41:20 +01:00
parent e6697edb52
commit fc6239d96e
19 changed files with 5896 additions and 5086 deletions

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2112 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -138,4 +138,53 @@ cosine6
}
expr1
{
type expression;
functions<scalar>
{
func1 constant 21;
func2 constant 15;
sin constant -5;
}
functions<vector>
{
vfunc3 constant (1 2 3);
vfunc4 constant (3 2 1);
}
expression
#{
100 * fn:vfunc3() & fn:vfunc4() * (vector::z) .z()
* (fn:sin(arg()) + fn:func1(fn:func2()))
#};
}
expr2
{
type expression;
functions<scalar>
{
func1 constant 21;
func2 constant 15;
sin constant -5;
}
functions<vector>
{
vfunc3 constant (1 2 3);
vfunc4 constant (3 2 1);
}
expression
#{
(fn:vfunc3() & vector::z) * arg()
#};
}
// ************************************************************************* //