Contrib/swak4Foam

From OpenFOAMWiki
< Contrib
Revision as of 23:17, 13 September 2010 by Bgschaid (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Look. If this works, it'll keep us from getting caught. If it doesn't, it'll keep us from getting old.
MacGyver. Master of the knife

A library that combines the functionality of groovyBC and funkySetFields. Currently this page is incomplete. Please have a look at those 2 pages for further information.

This page is only a stub. I'll finish it when I find time. If you feel that you can improve it: go ahead

1 About

swak4Foam stands for SWiss Army Knife for Foam. Like that knife it rarely is the best tool for any given task, but sometimes it is more convenient to get it out of your pocket than going to the tool-shed to get the chain-saw.

2 Contents

2.1 Libraries

swak4FoamParsers
The basis of swak4Foam: the expression parsers with the logic to access the OpenFOAM data-structures. None of the other software pieces compile without it
groovyBC
Implements the infamous groovyBC. A boundary condition that allows arbitrary expressions in the field-file
swakFunctionObjects
Function objects that have no additional requirements. Mainly used for manipulating and creating fields with expressions
simpleSwakFunctionObjects
Function objects based on the simpleFunctionObjects-library (which is a prerequisite for compiling it). Evaluate expressions and output the results
swakSourceFields
Field that is calculated from an expression. To be used as source-term or coefficient in some solver
swakTopoSources
topoSources for cellSet and faceSet. Can be used with the cellSet and faceSet-utilities

2.2 Utilities

funkySetFields
Utility that allows creation and manipulation of files with expressions
funkySetBoundaryField
Sets any field on a boundary to a non-uniform value based on an expression.
Acts without deeper understanding of the underlying boundary condition
replayTransientBC
Utility to quickly test whether a groovyBC gives the expected results. Writes the specified fields with the applied boundary condition but doesn't do anything else. Can be used for other transient BCs as well

2.3 Examples

Have a look at the README and the files to understand how to use things

3 Expression

These are the core of it. Expressions can be used for

3.1 Accessing external expressions

The syntax for this is slightly different from external expressions in groovyBC (the change of syntax was chosen to avoid clashes with valid patch or zone names).

The destination for an external expression is enclosed in {}. It can consist of three parts

  1. entity type (if none is given, then patch is assumed. Unless no name is given, then internalField is assumed). Valid types are
    • internalField
    • patch
    • cellZone
    • faceZone
    • cellSet
    • faceSet
  2. entity name
  3. mesh region (if none is given, then the current mesh is assumed)

Not all three parts have to present. In the general form it is written as {type'name/region}. So

pInlet{inlet}=average(p);

is the average pressure on the inlet.

pControl{faceZone'control/otherMesh}=average(p);

is the average pressure on a faceZone on another mesh.

External values can only be used if they are homogenous (so they should either be a min, max, sum or average)

3.2 Random notes on the expression syntax

Some changes to the original syntax of groovyBC and funkySetFields (these remarks should become obsolete once there is a canonical list of functions here).

  • For faceSet and faceZone a pseudo-function flip() is defined which is either +1 or -1. For faceZone this is the flipMap (-1 if the flipMap is true for a face). For a faceSet named (for instance) foo it is defined if a cellSet of the name fooSlaveCells is defined (this follows the convention of the setsToZones-utility. The main purpose of this function is to get consistent mass-flows on faces (phi*flip() takes into account the orientation of the faces)
  • there is a new pseudo-function cpu() that returns the number of the current CPU for parallel runs
  • the pseudo-function id() returns the cell/face-id

4 Downloading

The current version can be downloaded using this command

svn checkout https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.7/libraries/swak4Foam/

Further information is found in the README-file.

--Bgschaid 01:17, 14 September 2010 (CEST)