Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • openfoam openfoam
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 445
    • Issues 445
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 10
    • Merge requests 10
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • openfoamopenfoam
  • Merge requests
  • !593

Field functions for lerp and clamp. Add clamping as Field methods

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Mark OLESEN requested to merge feature-field-functions-SIMD into develop Feb 06, 2023
  • Overview 5
  • Commits 11
  • Changes 195

To improve data locality and simplify calling code, now have lerp() and clamp() as free functions working on fields. Both can be composed as a SIMD type of operation (with three operands) and applied within the fields loops instead of being composed as separate field operations.

  • Having lerp turns out to only be moderately useful, since most of the schemes have already unrolled the operation inside. However, it is still quite convenient when composing (for example) mixed boundary conditions or combining patch internal and neighbour values.
  • The clamp method is used in several more places, quite commonly in multi-phase routines to enforce a strict 0-1 boundness.

Since clamping of field values is a quite useful property, in-place clamping has been added as field methods directly:

  • clamp_min(...), clamp_max(...), clamp_range(...)

The frequently required 0-1 bounding can be use succinctly with the zero_one dispatch tag. For example,

alpha.clamp_range(zero_one{});

Tip: with flow switching (eg, inlet/outlet) the lerp function can be combined with pos0 to define a selector. Eg,

lerp(a, b, pos0(phi))

// vs.
a*neg(phi) + b * pos0(phi)
Edited Feb 06, 2023 by Mark OLESEN
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: feature-field-functions-SIMD