(Added a simple new Boundary Condition) |
m (→Technical) |
||
Line 167: | Line 167: | ||
* the BC only works for <tt>fvPatchFields</tt> but can "read" point and face-fields too | * the BC only works for <tt>fvPatchFields</tt> but can "read" point and face-fields too | ||
+ | |||
+ | === Other === | ||
+ | |||
+ | The parser-part can be used in other boundary conditions (that are not covered by the <tt>mixed</tt>-BC) | ||
=== Known Bugs === | === Known Bugs === |
Revision as of 23:01, 19 February 2009
Contents
1 Short description
A library that introduces a boundary-condition groovyBC. This boundary condition is basically a mixed-BC where value, gradient and valueFraction are specified as expressions instead as fields.
It can be used to set non-uniform boundary-conditions without programming.
This library is provided as-is and is a permanent Beta-Version (but it works fine for me, if it doesn't for you: tell me about it and I'll see what the problem is)
1.1 Words of warning
This library can save you the work to program your own boundary-conditions, but
- you should be familiar with the C++ expression syntax
- it makes it easier to 'shoot yourself in the foot' (do stupid things)
- especially for large cases a custom-made library might be more efficient
(it's like a Swiss Army Knife: useful for a lot of things, but not necessarily the best tool for these tasks)
2 Usage
2.1 Compilation and installation
Just do
wmake libso
in the directory of the sources. The library will be compiled and installed in a place (%FOAM_USER_LIBBIN) where it is usable
2.2 Additions to controlDict
A function object is activated by adding an entry like this to the system/controlDict of a case:
libs ( "libgroovyBC.so" ) ;
If you are experiencing problems with paraFoam try this combination.
libs ( "libOpenFOAM.so" "libgroovyBC.so" ) ;
2.3 Usage of the boundary condition
Just set the type of a patch to groovyBC
2.4 Parameters in the patch
- valueExpression
- String with the value to be used if a Dirichlet-condition is needed. Defaults to zero
- gradientExpression
- String with the gradient to be used if a Neumann conditon is needed. Defaults to zero
- fractionExpression
- Determines whether the face is Dirichlet (1) or Neumann (0). Defaults to 1
- variables
- List with temporary variables separated by a semicolon. May make the writing of expressions shorter. Defaults to empty. Names defined here "shadow" fields of the same name
- timelines
- List with subdictionaries that specify interpolation tables over time. See the original timeVaryingUniform-condition. Currently only scalars are allowed. The parameter name specifies the name under which this may be accessed. The name "shadows" fields of the same name
3 Expression syntax
The most complete documentation of the expression syntax is the source file for the Bison-grammar (*.yy and *.ll). Sorry.
These C++ operators are implemented:
- +,-,*,/
- Arithmetic operators. Can be used for vectors and scalars (only if useful. For instance: vectors can't be added to scalars)
- %
- A modulo-operator. Somehow differently defined from the standard C++ %-operator: the value of % is (not - if you don't understand what I mean, please test for yourself - for most applications of this operator this is in my opinion the more practical implementation)
- &,^
- The vector operators as defined by OpenFOAM
- <,>,<=,>=,!=,==
- Comparison operators (only defined for scalars)
- &&,||
- Logical Operators
- Conditional operator
- The conditional operator ( test ? val1 : val2) is defined for scalars and vectors
Operator precedence should be the same as for C++.
All the fields that are defined on the patch can be used. If the field is also the field that this is a BC for the old value is used.
These pseudo-variables are defined:
- pi
- Guess ;)
These functions are defined:
- pow,log,exp,sqr,sqrt,sin,cos,tan
- Only defined for scalars
- mag
- defined for scalars and vectors
- min,max
- minimum and maximum of a scalar field
- sum
- sum of the values for a scalar field
These pseudo-functions are defined:
- toPoint
- Takes a scalar (or vector) field defined on the faces and interpolates it to the points
- toFace
- Takes a scalar (or vector) field defined on the points and interpolates it to the faces
- pos
- Vector field with the face-centers
- pts
- Vector field with the vertices
- normal
- Vector field with the face normals
- Sf
- field with the surface vectors (mag will give you the area)
- rand
- Scalars-field with random numbers from [0,1]
- randNormal
- Random-number scalar field that is Gauss-distributed
- deltaT
- a field that returns the time-step
- time
- a field that returns the current time
Advanced functions you're propably not going to need are:
- Cn
- neighbour cell centers of the patch
- delta
- Return patch weighting factors
- weights
- Return cell-centre to face-centre vector
Functions that need another field are:
- snGrad
- Gradient of that field
- internalField
- internal values of that field
- neighbourField
- neighbour values for a coupled patch
4 Usage Examples
TODO: Users. Please feel free to include examples here
4.1 Demo-Cases
There are three demo-cases include in the repository in a folder Demos with three demo cases. All of these cases only require a blockMesh.
Don't try to find experimental results for these cases. They are what the name of the folder says: Demos
The three cases are
4.1.1 pulsedPitzDaily
To be run with oodles. Runs the pitzDaily-case with a parabolic inlet condition that pulsates
inlet { type groovyBC; variables "yp=pts().y;minY=toFace(min(yp));maxY=toFace(max(yp));para=-(maxY-pos().y)*(pos().y-minY)/(0.25*pow(maxY-minY,2))*normal();"; valueExpression "10*(1+0.5*sin(500*time()))*para"; value uniform (10 0 0); }
on the outlet the regular inletOutlet-BC is emulated (just as a demonstration)
outlet { type groovyBC; valueExpression "vector(0,0,0)"; gradientExpression "vector(0,0,0)"; fractionExpression "(phi > 0) ? 0 : 1"; value uniform (0 0 0); }
4.1.2 wobbler
A solidDisplacementFoam case where a bar that is fixed on one side is pushed according to a predefined timeline on a fraction of the boundary (the rest is zero gradient). On the relevant patch the boundary conditon for D is
forced { type groovyBC; value uniform (0 0 0); // valueExpression "vector(0,0.1*sin(time()),0)"; timelines ( { name impulse; outOfBounds clamp; fileName "$FOAM_CASE/impulse.data"; } ); valueExpression "-impulse*normal()"; gradientExpression "vector(0,0,0)"; fractionExpression "(time()<5) ? ((pos().x>0.45 && pos().x<0.55) ? 1 : 0) : 0"; }
4.1.3 circulatingSplash
A interDyMFoam-case that crashes halfway through the calculation (but looks quite nice until then). Whoever wants to fix that case is welcome to do so
gamma is set on top on a small circular part that moves around during time:
atmosphere { type groovyBC; variables "r1=0.25*toFace(max(pts().x)-min(pts().x));r2=r1*0.2*(1-0.5*cos(54*time()));"; valueExpression "(sqrt(pow(pos().x-r1*sin(10*time()),2)+pow(pos().z-r1*cos(15*time()),2))<r2) ? 1 : 0"; value uniform 0; }
The Velocity is set depending on gamma:
atmosphere { type groovyBC; valueExpression "-(gamma+internalField(gamma))*0.5*normal()"; value uniform (0 0 0); }
5 Technical
- the BC only works for fvPatchFields but can "read" point and face-fields too
5.1 Other
The parser-part can be used in other boundary conditions (that are not covered by the mixed-BC)
5.2 Known Bugs
This utility is still under development. Currently there are no known known bugs (but propably some unknown ones)
6 Download
The most recent version of the sources can always be downloaded via Subversion:
svn checkout https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.5/libraries/groovyBC
7 Plans
- allow expressions for tensors
- allow "permanent" variables
- implement the BC for point and face-fields
8 History
- 2009-02-19: Initial upload
--Bgschaid 23:50, 19 February 2009 (CET)