From f11787ae2f5c835315b13f26f578fbbcf0bcdba3 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Fri, 6 Oct 2017 15:33:33 +0100 Subject: [PATCH] fvOptions: Added support for transport equations involving d2dt2 Added incompressible solver support to the buoyancyForce fvOption --- .../cfdTools/general/fvOptions/fvOptionList.H | 26 +++++++- .../general/fvOptions/fvOptionListTemplates.C | 61 ++++++++++++++----- .../derived/buoyancyForce/buoyancyForce.C | 12 +++- .../derived/buoyancyForce/buoyancyForce.H | 7 +++ 4 files changed, 89 insertions(+), 17 deletions(-) diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.H b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.H index 78df2901e..3e6847c56 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.H +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -88,6 +88,15 @@ protected: //- Check that all sources have been applied void checkApplied() const; + //- Return source for equation with specified name and dimensions + template + tmp> source + ( + GeometricField& field, + const word& fieldName, + const dimensionSet& ds + ); + //- Disallow default bitwise copy construct optionList(const optionList&); @@ -201,6 +210,21 @@ public: GeometricField& field ); + //- Return source for equation with second time derivative + template + tmp> d2dt2 + ( + GeometricField& field + ); + + //- Return source for equation with second time derivative + template + tmp> d2dt2 + ( + GeometricField& field, + const word& fieldName + ); + // Constraints diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C index b09af6f2c..d78547820 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,26 +26,15 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -Foam::tmp> Foam::fv::optionList::operator() -( - GeometricField& field -) -{ - return this->operator()(field, field.name()); -} - - -template -Foam::tmp> Foam::fv::optionList::operator() +Foam::tmp> Foam::fv::optionList::source ( GeometricField& field, - const word& fieldName + const word& fieldName, + const dimensionSet& ds ) { checkApplied(); - const dimensionSet ds = field.dimensions()/dimTime*dimVolume; - tmp> tmtx(new fvMatrix(field, ds)); fvMatrix& mtx = tmtx.ref(); @@ -76,6 +65,27 @@ Foam::tmp> Foam::fv::optionList::operator() } +template +Foam::tmp> Foam::fv::optionList::operator() +( + GeometricField& field +) +{ + return this->operator()(field, field.name()); +} + + +template +Foam::tmp> Foam::fv::optionList::operator() +( + GeometricField& field, + const word& fieldName +) +{ + return source(field, fieldName, field.dimensions()/dimTime*dimVolume); +} + + template Foam::tmp> Foam::fv::optionList::operator() ( @@ -242,6 +252,27 @@ Foam::tmp> Foam::fv::optionList::operator() } +template +Foam::tmp> Foam::fv::optionList::d2dt2 +( + GeometricField& field +) +{ + return this->d2dt2(field, field.name()); +} + + +template +Foam::tmp> Foam::fv::optionList::d2dt2 +( + GeometricField& field, + const word& fieldName +) +{ + return source(field, fieldName, field.dimensions()/sqr(dimTime)*dimVolume); +} + + template void Foam::fv::optionList::constrain(fvMatrix& eqn) { diff --git a/src/fvOptions/sources/derived/buoyancyForce/buoyancyForce.C b/src/fvOptions/sources/derived/buoyancyForce/buoyancyForce.C index 23c85d0b1..6976ee9fb 100644 --- a/src/fvOptions/sources/derived/buoyancyForce/buoyancyForce.C +++ b/src/fvOptions/sources/derived/buoyancyForce/buoyancyForce.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2015-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -82,6 +82,16 @@ Foam::fv::buoyancyForce::buoyancyForce // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void Foam::fv::buoyancyForce::addSup +( + fvMatrix& eqn, + const label fieldi +) +{ + eqn += g_; +} + + void Foam::fv::buoyancyForce::addSup ( const volScalarField& rho, diff --git a/src/fvOptions/sources/derived/buoyancyForce/buoyancyForce.H b/src/fvOptions/sources/derived/buoyancyForce/buoyancyForce.H index e50c5f326..8c0807fcd 100644 --- a/src/fvOptions/sources/derived/buoyancyForce/buoyancyForce.H +++ b/src/fvOptions/sources/derived/buoyancyForce/buoyancyForce.H @@ -96,6 +96,13 @@ public: // Evaluate + //- Add explicit contribution to incompressible momentum equation + virtual void addSup + ( + fvMatrix& eqn, + const label fieldi + ); + //- Add explicit contribution to compressible momentum equation virtual void addSup (