ENH: add exprField function object

- provides a simple means of defining/modifying fields. For example,

  ```
  <name1>
  {
      type    exprField;
      libs    (fieldFunctionObjects);
      field   pTotal;

      expression  "p + 0.5*(rho*magSqr(U))";
      dimensions  [ Pa ];
  }
  ```
  It is is also possible to modify an existing field.
  For example, to modify the previous one.
  ```
  <name2>
  {
      type    exprField;
      libs    (fieldFunctionObjects);
      field   pTotal;
      action  modify;

      // Static pressure only in these regions
      fieldMask
      #{
          (mag(pos()) < 0.05) && (pos().y() > 0)
       || cellZone(inlet)
      #};
      expression  "p";
  }
  ```

  To use as a simple post-process calculator, simply avoid storing the
  result and only generate on write:
  ```
  <name2>
  {
      store            false;
      executionControl none;
      writeControl     writeTime;
      ...
  }
  ```
This commit is contained in:
Mark Olesen
2021-12-10 11:03:38 +01:00
committed by Andrew Heather
parent a6cbfcb9ba
commit 8d4ad0438d
5 changed files with 986 additions and 2 deletions

View File

@ -24,4 +24,42 @@ derivedFields
}
exprField1
{
// Mandatory entries
type exprField;
libs (fieldFunctionObjects);
field pTot;
/// action new;
///autowrite false;
///store true;
useNamePrefix false;
// Use expression to define total pressure
executeControl timeStep;
writeControl none;
expression "p + 0.5*(rho * magSqr(U))";
dimensions [ Pa ];
}
exprField1.mod0
{
// Mandatory entries
type exprField;
libs (fieldFunctionObjects);
field pTot;
action modify;
executeControl timeStep;
writeControl writeTime;
// Static pressure only in these regions
fieldMask "(mag(pos()) < 0.05) && (pos().y() > 0) || cellZone(inlet)";
expression "p";
}
// ************************************************************************* //

View File

@ -69,7 +69,7 @@ sampled
surfaceFormat none;
fields (p rho U T rhoU pTotal);
fields (p rho U T rhoU pTotal pTot);
// Remove derived fields we created prior
removeFieldsOnExecute (rhoU pTotal);
@ -182,7 +182,7 @@ areaAverage
operation weightedAreaAverage;
weightField rhoU;
weightFields ( rho U none ); // 2012 and later
fields ( p pTotal );
fields ( p pTotal pTot );
}
areaIntegrate