functionObjects::age: add optinoal diffusion term and convergence control

to enable the calculation of the residence time for a fluid; mainly used in HVAC
analysis. E.g. residence time of air inside a ventilated room, see the new
tutorial roomResidenceTime.

Contributed by Tobias Holzmann
This commit is contained in:
Henry Weller
2019-10-08 16:14:38 +01:00
parent c8ab2a6e0c
commit a2a74cbb79
25 changed files with 1064 additions and 31 deletions

View File

@ -0,0 +1,43 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
walls
{
type noSlip;
}
inlet
{
type fixedValue;
value uniform (1.68 0 0);
}
outlet
{
type pressureInletOutletVelocity;
value uniform (0 0 0);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,45 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -3 0 0 0 0];
internalField uniform 0.23;
boundaryField
{
walls
{
type epsilonWallFunction;
value $internalField;
}
inlet
{
type turbulentMixingLengthDissipationRateInlet;
mixingLength 0.0168;
value $internalField;
}
outlet
{
type inletOutlet;
inletValue $internalField;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,45 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 8e-2;
boundaryField
{
walls
{
type kqRWallFunction;
value $internalField;
}
inlet
{
type turbulentIntensityKineticEnergyInlet;
intensity 0.14;
value $internalField;
}
outlet
{
type inletOutlet;
inletValue $internalField;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,44 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ 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
{
walls
{
type nutkWallFunction;
value uniform 0;
}
inlet
{
type calculated;
value uniform 0;
}
outlet
{
type calculated;
value uniform 0;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,42 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
walls
{
type zeroGradient;
}
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,11 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial clean functions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase
(cd validation && ./Allclean)
#------------------------------------------------------------------------------

View File

@ -0,0 +1,16 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh
runApplication simpleFoam
runApplication -s age simpleFoam -latestTime -postProcess -func age
runApplication -s probes1 postProcess -func probes1 -latestTime
runApplication -s probes2 postProcess -func probes2 -latestTime
runApplication -s flowRatePatch postProcess -func flowRatePatch -latestTime
(cd validation && ./Allrun $*)
#------------------------------------------------------------------------------

View File

@ -0,0 +1,23 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
// Air at 23 degC
nu [0 2 -1 0 0 0 0] 1.56225e-05;
// ************************************************************************* //

View File

@ -0,0 +1,30 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ 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,28 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
-------------------------------------------------------------------------------
Description
Solves a transport equation to determine the time taken for a particle to
convect from an inlet to the location in the flow.
This will output a field, age, with units of time. This field needs a
solver setting in fvSolution and a div(phi,age) scheme in fvSchemes.
Alternatively, a schemesField entry can be used to reuse settings from
another field.
The number of correctors, nCorr, determines how many times the solution is
repeated to iterate away any non-linearities in the choice of scheme. If
the divergence scheme is set to upwind, no corrections will be necessary.
\*---------------------------------------------------------------------------*/
type age;
libs ("libfieldFunctionObjects.so");
diffusion true;
// ************************************************************************* //

View File

@ -0,0 +1,240 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0) // 0
(0 0 2.05)
(0 1.65 2.05)
(0 1.65 0)
(3.8 0 0) // 4
(3.8 0 2.05)
(3.8 1.65 2.05)
(3.8 1.65 0)
(4 0 0) // 8
(4 0 2.05)
(4 1.65 2.05)
(4 1.65 0)
(4.2 0 0) // 12
(4.2 0 2.05)
(4.2 1.65 2.05)
(4.2 1.65 0)
(0 1.95 0) // 16
(0 1.95 2.05)
(3.8 1.95 0)
(3.8 1.95 2.05)
(4 1.95 0) // 20
(4 1.95 2.05)
(4.2 1.95 0)
(4.2 1.95 2.05)
(0 3.6 0) // 24
(0 3.6 2.05)
(3.8 3.6 0)
(3.8 3.6 2.05)
(4 3.6 0) // 28
(4 3.6 2.05)
(4.2 3.6 0)
(4.2 3.6 2.05)
(0 0 2.25) // 32
(0 1.65 2.25)
(3.8 0 2.25)
(3.8 1.65 2.25)
(4 0 2.25) // 36
(4 1.65 2.25)
(4.2 0 2.25)
(4.2 1.65 2.25)
(0 1.95 2.25) // 40
(3.8 1.95 2.25)
(4 1.95 2.25)
(4.2 1.95 2.25)
(0 3.6 2.25) // 44
(3.8 3.6 2.25)
(4 3.6 2.25)
(4.2 3.6 2.25)
(0 0 3) // 48
(0 1.65 3)
(3.8 0 3)
(3.8 1.65 3)
(4 0 3) // 52
(4 1.65 3)
(4.2 0 3)
(4.2 1.65 3)
(0 1.95 3) // 56
(0 3.6 3)
(3.8 1.95 3)
(3.8 3.6 3)
(4 1.95 3) // 60
(4 3.6 3)
(4.2 1.95 3)
(4.2 3.6 3)
);
blocks
(
hex (0 3 2 1 4 7 6 5)
(21 20 35)
simpleGrading (1 1 1)
hex (4 7 6 5 8 11 10 9)
(21 20 2)
simpleGrading (1 1 1)
hex (8 11 10 9 12 15 14 13)
(21 20 2)
simpleGrading (1 1 1)
hex (3 16 17 2 7 18 19 6)
(4 20 35)
simpleGrading (1 1 1)
hex (7 18 19 6 11 20 21 10)
(4 20 2)
simpleGrading (1 1 1)
hex (11 20 21 10 15 22 23 14)
(4 20 2)
simpleGrading (1 1 1)
hex (16 24 25 17 18 26 27 19)
(21 20 35)
simpleGrading (1 1 1)
hex (18 26 27 19 20 28 29 21)
(21 20 2)
simpleGrading (1 1 1)
hex (20 28 29 21 22 30 31 23)
(21 20 2)
simpleGrading (1 1 1)
hex (1 2 33 32 5 6 35 34)
(21 2 35)
simpleGrading (1 1 1)
hex (5 6 35 34 9 10 37 36)
(21 2 2)
simpleGrading (1 1 1)
hex (9 10 37 36 13 14 39 38)
(21 2 2)
simpleGrading (1 1 1)
hex (2 17 40 33 6 19 41 35)
(4 2 35)
simpleGrading (1 1 1)
hex (6 19 41 35 10 21 42 37)
(4 2 2)
simpleGrading (1 1 1)
hex (10 21 42 37 14 23 43 39)
(4 2 2)
simpleGrading (1 1 1)
hex (17 25 44 40 19 27 45 41)
(21 2 35)
simpleGrading (1 1 1)
hex (19 27 45 41 21 29 46 42)
(21 2 2)
simpleGrading (1 1 1)
hex (21 29 46 42 23 31 47 43)
(21 2 2)
simpleGrading (1 1 1)
hex (32 33 49 48 34 35 51 50)
(21 8 35)
simpleGrading (1 1 1)
hex (34 35 51 50 36 37 53 52)
(21 8 2)
simpleGrading (1 1 1)
hex (36 37 53 52 38 39 55 54)
(21 8 2)
simpleGrading (1 1 1)
hex (33 40 56 49 35 41 58 51)
(4 8 35)
simpleGrading (1 1 1)
hex (35 41 58 51 37 42 60 53)
(4 8 2)
simpleGrading (1 1 1)
hex (37 42 60 53 39 43 62 55)
(4 8 2)
simpleGrading (1 1 1)
hex (40 44 57 56 41 45 59 58)
(21 8 35)
simpleGrading (1 1 1)
hex (41 45 59 58 42 46 61 60)
(21 8 2)
simpleGrading (1 1 1)
hex (42 46 61 60 43 47 63 62)
(21 8 2)
simpleGrading (1 1 1)
);
defaultPatch
{
name walls;
type wall;
}
boundary
(
inlet
{
type patch;
faces
(
(2 17 40 33)
);
}
outlet
{
type patch;
faces
(
(51 58 60 53)
);
}
);
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application simpleFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 2000;
deltaT 1;
writeControl timeStep;
writeInterval 250;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
functions
{
#includeFunc residuals
}
// ************************************************************************* //

View File

@ -0,0 +1,19 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
-------------------------------------------------------------------------------
Description
Calculates the flow rate through a specified patch by summing the flux on
patch faces. For solvers where the flux is volumetric, the flow rate is
volumetric; where flux is mass flux, the flow rate is mass flow rate.
\*---------------------------------------------------------------------------*/
name inlet;
#includeEtc "caseDicts/postProcessing/flowRate/flowRatePatch.cfg"
// ************************************************************************* //

View File

@ -0,0 +1,60 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default steadyState;
}
gradSchemes
{
default Gauss linear;
}
divSchemes
{
default none;
div(phi,U) bounded Gauss upwind;
div(phi,k) bounded Gauss upwind;
div(phi,epsilon) bounded Gauss upwind;
div((nuEff*dev2(T(grad(U))))) Gauss linear;
div(phi,age) bounded Gauss upwind;
}
laplacianSchemes
{
default Gauss linear orthogonal;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default orthogonal;
}
wallDist
{
method meshWave;
}
// ************************************************************************* //

View File

@ -0,0 +1,72 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver GAMG;
tolerance 1e-08;
relTol 0.1;
smoother GaussSeidel;
}
"(U|k|epsilon)"
{
solver PBiCG;
preconditioner DILU;
tolerance 1e-08;
relTol 0.1;
}
age
{
$U;
relTol 0.001;
}
}
SIMPLE
{
consistent yes;
residualControl
{
p 1e-3;
U 1e-4;
"(k|epsilon)" 1e-4;
}
}
relaxationFactors
{
fields
{
p 1;
}
equations
{
U 0.95;
k 0.7;
epsilon 0.7;
age 1;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
-------------------------------------------------------------------------------
Description
Writes out values of fields from cells nearest to specified locations.
\*---------------------------------------------------------------------------*/
#includeEtc "caseDicts/postProcessing/probes/probes.cfg"
fields (age);
probeLocations
(
(1.13 1.8 0.0)
(1.13 1.8 0.1)
(1.13 1.8 0.2)
(1.13 1.8 0.3)
(1.13 1.8 0.4)
(1.13 1.8 0.5)
(1.13 1.8 0.6)
(1.13 1.8 0.7)
(1.13 1.8 0.8)
(1.13 1.8 0.9)
(1.13 1.8 1.0)
(1.13 1.8 1.1)
(1.13 1.8 1.2)
(1.13 1.8 1.3)
(1.13 1.8 1.4)
(1.13 1.8 1.5)
(1.13 1.8 1.6)
(1.13 1.8 1.7)
(1.13 1.8 1.8)
(1.13 1.8 1.9)
(1.13 1.8 2.1)
(1.13 1.8 2.2)
(1.13 1.8 2.3)
(1.13 1.8 2.4)
(1.13 1.8 2.5)
(1.13 1.8 2.6)
(1.13 1.8 2.7)
(1.13 1.8 2.8)
(1.13 1.8 2.9)
(1.13 1.8 3.0)
);
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
-------------------------------------------------------------------------------
Description
Writes out values of fields from cells nearest to specified locations.
\*---------------------------------------------------------------------------*/
#includeEtc "caseDicts/postProcessing/probes/probes.cfg"
fields (age);
probeLocations
(
(3.2 1.8 0.0)
(3.2 1.8 0.1)
(3.2 1.8 0.2)
(3.2 1.8 0.3)
(3.2 1.8 0.4)
(3.2 1.8 0.5)
(3.2 1.8 0.6)
(3.2 1.8 0.7)
(3.2 1.8 0.8)
(3.2 1.8 0.9)
(3.2 1.8 1.0)
(3.2 1.8 1.1)
(3.2 1.8 1.2)
(3.2 1.8 1.3)
(3.2 1.8 1.4)
(3.2 1.8 1.5)
(3.2 1.8 1.6)
(3.2 1.8 1.7)
(3.2 1.8 1.8)
(3.2 1.8 1.9)
(3.2 1.8 2.1)
(3.2 1.8 2.2)
(3.2 1.8 2.3)
(3.2 1.8 2.4)
(3.2 1.8 2.5)
(3.2 1.8 2.6)
(3.2 1.8 2.7)
(3.2 1.8 2.8)
(3.2 1.8 2.9)
(3.2 1.8 3.0)
);
// ************************************************************************* //

View File

@ -0,0 +1,2 @@
#!/bin/bash
rm -f positionsZ age* *.eps *_OF

View File

@ -0,0 +1,37 @@
#!/bin/bash
./Allclean
# ------ Pos 1 Evaluation
tail -n 1 ../postProcessing/probes1/*/age | xargs | sed 's/ /\n/g' | tail -n 30 > ageValues
head -n 30 ../postProcessing/probes1/*/age | cut -d' ' -f6 | cut -d')' -f1 > positionsZ
# Build dimless age value
V=45.36
Vdot=`cat ../postProcessing/flowRatePatch/0/surfaceFieldValue.dat | tail -n 1 | xargs | cut -d' ' -f2`
Vdot=`echo $Vdot | sed 's/e/*10^/'`
while IFS= read -r line
do
echo "scale=5; $line/($V/($Vdot*-1.))" | bc >> ageDimless1
done < "ageValues"
paste positionsZ ageDimless1 > Pos1_OF
# ------ Pos 2 Evaluation
tail -n 1 ../postProcessing/probes2/*/age | xargs | sed 's/ /\n/g' | tail -n 30 > ageValues
head -n 30 ../postProcessing/probes2/*/age | cut -d' ' -f6 | cut -d')' -f1 > positionsZ
# Build dimless age value
while IFS= read -r line
do
echo "scale=5; $line/($V/($Vdot*-1.))" | bc >> ageDimless2
done < "ageValues"
paste positionsZ ageDimless2 > Pos2_OF
# ------ Plot the results
gnuplot plot*
#------------------------------------------------------------------------------

View File

@ -0,0 +1,12 @@
# Bartak M. et al.: Experimental and numerical study of local mean age of air
# x = 1.13m | y = 1.8 m
# Data extracted from plots as the original data were not given
#
# Age [dimless] z coordinate Age [s] = Dimless * 45.36 / 0.1
# ---------------------------------------------------------------------
0.9999999999999998 0.18907723824317335 453.6
1.0135746606334840 0.99995497624997220 459.7
0.9773755656108594 1.09963755881227330 443.3
0.6425339366515836 2.00180095000112600 291.5
0.3981900452488687 2.09754395443596500 180.6
0.9773755656108594 2.82600571801625400 443.3

View File

@ -0,0 +1,10 @@
# Bartak M. et al.: Experimental and numerical study of local mean age of air
# x = 3.20m | y = 1.8 m
# Data extracted from plots as the original data were not given
#
# Age [dimless] z coordinate
# ---------------------------------------
0.9842696629213484 0.1782682512733449
1.0966292134831463 1.1052631578947367
0.7550561797752810 2.0984719864176570
1.0022471910112358 2.8268251273344650

View File

@ -0,0 +1,15 @@
#!/bin/gnuplot
#------------------------------------------------------------------------------
set grid
set title "Comparison at x =1.13 m, y = 1.8 m"
set xlabel "Dimensionless Age Quantity [-]"
set ylabel "z-coordinate [m]"
set xrange [0:2]
set yrange [0:3]
#------------------------------------------------------------------------------
set terminal postscript eps color enhanced "Helveicta,20"
set output 'Pos1_Comparison.eps'
plot \
'measurement_Pos1' using 1:2 w p pt 7 t 'Measurement', \
'Pos1_OF' using 2:1 w l t 'OpenFOAM'
#------------------------------------------------------------------------------

View File

@ -0,0 +1,15 @@
#!/bin/gnuplot
#------------------------------------------------------------------------------
set grid
set title "Comparison at x = 3.2 m, y = 1.8 m"
set xlabel "Dimensionless Age Quantity [-]"
set ylabel "z-coordinate [m]"
set xrange [0:2]
set yrange [0:3]
#------------------------------------------------------------------------------
set terminal postscript eps color enhanced "Helveicta,20"
set output 'Pos2_Comparison.eps'
plot \
'measurement_Pos2' using 1:2 w p pt 7 t 'Measurement', \
'Pos2_OF' using 2:1 w l t 'OpenFOAM'
#------------------------------------------------------------------------------