TUT: simple tutorial with expression boundary conditions and setExprFields

This commit is contained in:
Mark Olesen 2019-12-03 12:34:50 +01:00
parent 2923daab65
commit 44304e07d6
18 changed files with 919 additions and 0 deletions

View File

@ -0,0 +1,55 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 1 0 0 0];
internalField uniform 300;
boundaryField
{
inlet
{
type outletMappedUniformInletHeatAddition;
outletPatch outlet1;
Q 5; // Heat addition in W
TMin 300;
TMax 500;
value $internalField;
}
outlet1
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}
outlet2
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}
defaultFaces
{
type zeroGradient;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
inlet
{
type pressureInletOutletVelocity;
value uniform (0 0 0);
}
outlet1
{
type inletOutlet;
inletValue uniform (0 0 0);
value uniform (0 0 0);
}
outlet2
{
type inletOutlet;
inletValue uniform (0 0 0);
value uniform (0 0 0);
}
defaultFaces
{
type fixedValue;
value uniform (0 0 0);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object alphat;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -1 0 0 0 0];
internalField uniform 1e-3;
boundaryField
{
inlet
{
type calculated;
value uniform 0;
}
outlet1
{
type calculated;
value uniform 0;
}
outlet2
{
type calculated;
value uniform 0;
}
defaultFaces
{
type compressible::alphatWallFunction;
value $internalField;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -3 0 0 0 0];
internalField uniform 200;
boundaryField
{
inlet
{
type turbulentMixingLengthDissipationRateInlet;
mixingLength 0.01; // 1cm - half channel height
value $internalField;
}
outlet1
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}
outlet2
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}
defaultFaces
{
type epsilonWallFunction;
value $internalField;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,51 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 1;
boundaryField
{
inlet
{
type turbulentIntensityKineticEnergyInlet;
intensity 0.05; // 5% turbulent intensity
value $internalField;
}
outlet1
{
type inletOutlet;
inletValue $internalField;
}
outlet2
{
type inletOutlet;
inletValue $internalField;
}
defaultFaces
{
type kqRWallFunction;
value $internalField;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,44 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object nuTilda;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
inlet
{
type zeroGradient;
}
outlet1
{
type zeroGradient;
}
outlet2
{
type zeroGradient;
}
defaultFaces
{
type zeroGradient;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
inlet
{
type calculated;
value uniform 0;
}
outlet1
{
type calculated;
value uniform 0;
}
outlet2
{
type calculated;
value uniform 0;
}
defaultFaces
{
type nutkWallFunction;
value uniform 0;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,71 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -2 0 0 0 0];
internalField uniform 1e5;
boundaryField
{
inlet
{
type uniformTotalPressure;
gamma 1.2;
p0 table
(
(0 1e5)
(1 1.4e5)
);
}
outlet1
{
type fixedValue;
value $internalField;
}
outlet1
{
type exprFixedValue;
value $internalField;
valueExpr "0.5*(pInlet + pOutlet2)";
variables
(
"pInlet{inlet} = weightAverage(p)"
"pOutlet2{outlet2} = p"
);
// debug true;
// debugScanner true;
// debugParser true;
}
outlet2
{
type fixedValue;
value $internalField;
}
defaultFaces
{
type zeroGradient;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,4 @@
15/8/8 Simple T-junction. Inlet on left, one outlet at bottom, one at top.
To test multiple outlets.
Enable debugScanner/debugParser for a verbose view of the parsing engine.

View File

@ -0,0 +1,22 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
viscousDissipation
{
type viscousDissipation;
enabled true;
}
// ************************************************************************* //

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object thermophysicalProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType
{
type hePsiThermo;
mixture pureMixture;
transport sutherland;
thermo hConst;
equationOfState perfectGas;
specie specie;
energy sensibleEnthalpy;
}
mixture
{
specie
{
molWeight 28.9;
}
thermodynamics
{
Cp 1007;
Hf 0;
}
transport
{
As 1.4792e-06;
Ts 116;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,30 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType RAS;
RAS
{
RASModel kEpsilon;
turbulence on;
printCoeffs on;
}
// ************************************************************************* //

View File

@ -0,0 +1,127 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// outlet1
// +-+
// | |
// | |
// | |
// | |
// +-----------+ |
// |inlet |
// +-----------+ |
// | |
// | |
// | |
// | |
// +-+
// outlet2
scale 1;
vertices
(
(0.0 -0.01 0) //0
(0.2 -0.01 0)
(0.2 0.01 0) //2
(0.0 0.01 0)
(0.22 -0.01 0) //4
(0.22 0.01 0)
(0.2 -0.21 0) //6
(0.22 -0.21 0)
(0.2 0.21 0) //8
(0.22 0.21 0)
// Z
(0.0 -0.01 0.02) //0
(0.2 -0.01 0.02)
(0.2 0.01 0.02) //2
(0.0 0.01 0.02)
(0.22 -0.01 0.02) //4
(0.22 0.01 0.02)
(0.2 -0.21 0.02) //6
(0.22 -0.21 0.02)
(0.2 0.21 0.02) //8
(0.22 0.21 0.02)
);
blocks
(
// inlet block
hex (0 1 2 3 10 11 12 13) (50 5 5) simpleGrading (1 1 1)
// central block
hex (1 4 5 2 11 14 15 12) (5 5 5) simpleGrading (1 1 1)
// bottom block
hex (6 7 4 1 16 17 14 11) (5 50 5) simpleGrading (1 1 1)
// top block
hex (2 5 9 8 12 15 19 18) (5 50 5) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(0 10 13 3)
);
}
outlet1
{
type patch;
faces
(
(6 7 17 16)
);
}
outlet2
{
type patch;
faces
(
(8 18 19 9)
);
}
defaultFaces
{
type wall;
faces ();
}
);
mergePatchPairs
(
);
// ************************************************************************* //

View File

@ -0,0 +1,52 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application rhoPimpleFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 1.0;
deltaT 0.001;
writeControl adjustable;
writeInterval 0.1;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
adjustTimeStep yes;
maxCo 3;
// ************************************************************************* //

View File

@ -0,0 +1,57 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
}
divSchemes
{
default none;
div(phi,U) Gauss limitedLinearV 1;
div(phi,k) Gauss limitedLinear 1;
div(phi,epsilon) Gauss limitedLinear 1;
div(phi,h) Gauss limitedLinear 1;
div(phi,R) Gauss limitedLinear 1;
div(R) Gauss linear;
div(phi,K) Gauss linear;
div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear;
}
laplacianSchemes
{
default Gauss linear corrected;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default corrected;
}
// ************************************************************************* //

View File

@ -0,0 +1,70 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver GAMG;
tolerance 1e-08;
relTol 0.01;
smoother GaussSeidel;
}
pFinal
{
solver GAMG;
tolerance 1e-08;
relTol 0;
smoother GaussSeidel;
}
"(rho|U|k|epsilon|h)"
{
solver smoothSolver;
smoother symGaussSeidel;
tolerance 1e-07;
relTol 0.05;
}
"(rho|U|k|epsilon|h)Final"
{
$U;
tolerance 1e-07;
relTol 0;
}
}
PIMPLE
{
momentumPredictor no;
transonic no;
nOuterCorrectors 1;
nCorrectors 5;
nNonOrthogonalCorrectors 0;
}
relaxationFactors
{
equations
{
".*" 1;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,32 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object setExprBoundaryFieldsDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
pattern
{
field T;
expressions
(
{
patch outlet2;
target something;
expression #{ (pos().x() < 1e-4 ? 60 : 120) #};
}
);
}
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object setExprFieldsDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
expressions
(
T
{
field T;
dimensions [0 0 0 1 0 0 0];
constants
{
centre (0.21 0 0.01);
}
variables
(
"radius = 0.1"
);
condition
#{
// Within the radius
(mag(pos() - $[(vector)constants.centre]) < radius)
// but only +ve y!
&& pos((pos() - $[(vector)constants.centre]).y()) > 0
#};
expression
#{
300
+ 200 * (1 - mag(pos() - $[(vector)constants.centre]) / radius)
#};
}
);
// ************************************************************************* //