Andrew Heather 1b17784a1f Merge branch 'feature-expressions' into 'develop'
Feature expressions

### Summary

This branch represents an implementation of what is considered to be the most useful aspects of swak4Foam ([Swiss-Army-Knife for FOAM](https://openfoamwiki.net/index.php/Contrib/swak4Foam)) from Bernhard Gschaider, namely the ability to use text-based expressions instead of coding in C++ for the following cases:
- expression-based boundary conditions (also known as _groovy_ boundary conditions)
- expression-based setFields (also known as _funky_ set fields)

The idea of what we currently term *expressions* was pioneered by
(Bernhard Gschaider) and is now firmly established in `swak4Foam`.
Among other things, expressions attempt to bridge the gap between
using standard, predefined boundary conditions and writing dedicated,
special-purpose ones. Although part of this gap is now covered within
OpenFOAM by using dynamically compiled user coding (eg, coded boundary
conditions), there remains substantial areas where it can be
significantly more convenient to have a series of predefined functions
and expression sytax with some access to base OpenFOAM field
functionality that enables rapid deployment of boundary conditions, or
custom-defined `setFields` without writing code.
A significant portion of `swak4Foam` expressions has been adapted for
direct integration into OpenFOAM. During the integration and rewrite,
we have tried to pare things down to a smaller subset with the aim of
covering 90% or more of the common cases. The remaining cases are left
to be reassessed for extending the *expressions* functionality in the
future, but they also may be better served with other approaches (eg,
with coded conditions) that were not available when `swak4Foam` was
originally conceived.

To the greatest extent possible, the integrated *expressions* have
been designed to avoid name clashes with `swak` so it should remain
possible to use the most recent versions of `swak` without problem.


### Risks

- New functionality, so low chance of regression.
- The scope of the functionality will be revised in the future

### Naming (for `swak4Foam` users)

The following are the *expressions* correspondences to `swak`:

- The `exprFixedValue` and `exprGradient` boundary conditions are
  roughly equivalent to the _groovy_ boundary conditions.

- The utilities `setExprFields` and `setExprBoundaryFields` are
  roughly equivalent to the _funky_ utilities of similar name.

The naming of the boundary conditions and utilities not only reflects
the slightly different input requirements, but simultaneously seeks to
avoid any potential name-clash with `swak4Foam` in a mixed
environment.

The names for the boundary condition dictionary entries tend be
shorter and slightly different (eg, `valueExpr` vs `valueExpression`)
to serve as a small reminder that the *expressions* syntax is slightly
different than the *groovy* equivalents. It also allows the user to
fashion dictionary entries that are sufficient for **both** boundary
condition variants and quickly toggle between them simply by changing
the boundary condition `type`.

See merge request Development/openfoam!300
2019-12-10 12:10:26 +00:00
2019-06-14 10:11:17 +01:00
2019-12-06 20:36:30 +01:00
2018-12-03 15:33:45 +00:00

About OpenFOAM

OpenFOAM is a free, open source CFD software released and developed primarily by OpenCFD Ltd since 2004. It has a large user base across most areas of engineering and science, from both commercial and academic organisations. OpenFOAM has an extensive range of features to solve anything from complex fluid flows involving chemical reactions, turbulence and heat transfer, to acoustics, solid mechanics and electromagnetics.

OpenFOAM is professionally released every six months to include customer sponsored developments and contributions from the community - individual and group contributors, re-integrations (including from FOAM-extend and OpenFOAM Foundation Ltd) - in this Official Release sanctioned by the OpenFOAM Worldwide Trademark Owner aiming towards one OpenFOAM.

Copyright

OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. See the file COPYING in this directory or http://www.gnu.org/licenses/, for a description of the GNU General Public License terms under which you may redistribute files.

OpenFOAM Trademark

OpenCFD Ltd grants use of its OpenFOAM trademark by Third Parties on a licence basis. ESI Group and OpenFOAM Foundation Ltd are currently permitted to use the Name and agreed Domain Name. For information on trademark use, please refer to the trademark policy guidelines.

Please contact OpenCFD if you have any questions on the use of the OpenFOAM trademark.

Violations of the Trademark are monitored, and will be duly prosecuted.

Using OpenFOAM

If OpenFOAM has already been compiled on your system, simply source the appropriate etc/bashrc or etc/cshrc file and get started. For example, for the OpenFOAM-v1906 version:

source /installation/path/OpenFOAM-v1906/etc/bashrc

Compiling OpenFOAM

If you are compiling OpenFOAM from source, please see the relevant guides:

Location Readme Requirements Build
OpenFOAM readme system requirements build
ThirdParty readme system requirements build

How do I know which version I am currently using?

The value of the $WM_PROJECT_DIR or even $WM_PROJECT_VERSION are not guaranteed to have any correspondence to the OpenFOAM release (API) value. If OpenFOAM has already been compiled, the build-time information is embedded into each application. For example, as displayed from blockMesh -help:

Using: OpenFOAM-v1812.local (1812) - visit www.openfoam.com
Build: 65d6551ff7-20190530 (patch=190531)
Arch:  LSB;label=32;scalar=64

This output contains all of the more interesting information that we need:

item value
version v1812.local
api 1812
commit 65d6551ff7
author date 20190530
patch-level (20)190531
label/scalar size 32/64 bits

The Arch information may also include the solveScalar size if different than the scalar size.

As can be seen in this example, the git build information is supplemented by the date when the last change was authored, which can be helpful when the repository contains local changes. If you simply wish to know the current API and patch levels directly, the wmakeBuildInfo script provides the relevant information even when OpenFOAM has not yet been compiled:

$ wmakeBuildInfo
make
    api = 1812
    patch = 190531
    branch = master
    build = 65d6551ff7-20190530

Similar information is available with foamEtcFile, using the -show-api or -show-patch options. For example,

$ foamEtcFile -show-api
1812

$ foamEtcFile -show-patch
190531

This output will generally be the easiest to parse for scripts. The $FOAM_API convenience environment variable may not reflect the patching changes made within the currently active environment and should be used with caution.

ThirdParty directory

OpenFOAM normally ships with a directory of 3rd-party software and build scripts for some 3rd-party software that is either necessary or at least highly useful for OpenFOAM, but which are not necessarily readily available on every operating system or cluster installation.

These 3rd-party sources are normally located in a directory parallel to the OpenFOAM directory. For example,

/path/parent
|-- OpenFOAM-v1906
\-- ThirdParty-v1906

There are, however, many cases where this simple convention is inadequate:

  • When no additional 3rd party software is actually required (ie, the operating system or cluster installation provides it)

  • When we have changed the OpenFOAM directory name to some arbitrary directory name, e.g. openfoam-sandbox1906, etc..

  • When we would like any additional 3rd party software to be located inside of the OpenFOAM directory to ensure that the installation is encapsulated within a single directory structure. This can be necessary for cluster installations, or may simply be a convenient means of performing a software rollout for individual workstations.

  • When we have many different OpenFOAM directories for testing or developing various different features but wish to use or reuse the same 3rd party software for them all.

The solution for these problems is a newer, more intelligent discovery when locating the ThirdParty directory with the following precedence:

  1. PROJECT/ThirdParty
    • for single-directory installations
  2. PREFIX/ThirdParty-VERSION
    • this corresponds to the traditional approach
  3. PREFIX/ThirdParty-vAPI
    • allows for an updated value of VERSION, eg, v1906-myCustom, without requiring a renamed ThirdParty. The API value would still be 1906 and the original ThirdParty-v1906/ would be found.
  4. PREFIX/ThirdParty-API
    • this is the same as the previous example, but using an unadorned API value. This also makes sense if the chosen version name also uses the unadorned API value in its naming, eg, 1906-patch190131, 1906.19W03
  5. PREFIX/ThirdParty-common
    • permits maximum reuse for various versions, but only for experienced user who are aware of potential version incompatibilities

If none of these directories are found to be suitable, it reverts to using PROJECT/ThirdParty as a dummy location (even if the directory does not exist). This is a safe fallback value since it is within the OpenFOAM directory structure and can be trusted to have no negative side-effects. In the above, the following notation has been used:

name value meaning
PROJECT $WM_PROJECT_DIR The OpenFOAM directory
PREFIX dirname $WM_PROJECT_DIR The OpenFOAM parent directory
API foamEtcFiles -show-api The api or release version
VERSION $WM_PROJECT_VERSION The version we've chosen

To reduce the potential of false positive matches (perhaps some other software also uses ThirdParty-xxx for its naming), the directory test is accompanied by a OpenFOAM-specific sanity test. The OpenFOAM ThirdParty directory will contain either an Allwmake file or a platforms/ directory.

Useful Links

Copyright 2016-2019 OpenCFD Ltd

Description
See [openfoam code wiki](/Development/openfoam/-/wikis/) for [build](/Development/openfoam/-/wikis/building) and [upgrade](/Development/openfoam/-/wikis/upgrade/upgrade) information, [binaries](/Development/openfoam/-/wikis/precompiled) ...
Readme 359 MiB
Languages
C++ 50.5%
C 46.9%
Shell 2.2%
Liquid 0.2%