Contrib/swak4Foam

From OpenFOAMWiki
< Contrib
Revision as of 09:22, 26 July 2011 by Bgschaid (Talk | contribs)

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.

Valid versions: OF version 16.png OF version 17.png OF Version 20.png

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

  • internalFields (basically the functionality of expressions in funkySetFields.
  • patchFields (basically the functionality of expressions in groovyBC
  • cellSet, faceSet, cellZone, faceZone. Only a subset of the functionality of expressions above is supported
  • surface. Calculations on sampledSurface. Only a subset of the functionality of expressions above is supported

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
    • surface
  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 that works with 1.x-releases of OpenFOAM can be downloaded using this command

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

the version that works with 2.0 can be found at

svn checkout https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_2.0/libraries/swak4Foam/

Further information is found in the README-file.

4.1 Development

The above SVN-repository is the current released version. The actual development version can be downloaded with Mercurial:

hg clone http://openfoam-extend.hg.sourceforge.net:8000/hgroot/openfoam-extend/swak4Foam

for the version that works with 2.0 you'll have to change to the appropriate branch with

hg update port_2.0.x

If you want to contribute (which is encouraged. Code or examples. Whatever you want) please contact Bgschaid and we'll set something up for write access

5 Other

5.1 Port to OF 2.0

The state of the port to OpenFOAM 2.0 and a way to download it can be found at this bug report

The port is formally finished, but the bug is left open for some time

5.2 Bugreports

Please report bugs here: [1]

5.3 History

5.3.1 2010-09-13

First Release

5.3.2 2010-12-18

New release Most important changes:

  • Parser for sampledSurfaces
  • Multiline variables
  • Two maintainance-scripts were added
  • Parsers using 'external variables' are now run-time selectable

5.3.3 2011-01-30

New release Changes (for details see README):

  • Library to deal with finiteArea in 1.6-ext
  • Bug-fixes

5.3.4 2011-04-20

New release

Changes (for details see README):

  • Stored variables
  • New utility funkyDoCalc
  • Calculation on sampled sets

5.3.5 2011-07-26

New release. Major change is support for OpenFOAM 2.0. For details see the README

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