From 454e609fbca000a103c8405eda7109ea93bfedde Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 6 Nov 2017 09:03:42 -0800 Subject: [PATCH 1/8] ENH: Adding momemtum predictor to chtSimpleFoam --- .../chtMultiRegionSimpleFoam/fluid/UEqn.H | 25 +++++++++++-------- .../readFluidMultiRegionSIMPLEControls.H | 3 +++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/UEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/UEqn.H index ed0402c2d0..f9712b548e 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/UEqn.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/UEqn.H @@ -16,17 +16,20 @@ fvOptions.constrain(UEqn); - solve - ( - UEqn - == - fvc::reconstruct + if (momentumPredictor) + { + solve ( + UEqn + == + fvc::reconstruct ( - - ghf*fvc::snGrad(rho) - - fvc::snGrad(p_rgh) - )*mesh.magSf() - ) - ); + ( + - ghf*fvc::snGrad(rho) + - fvc::snGrad(p_rgh) + )*mesh.magSf() + ) + ); - fvOptions.correct(U); + fvOptions.correct(U); + } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H index 66fd738d7a..3ce2a2b7b4 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H @@ -2,3 +2,6 @@ const int nNonOrthCorr = simple.lookupOrDefault("nNonOrthogonalCorrectors", 0); + + const bool momentumPredictor = + simple.lookupOrDefault("momentumPredictor", true); From 07e662a0efe878e7536c09c11032d51fad3dc7d4 Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 6 Nov 2017 09:04:15 -0800 Subject: [PATCH 2/8] BUG: Correcting adimensional formulation for fanPressureFvPatchScalarField --- .../derived/fanPressure/fanPressureFvPatchScalarField.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C index 9719903efc..c76ee572bc 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C @@ -181,7 +181,7 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs() { // Create an adimensional flow rate volFlowRate = - 120.0*volFlowRate/pow3(constant::mathematical::pi)/pow3(dm_); + 120.0*volFlowRate/pow3(constant::mathematical::pi)/pow3(dm_)/rpm_; } // Pressure drop for this flow rate @@ -190,7 +190,7 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs() if (nonDimensional_) { // Convert the adimensional deltap from curve into deltaP - pdFan = pdFan*pow4(constant::mathematical::pi)*rpm_*sqr(dm_)/1800; + pdFan = pdFan*pow4(constant::mathematical::pi)*sqr(dm_*rpm_)/1800; } totalPressureFvPatchScalarField::updateCoeffs From 69238a9e14315b0389ae64515ec42965e7d25362 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 7 Nov 2017 12:10:47 +0000 Subject: [PATCH 3/8] BUG: steadyStateDdtSchems - corrected oriented state of return fields for *Corr functions. Fixes #634 --- .../steadyStateDdtScheme.C | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/steadyStateDdtScheme/steadyStateDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/steadyStateDdtScheme/steadyStateDdtScheme.C index 790d189bc3..b90b00aa7b 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/steadyStateDdtScheme/steadyStateDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/steadyStateDdtScheme/steadyStateDdtScheme.C @@ -280,7 +280,7 @@ steadyStateDdtScheme::fvcDdtUfCorr const GeometricField& Uf ) { - return tmp + tmp tCorr ( new fluxFieldType ( @@ -299,6 +299,10 @@ steadyStateDdtScheme::fvcDdtUfCorr ) ) ); + + tCorr.ref().setOriented(); + + return tCorr; } @@ -310,7 +314,7 @@ steadyStateDdtScheme::fvcDdtPhiCorr const fluxFieldType& phi ) { - return tmp + tmp tCorr ( new fluxFieldType ( @@ -329,6 +333,10 @@ steadyStateDdtScheme::fvcDdtPhiCorr ) ) ); + + tCorr.ref().setOriented(); + + return tCorr; } @@ -341,7 +349,7 @@ steadyStateDdtScheme::fvcDdtUfCorr const GeometricField& Uf ) { - return tmp + tmp tCorr ( new fluxFieldType ( @@ -362,6 +370,10 @@ steadyStateDdtScheme::fvcDdtUfCorr ) ) ); + + tCorr.ref().setOriented(); + + return tCorr; } @@ -374,7 +386,7 @@ steadyStateDdtScheme::fvcDdtPhiCorr const fluxFieldType& phi ) { - return tmp + tmp tCorr ( new fluxFieldType ( @@ -395,6 +407,10 @@ steadyStateDdtScheme::fvcDdtPhiCorr ) ) ); + + tCorr.ref().setOriented(); + + return tCorr; } From 37d92d071491f3ab9b39650fde82f5f4c4169936 Mon Sep 17 00:00:00 2001 From: sergio Date: Wed, 15 Nov 2017 12:54:09 -0800 Subject: [PATCH 4/8] ENH: adding non-dimensional option to fanFvPatchField.C --- .../derived/fan/fanFvPatchField.C | 41 +++++++++++++++---- .../derived/fan/fanFvPatchField.H | 34 ++++++++++++++- .../derived/fan/fanFvPatchFields.C | 29 +++++++++++-- 3 files changed, 93 insertions(+), 11 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C index e22d979213..80772e86a0 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,7 +49,10 @@ Foam::fanFvPatchField::fanFvPatchField uniformJumpFvPatchField(p, iF), phiName_("phi"), rhoName_("rho"), - uniformJump_(false) + uniformJump_(false), + nonDimensional_(false), + rpm_(0.0), + dm_(0.0) {} @@ -64,8 +67,17 @@ Foam::fanFvPatchField::fanFvPatchField uniformJumpFvPatchField(p, iF, dict), phiName_(dict.lookupOrDefault("phi", "phi")), rhoName_(dict.lookupOrDefault("rho", "rho")), - uniformJump_(dict.lookupOrDefault("uniformJump", false)) -{} + uniformJump_(dict.lookupOrDefault("uniformJump", false)), + nonDimensional_(dict.lookupOrDefault("nonDimensional", false)), + rpm_(dict.lookupOrDefault("rpm", 0.0)), + dm_(dict.lookupOrDefault("dm", 0.0)) +{ + if (nonDimensional_) + { + dict.lookup("rpm") >> rpm_; + dict.lookup("dm") >> dm_; + } +} template @@ -80,7 +92,10 @@ Foam::fanFvPatchField::fanFvPatchField uniformJumpFvPatchField(ptf, p, iF, mapper), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_), - uniformJump_(ptf.uniformJump_) + uniformJump_(ptf.uniformJump_), + nonDimensional_(ptf.nonDimensional_), + rpm_(ptf.rpm_), + dm_(ptf.dm_) {} @@ -93,7 +108,10 @@ Foam::fanFvPatchField::fanFvPatchField uniformJumpFvPatchField(ptf), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_), - uniformJump_(ptf.uniformJump_) + uniformJump_(ptf.uniformJump_), + nonDimensional_(ptf.nonDimensional_), + rpm_(ptf.rpm_), + dm_(ptf.dm_) {} @@ -107,7 +125,10 @@ Foam::fanFvPatchField::fanFvPatchField uniformJumpFvPatchField(ptf, iF), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_), - uniformJump_(ptf.uniformJump_) + uniformJump_(ptf.uniformJump_), + nonDimensional_(ptf.nonDimensional_), + rpm_(ptf.rpm_), + dm_(ptf.dm_) {} @@ -138,6 +159,12 @@ void Foam::fanFvPatchField::write(Ostream& os) const ( os, "uniformJump", false, uniformJump_ ); + this->template writeEntryIfDifferent + ( + os, "nonDimensional", false, nonDimensional_ + ); + this->template writeEntryIfDifferent(os, "rpm", 0, rpm_); + this->template writeEntryIfDifferent(os, "dm", 0, dm_); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H index 567c3a29f5..975da7ab2e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,6 +34,24 @@ Description The jump is specified as a \c Function1 type, to enable the use of, e.g. contant, polynomial, table values. + The switch nonDimensional can be used for a non-dimensional table. It needs + inputs rpm and dm of the fan. It should be used with uniformJump true. + + The nonDimensional flux for the table is calculate as : + + phi = 4.0*mDot/(rho*sqr(PI)*dm^3*omega) + where: + dm is the mean diameter. + omega is rad/sec. + + The nonDimensinal pressure : + + Psi = 2 deltaP/(rho*(sqr(PI*omega*dm))) + where: + deltaP is the pressure drop + + The non-dimensional table should be given as Psi = F(phi). + Usage \table Property | Description | Required | Default value @@ -43,6 +61,9 @@ Usage rho | density field name | no | none uniformJump | applies a uniform pressure based on the averaged velocity | no | false + nonDimensional | uses non-dimensional table | no | false + rpm | fan rpm for non-dimensional table | no | 0.0 + dm | mean diameter for non-dimensional table | no | 0.0 \endtable Example of the boundary condition specification: @@ -114,6 +135,17 @@ class fanFvPatchField //- Uniform pressure drop bool uniformJump_; + //- Swtich for using non-dimensional curve + Switch nonDimensional_; + + // Parameters for non-dimensional table + + //- Fan rpm + scalar rpm_; + + //- Fan mean diameter + scalar dm_; + // Private Member Functions diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C index 51ad29066f..bfc39c9197 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,6 +48,15 @@ void Foam::fanFvPatchField::calcFanJump() { scalar area = gSum(patch().magSf()); Un = gSum(Un*patch().magSf())/area; + + if (nonDimensional_) + { + // Create an adimensional volumetric flow rate + Un = + 120.0*Un/pow3(constant::mathematical::pi) + * patch().magSf() + / pow3(dm_); + } } if (phi.dimensions() == dimDensity*dimVelocity*dimArea) @@ -55,7 +64,18 @@ void Foam::fanFvPatchField::calcFanJump() Un /= patch().lookupPatchField(rhoName_); } - this->jump_ = max(this->jumpTable_->value(Un), scalar(0)); + if (nonDimensional_) + { + scalarField deltap = this->jumpTable_->value(Un); + // Convert adimensional deltap from curve into deltaP + scalarField pdFan = + deltap*pow4(constant::mathematical::pi)*rpm_*sqr(dm_)/1800; + this->jump_ = max(pdFan, scalar(0)); + } + else + { + this->jump_ = max(this->jumpTable_->value(Un), scalar(0)); + } } } @@ -73,7 +93,10 @@ Foam::fanFvPatchField::fanFvPatchField uniformJumpFvPatchField(p, iF), phiName_(dict.lookupOrDefault("phi", "phi")), rhoName_(dict.lookupOrDefault("rho", "rho")), - uniformJump_(dict.lookupOrDefault("uniformJump", false)) + uniformJump_(dict.lookupOrDefault("uniformJump", false)), + nonDimensional_(dict.lookupOrDefault("nonDimensional", false)), + rpm_(dict.lookupOrDefault("rpm", 0.0)), + dm_(dict.lookupOrDefault("dm", 0.0)) { if (this->cyclicPatch().owner()) { From 93587afefc2ec98bb8f25c505e0d86f589fee9d2 Mon Sep 17 00:00:00 2001 From: sergio Date: Wed, 15 Nov 2017 12:58:58 -0800 Subject: [PATCH 5/8] ENH: Avoidding 0/0 conflict in externalCoupledTemperatureMixed increaging the zero order of denomitaror --- .../externalCoupledTemperatureMixedFvPatchScalarField.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C b/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C index 70128b8800..8961922b4b 100644 --- a/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C +++ b/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -196,7 +196,7 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeData const scalarField Tc(patchInternalField()); // Heat transfer coefficient [W/m2/K] - const scalarField htc(qDot/(Tp - Tc + ROOTVSMALL)); + const scalarField htc(qDot/(Tp - Tc + 1e-3)); const Field& magSf(this->patch().magSf()); From d6b3595fe8a32bbe9cc58e46c26499deb25099f0 Mon Sep 17 00:00:00 2001 From: sergio Date: Thu, 16 Nov 2017 11:01:54 -0800 Subject: [PATCH 6/8] BUG: Correcting expression for adimensional pressure drop table for fanFvPatchField --- .../fields/fvPatchFields/derived/fan/fanFvPatchFields.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C index bfc39c9197..320804a17d 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C @@ -55,7 +55,7 @@ void Foam::fanFvPatchField::calcFanJump() Un = 120.0*Un/pow3(constant::mathematical::pi) * patch().magSf() - / pow3(dm_); + / pow3(dm_)/rpm_; } } @@ -69,7 +69,7 @@ void Foam::fanFvPatchField::calcFanJump() scalarField deltap = this->jumpTable_->value(Un); // Convert adimensional deltap from curve into deltaP scalarField pdFan = - deltap*pow4(constant::mathematical::pi)*rpm_*sqr(dm_)/1800; + deltap*pow4(constant::mathematical::pi)*sqr(dm_*rpm_)/1800; this->jump_ = max(pdFan, scalar(0)); } else From e0f397d863f5b78791b567b05de3ef13a048baec Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Thu, 30 Nov 2017 08:36:07 +0000 Subject: [PATCH 7/8] BUG: ensightSurfaceReader - corrected initial list sizing --- .../readers/ensight/ensightSurfaceReaderTemplates.C | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReaderTemplates.C b/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReaderTemplates.C index df6f466390..efcd6b6f97 100644 --- a/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReaderTemplates.C +++ b/src/sampling/sampledSurface/readers/ensight/ensightSurfaceReaderTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2015-2017 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -75,7 +75,7 @@ Foam::tmp> Foam::ensightSurfaceReader::readField std::ostringstream oss; label nMask = 0; - for (size_t chari = 0; chari < fieldFileName.size(); chari++) + for (size_t chari = 0; chari < fieldFileName.size(); ++chari) { if (fieldFileName[chari] == '*') { @@ -130,7 +130,7 @@ Foam::tmp> Foam::ensightSurfaceReader::readField label n = surfPtr_->size(); forAll(values, cmptI) { - values.setSize(n); + values[cmptI].setCapacity(n); } // Read data file using schema generated while reading the surface From 1af512ae5199ccbf3bd3b7499dd9fb0ebdee96d7 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 5 Dec 2017 11:43:09 +0000 Subject: [PATCH 8/8] ENH: Added divergence scheme test case --- .../schemes/divergenceExample/0/T | 51 +++++++++++ .../schemes/divergenceExample/0/U | 51 +++++++++++ .../schemes/divergenceExample/Allrun | 21 +++++ .../schemes/divergenceExample/README | 17 ++++ .../constant/transportProperties | 21 +++++ .../divergenceExample/system/blockMeshDict | 89 +++++++++++++++++++ .../divergenceExample/system/controlDict | 74 +++++++++++++++ .../divergenceExample/system/fvSchemes | 50 +++++++++++ .../system/fvSchemes.template | 50 +++++++++++ .../divergenceExample/system/fvSolution | 37 ++++++++ .../divergenceExample/system/schemesToTest | 14 +++ 11 files changed, 475 insertions(+) create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/0/T create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/0/U create mode 100755 tutorials/verificationAndValidation/schemes/divergenceExample/Allrun create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/README create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/constant/transportProperties create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/system/blockMeshDict create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/system/controlDict create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes.template create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSolution create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/system/schemesToTest diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/0/T b/tutorials/verificationAndValidation/schemes/divergenceExample/0/T new file mode 100644 index 0000000000..a467b9caf2 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/0/T @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 1e-8; + +boundaryField +{ + top + { + type zeroGradient; + } + + bottom + { + type fixedValue; + value uniform 0; + } + + left + { + type fixedValue; + value uniform 1; + } + + right + { + type zeroGradient; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/0/U b/tutorials/verificationAndValidation/schemes/divergenceExample/0/U new file mode 100644 index 0000000000..354c78f6d5 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/0/U @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: 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 (1 1 0); + +boundaryField +{ + top + { + type zeroGradient; + } + + bottom + { + type fixedValue; + value $internalField; + } + + left + { + type fixedValue; + value $internalField; + } + + right + { + type zeroGradient; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/Allrun b/tutorials/verificationAndValidation/schemes/divergenceExample/Allrun new file mode 100755 index 0000000000..46e746c9c9 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/Allrun @@ -0,0 +1,21 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +runApplication blockMesh + +cat system/schemesToTest | while read scheme +do + echo "Updating fvSchmes to use $scheme" + sed "s/DIVSCHEME/$scheme/g" system/fvSchemes.template > system/fvSchemes + + # Create a sanitised name for the scheme - remove 'special' characters + schemeTag=$(sed -e 's# #_#g#' -e 's#(##g' -e 's#)##g' -e 's#\.##g' <<< "$scheme") + + runApplication -s ${schemeTag} scalarTransportFoam + + # Save the line plot + mv postProcessing/sample1/100/line1_T.xy line1_T_${schemeTag}.xy +done diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/README b/tutorials/verificationAndValidation/schemes/divergenceExample/README new file mode 100644 index 0000000000..6b586a8f8e --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/README @@ -0,0 +1,17 @@ +Divergence scheme test +====================== + +Various divergence schemes are examined on a 2-D structured mesh, where a +passive scalar is convected at 45deg to the mesh co-ordinate system using a +uniform flow velocity. Executing: + +./Allrun + +will update the system/fvSchemes file to use each scheme listed in the file +system/schemesToTest and perform the test using the scalarTransportFoam solver. +A test file for each run is generated that can be used to compare the predicted +scalar profile against the exact solution. + +For more information, see: + +https://www.openfoam.com/documentation/cpp-guide/html/guide-schemes-divergence-example.html diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/constant/transportProperties b/tutorials/verificationAndValidation/schemes/divergenceExample/constant/transportProperties new file mode 100644 index 0000000000..1d7dd0c063 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/constant/transportProperties @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +DT DT [0 2 -1 0 0] 0; + + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/system/blockMeshDict b/tutorials/verificationAndValidation/schemes/divergenceExample/system/blockMeshDict new file mode 100644 index 0000000000..0a2bf84381 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/system/blockMeshDict @@ -0,0 +1,89 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 1; + +vertices +( + (0 0 0) + (1 0 0) + (1 1 0) + (0 1 0) + (0 0 0.1) + (1 0 0.1) + (1 1 0.1) + (0 1 0.1) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (50 50 1) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + top + { + type patch; + faces + ( + (3 7 6 2) + ); + } + bottom + { + type patch; + faces + ( + (1 5 4 0) + ); + } + left + { + type patch; + faces + ( + (0 4 7 3) + ); + } + right + { + type patch; + faces + ( + (2 6 5 1) + ); + } + frontAndBack + { + type empty; + faces + ( + (0 3 2 1) + (4 5 6 7) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/system/controlDict b/tutorials/verificationAndValidation/schemes/divergenceExample/system/controlDict new file mode 100644 index 0000000000..57f4d3a02d --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/system/controlDict @@ -0,0 +1,74 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application scalarTransportFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 100; + +deltaT 0.005; + +writeControl timeStep; + +writeInterval 100; + +purgeWrite 1; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + +functions +{ + sample1 + { + type sets; + functionObjectLibs ("libsampling.so"); + outputControl onEnd; + setFormat raw; + sets + ( + line1 + { + type uniform; + axis distance; + + // Slightly perturbed so as not to align with face or edge + start (0 1 0.00501); + end (1 0 0.00501); + nPoints 200; + } + ); + interpolationScheme cellPoint; + fields (T); + } +} + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes b/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes new file mode 100644 index 0000000000..2187810b69 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: 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,T) Gauss limitedLinear 0.2; +} + +laplacianSchemes +{ + default Gauss linear orthogonal; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default orthogonal; +} + + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes.template b/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes.template new file mode 100644 index 0000000000..be5ae28968 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes.template @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: 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,T) Gauss DIVSCHEME; +} + +laplacianSchemes +{ + default Gauss linear orthogonal; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default orthogonal; +} + + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSolution b/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSolution new file mode 100644 index 0000000000..5a89311545 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSolution @@ -0,0 +1,37 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + T + { +// solver smoothSolver; +// smoother symGaussSeidel; + solver PBiCG; + preconditioner DILU; + tolerance 1e-10; + relTol 0; + } +} + +SIMPLE +{ + nNonOrthogonalCorrectors 0; +} + + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/system/schemesToTest b/tutorials/verificationAndValidation/schemes/divergenceExample/system/schemesToTest new file mode 100644 index 0000000000..be48003bf6 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/system/schemesToTest @@ -0,0 +1,14 @@ +limitedLinear 0.2 +limitedLinear 1.0 +linear +linearUpwind grad(U) +LUST +midPoint +Minmod +MUSCL +QUICK +SFCD +SuperBee +UMIST +upwind +vanLeer