openfoam/tutorials/compressible/rhoSimpleFoam/squareBend/system/derivedFields
Mark Olesen 8d4ad0438d 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;
      ...
  }
  ```
2021-12-10 14:46:21 +00:00

66 lines
1.3 KiB
C++

// -*- C++ -*-
// Create additional volume fields (for sampling)
derivedFields
{
// Mandatory entries
type derivedFields;
libs (fieldFunctionObjects);
derived (rhoU pTotal);
// Optional entries
rhoRef 1.25;
// Optional (inherited) entries
region region0;
enabled true;
log true;
timeStart 0;
timeEnd 10000;
executeControl timeStep;
executeInterval 1;
writeControl none;
writeInterval -1;
}
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";
}
// ************************************************************************* //