[version 12][version 11][version 10][version 9][version 8][version 7][version 6]
6.4 Derived boundary conditions
There are numerous more complex boundary conditions derived from the basic conditions. For example, many complex conditions are derived from fixedValue, where the value is calculated by a function of other patch fields, time, geometric information, etc. Some other conditions derived from mixed/directionMixed switch between fixedValue and fixedGradient (usually with a zero gradient).
The available boundary conditions can be listed with foamToC using the -scalarBCs and -vectorBCs options, corresponding to boundary conditions for scalar fields and vector fields, respectively. For example, for scalar fields, boundary conditions are listed by
foamToC -scalarBCs
foamInfo totalPressure
6.4.1 The inlet/outlet condition
The inletOutlet condition is one derived from mixed, which switches between zeroGradient when the fluid flows out of the domain at a patch face, and fixedValue, when the fluid is flowing into the domain. For inflow, the inlet value is specified by an inletValue entry. A good example of its use can be seen in the damBreakLaminar tutorial, where it is applied to the phase fraction on the upper atmosphere boundary. Where there is outflow, the condition is well posed, where there is inflow, the phase fraction is fixed with a value of 0, corresponding to 100% air.
16 17dimensions []; 18 19internalField uniform 0; 20 21boundaryField 22{ 23 #includeEtc "caseDicts/setConstraintTypes" 24 25 wall 26 { 27 type zeroGradient; 28 } 29 30 atmosphere 31 { 32 type inletOutlet; 33 inletValue $internalField; 34 value $internalField; 35 } 36} 37 38 39// ************************************************************************* //
6.4.2 Entrainment boundary conditions
The combination of the totalPressure condition on pressure and pressureInletOutletVelocity on velocity is extremely common for patches where some inflow occurs and the inlet flow velocity is not known. The conditions are used on the atmosphere boundary in the damBreak tutorial, inlet conditions where only pressure is known, outlets where flow reversal may occur, and where flow in entrained, e.g. on boundaries surrounding a jet through a nozzle.
The idea behind this combination is that the condition is a standard combination in the case of outflow, but for inflow the normal velocity is allowed to find its own value. Under these circumstances, a rapid rise in velocity presents a risk of instability, but the rise is moderated by the reduction of inlet pressure, and hence driving pressure gradient, as the inflow velocity increases.
The totalPressure condition specifies:
(6.2) |
The entrainmentPressure condition also exists which is arguably more robust than totalPressure by using the normal component of velocity in the calculation for inflow, i.e.
(6.3) |
Solver applications which include buoyancy effects, though a gravitational force (per unit volume) source term, tend to solve for a pressure field , where the hydrostatic component is subtracted based on a height above some reference. For such solvers, e.g. interFoam, an equivalent prghTotalPressure condition is applied which specifies:
(6.4) |
The pressureInletOutletVelocity condition specifies zeroGradient at all times, except on the tangential component which is set to fixedValue for inflow, with the tangentialVelocity defaulting to 0.
The specification of these boundary conditions in the U and p_rgh files, in the damBreak case, are shown below.
16 17dimensions [0 1 -1 0 0 0 0]; 18 19internalField uniform (0 0 0); 20 21boundaryField 22{ 23 #includeEtc "caseDicts/setConstraintTypes" 24 25 wall 26 { 27 type noSlip; 28 } 29 30 atmosphere 31 { 32 type pressureInletOutletVelocity; 33 value $internalField; 34 } 35} 36 37 38// ************************************************************************* //
16 17dimensions [1 -1 -2 0 0 0 0]; 18 19internalField uniform 0; 20 21boundaryField 22{ 23 #includeEtc "caseDicts/setConstraintTypes" 24 25 wall 26 { 27 type fixedFluxPressure; 28 value $internalField; 29 } 30 31 atmosphere 32 { 33 type prghTotalPressure; 34 p0 $internalField; 35 } 36} 37 38 39// ************************************************************************* //
6.4.3 Fixed flux pressure
In the above example, it can be seen that all the wall boundaries use a boundary condition named fixedFluxPressure. This boundary condition is used for pressure in situations where zeroGradient is generally used, but where body forces such as gravity and surface tension are present in the solution equations. The condition adjusts the gradient accordingly.
6.4.4 Time-varying boundary conditions
There are several boundary conditions for which some input parameters are specified by a function of time (using Function1 functionality) class. The available functions from the Function1 can be listed by the following command.
find $FOAM_SRC/finiteVolume/fields/fvPatchFields -type f -name "*.H" |\
xargs grep -l Function1 | xargs dirname | sort
The Function1 is specified by a keyword following the uniformValue entry, followed by parameters that relate to the particular function. The Function1 options can be listed by foamToC by
foamToC -table scalarFunction1
foamToC -table scalarFunction1 | grep OpenFOAM
-
table: inline list of (time value) pairs; interpolates values linearly between times.
-
tableFile: as above, but with data supplied in a separate file.
-
polynomial: polynomial function using a list (coeff exponent) pairs.
-
scale: scales a given value function by a scalar scale function; both entries can be themselves Function1; scale function is often a ramp function (below), with value controlling the ramp value.
-
linearRamp, quadraticRamp, exponentialSqrRamp, halfCosineRamp, quarterCosineRamp and quarterSineRamp: monotonic ramp functions which ramp from 0 to 1 over specified duration.
-
reverseRamp: reverses the values of a ramp function, e.g. from 1 to 0.
Examples or a time-varying inlet for a scalar are shown below.
inlet { type uniformFixedValue; uniformValue constant 2; } inlet { type uniformFixedValue; uniformValue table ((0 0) (10 2)); } inlet { type uniformFixedValue; uniformValue polynomial ((1 0) (2 2)); // = 1*t^0 + 2*t^2 } inlet { type uniformFixedValue; uniformValue { type tableFile; format csv; nHeaderLine 4; // number of header lines refColumn 0; // time column index componentColumns (1); // data column index separator ","; // optional (defaults to ",") mergeSeparators no; // merge multiple separators file "dataTable.csv"; } } inlet { type uniformFixedValue; uniformValue { type square; frequency 10; amplitude 1; scale 2; // Scale factor for wave level 1; // Offset } } inlet { type uniformFixedValue; uniformValue { type sine; frequency 10; amplitude 1; scale 2; // Scale factor for wave level 1; // Offset } } input // ramp from 0 -> 2, from t = 0 -> 0.4 { type uniformFixedValue; uniformValue { type scale; scale linearRamp; start 0; duration 0.4; value 2; } } input // ramp from 2 -> 0, from t = 0 -> 0.4 { type uniformFixedValue; uniformValue { type scale; scale reverseRamp; ramp linearRamp; start 0; duration 0.4; value 2; } } inlet // pulse with value 2, from t = 0 -> 0.4 { type uniformFixedValue; uniformValue { type scale; scale squarePulse start 0; duration 0.4; value 2; } } inlet { type uniformFixedValue; uniformValue coded; name pulse; codeInclude #{ #include "mathematicalConstants.H" #}; code #{ return scalar ( 0.5*(1 - cos(constant::mathematical::twoPi*min(x/0.3, 1))) ); #}; }