From a2a74cbb7921c2e0de3e5aa1f319e5913b65e771 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Tue, 8 Oct 2019 16:14:38 +0100 Subject: [PATCH] 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 --- src/functionObjects/field/age/age.C | 109 ++++++-- src/functionObjects/field/age/age.H | 24 +- .../simpleFoam/roomResidenceTime/0/U | 43 ++++ .../simpleFoam/roomResidenceTime/0/epsilon | 45 ++++ .../simpleFoam/roomResidenceTime/0/k | 45 ++++ .../simpleFoam/roomResidenceTime/0/nut | 44 ++++ .../simpleFoam/roomResidenceTime/0/p | 42 +++ .../simpleFoam/roomResidenceTime/Allclean | 11 + .../simpleFoam/roomResidenceTime/Allrun | 16 ++ .../constant/transportProperties | 23 ++ .../constant/turbulenceProperties | 30 +++ .../simpleFoam/roomResidenceTime/system/age | 28 ++ .../roomResidenceTime/system/blockMeshDict | 240 ++++++++++++++++++ .../roomResidenceTime/system/controlDict | 53 ++++ .../roomResidenceTime/system/flowRatePatch | 19 ++ .../roomResidenceTime/system/fvSchemes | 60 +++++ .../roomResidenceTime/system/fvSolution | 72 ++++++ .../roomResidenceTime/system/probes1 | 50 ++++ .../roomResidenceTime/system/probes2 | 50 ++++ .../roomResidenceTime/validation/Allclean | 2 + .../roomResidenceTime/validation/Allrun | 37 +++ .../validation/measurement_Pos1 | 12 + .../validation/measurement_Pos2 | 10 + .../validation/plotPos1Data.gplt | 15 ++ .../validation/plotPos2Data.gplt | 15 ++ 25 files changed, 1064 insertions(+), 31 deletions(-) create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/0/U create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/0/epsilon create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/0/k create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/0/nut create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/0/p create mode 100755 tutorials/incompressible/simpleFoam/roomResidenceTime/Allclean create mode 100755 tutorials/incompressible/simpleFoam/roomResidenceTime/Allrun create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/constant/transportProperties create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/constant/turbulenceProperties create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/system/age create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/system/blockMeshDict create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/system/controlDict create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/system/flowRatePatch create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/system/fvSchemes create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/system/fvSolution create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/system/probes1 create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/system/probes2 create mode 100755 tutorials/incompressible/simpleFoam/roomResidenceTime/validation/Allclean create mode 100755 tutorials/incompressible/simpleFoam/roomResidenceTime/validation/Allrun create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/validation/measurement_Pos1 create mode 100644 tutorials/incompressible/simpleFoam/roomResidenceTime/validation/measurement_Pos2 create mode 100755 tutorials/incompressible/simpleFoam/roomResidenceTime/validation/plotPos1Data.gplt create mode 100755 tutorials/incompressible/simpleFoam/roomResidenceTime/validation/plotPos2Data.gplt diff --git a/src/functionObjects/field/age/age.C b/src/functionObjects/field/age/age.C index cb90801cbd..0222e7816f 100644 --- a/src/functionObjects/field/age/age.C +++ b/src/functionObjects/field/age/age.C @@ -24,8 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "age.H" -#include "fvmDdt.H" #include "fvmDiv.H" +#include "fvmLaplacian.H" +#include "turbulenceModel.H" #include "inletOutletFvPatchField.H" #include "wallFvPatch.H" #include "zeroGradientFvPatchField.H" @@ -65,6 +66,26 @@ Foam::wordList Foam::functionObjects::age::patchTypes() const } +bool Foam::functionObjects::age::converged +( + const int nCorr, + const scalar initialResidual +) const +{ + if (initialResidual < tolerance_) + { + Info<< "Field " << typeName + << " converged in " << nCorr << " correctors\n" << endl; + + return true; + } + else + { + return false; + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::age::age @@ -74,12 +95,7 @@ Foam::functionObjects::age::age const dictionary& dict ) : - fvMeshFunctionObject(name, runTime, dict), - phiName_(), - rhoName_(), - nCorr_(0), - schemesField_() - + fvMeshFunctionObject(name, runTime, dict) { read(dict); } @@ -97,10 +113,10 @@ bool Foam::functionObjects::age::read(const dictionary& dict) { phiName_ = dict.lookupOrDefault("phi", "phi"); rhoName_ = dict.lookupOrDefault("rho", "rho"); - - dict.readIfPresent("nCorr", nCorr_); - + nCorr_ = dict.lookupOrDefault("nCorr", 5); schemesField_ = dict.lookupOrDefault("schemesField", typeName); + diffusion_ = dict.lookupOrDefault("diffusion", false); + tolerance_ = dict.lookupOrDefault("tolerance", 1e-5); return true; } @@ -114,7 +130,7 @@ bool Foam::functionObjects::age::execute() bool Foam::functionObjects::age::write() { - volScalarField t + volScalarField age ( IOobject ( @@ -152,36 +168,83 @@ bool Foam::functionObjects::age::write() const volScalarField& rho = mesh_.lookupObject(rhoName_); - for (label i = 0; i <= nCorr_; ++ i) + tmp tmuEff; + word laplacianScheme; + + if (diffusion_) { - fvScalarMatrix tEqn + tmuEff = + mesh_.lookupObject + ( + turbulenceModel::propertiesName + ).muEff(); + + laplacianScheme = + "laplacian(" + tmuEff().name() + ',' + schemesField_ + ")"; + } + + for (int i=0; i<=nCorr_; i++) + { + fvScalarMatrix ageEqn ( - fvm::div(phi, t, divScheme) == rho + fvm::div(phi, age, divScheme) == rho ); - tEqn.relax(relaxCoeff); + if (diffusion_) + { + ageEqn -= fvm::laplacian(tmuEff(), age, laplacianScheme); + } - tEqn.solve(schemesField_); + ageEqn.relax(relaxCoeff); + + if (converged(i, ageEqn.solve(schemesField_).initialResidual())) + { + break; + }; } } else { - for (label i = 0; i <= nCorr_; ++ i) + tmp tnuEff; + word laplacianScheme; + + if (diffusion_) { - fvScalarMatrix tEqn + tnuEff = + mesh_.lookupObject + ( + turbulenceModel::propertiesName + ).nuEff(); + + laplacianScheme = + "laplacian(" + tnuEff().name() + ',' + schemesField_ + ")"; + } + + for (int i=0; i<=nCorr_; i++) + { + fvScalarMatrix ageEqn ( - fvm::div(phi, t, divScheme) == dimensionedScalar(1) + fvm::div(phi, age, divScheme) == dimensionedScalar(1) ); - tEqn.relax(relaxCoeff); + if (diffusion_) + { + ageEqn -= fvm::laplacian(tnuEff(), age, laplacianScheme); + } - tEqn.solve(schemesField_); + ageEqn.relax(relaxCoeff); + + if (converged(i, ageEqn.solve(schemesField_).initialResidual())) + { + break; + } } } - Info<< "Min/max age:" << min(t).value() << ' ' << max(t).value() << endl; + Info<< "Min/max age:" << min(age).value() + << ' ' << max(age).value() << endl; - t.write(); + age.write(); return true; } diff --git a/src/functionObjects/field/age/age.H b/src/functionObjects/field/age/age.H index 9b59641389..f8a5088efe 100644 --- a/src/functionObjects/field/age/age.H +++ b/src/functionObjects/field/age/age.H @@ -40,12 +40,14 @@ Description Usage \table - Property | Description | Required | Default value - phi | The name of the flux field | no | phi - rho | The name of the density field | no | rho - nCorr | The number of correctors | no | 0 + Property | Description | Required | Default value + phi | The name of the flux field | no | phi + rho | The name of the density field | no | rho + nCorr | The maximum number of correctors | no | 5 schemesField | The name of the field from which schemes are taken | \\ no | age + diffusion | Switch to turn on/off the diffusion term | no | off + tolerance | Solver residual control | no | 1e-5 \endtable \verbatim @@ -57,9 +59,6 @@ Usage writeControl writeTime; writeInterval 1; - phi phi; - rho rho; - nCorr 10; schemesField k; } \endverbatim @@ -99,17 +98,26 @@ class age word rhoName_; //- Number of corrections - label nCorr_; + int nCorr_; //- Name of field from which schemes are taken word schemesField_; + //- Switch to turn on/off the diffusion term + Switch diffusion_; + + //- Convergence tolerance + scalar tolerance_; + // Private Member Functions //- The list of patch types for the age field wordList patchTypes() const; + //- Check convergence + bool converged(const int nCorr, const scalar initialResidual) const; + public: diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/0/U b/tutorials/incompressible/simpleFoam/roomResidenceTime/0/U new file mode 100644 index 0000000000..58f7d1e4de --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/0/U @@ -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); + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/0/epsilon b/tutorials/incompressible/simpleFoam/roomResidenceTime/0/epsilon new file mode 100644 index 0000000000..54ccea40e8 --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/0/epsilon @@ -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; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/0/k b/tutorials/incompressible/simpleFoam/roomResidenceTime/0/k new file mode 100644 index 0000000000..341479b846 --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/0/k @@ -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; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/0/nut b/tutorials/incompressible/simpleFoam/roomResidenceTime/0/nut new file mode 100644 index 0000000000..36e6610825 --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/0/nut @@ -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; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/0/p b/tutorials/incompressible/simpleFoam/roomResidenceTime/0/p new file mode 100644 index 0000000000..535966aaec --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/0/p @@ -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; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/Allclean b/tutorials/incompressible/simpleFoam/roomResidenceTime/Allclean new file mode 100755 index 0000000000..5cf60b8b16 --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/Allclean @@ -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) + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/Allrun b/tutorials/incompressible/simpleFoam/roomResidenceTime/Allrun new file mode 100755 index 0000000000..9344689094 --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/Allrun @@ -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 $*) + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/constant/transportProperties b/tutorials/incompressible/simpleFoam/roomResidenceTime/constant/transportProperties new file mode 100644 index 0000000000..637921a6f7 --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/constant/transportProperties @@ -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; + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/constant/turbulenceProperties b/tutorials/incompressible/simpleFoam/roomResidenceTime/constant/turbulenceProperties new file mode 100644 index 0000000000..a652d98461 --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/constant/turbulenceProperties @@ -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; +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/system/age b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/age new file mode 100644 index 0000000000..605ae78f7e --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/age @@ -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; + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/system/blockMeshDict b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/blockMeshDict new file mode 100644 index 0000000000..54c1eb79f1 --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/blockMeshDict @@ -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) + ); + } +); + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/system/controlDict b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/controlDict new file mode 100644 index 0000000000..3444f311cf --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/controlDict @@ -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 +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/system/flowRatePatch b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/flowRatePatch new file mode 100644 index 0000000000..d1e8dae85c --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/flowRatePatch @@ -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" + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/system/fvSchemes b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/fvSchemes new file mode 100644 index 0000000000..7ccfdb31be --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/fvSchemes @@ -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; +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/system/fvSolution b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/fvSolution new file mode 100644 index 0000000000..76aa352c48 --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/fvSolution @@ -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; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/system/probes1 b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/probes1 new file mode 100644 index 0000000000..0604c87225 --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/probes1 @@ -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) +); + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/system/probes2 b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/probes2 new file mode 100644 index 0000000000..c66ef5deaf --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/system/probes2 @@ -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) +); + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/Allclean b/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/Allclean new file mode 100755 index 0000000000..23c5821e9c --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/Allclean @@ -0,0 +1,2 @@ +#!/bin/bash +rm -f positionsZ age* *.eps *_OF diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/Allrun b/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/Allrun new file mode 100755 index 0000000000..53d63276bf --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/Allrun @@ -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* + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/measurement_Pos1 b/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/measurement_Pos1 new file mode 100644 index 0000000000..30bab60c3d --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/measurement_Pos1 @@ -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 diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/measurement_Pos2 b/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/measurement_Pos2 new file mode 100644 index 0000000000..4fed34dbce --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/measurement_Pos2 @@ -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 diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/plotPos1Data.gplt b/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/plotPos1Data.gplt new file mode 100755 index 0000000000..536beefcd1 --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/plotPos1Data.gplt @@ -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' +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/plotPos2Data.gplt b/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/plotPos2Data.gplt new file mode 100755 index 0000000000..18e0e553b0 --- /dev/null +++ b/tutorials/incompressible/simpleFoam/roomResidenceTime/validation/plotPos2Data.gplt @@ -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' +#------------------------------------------------------------------------------