diff --git a/applications/solvers/compressible/dbnsFoam/createFields.H b/applications/solvers/compressible/dbnsFoam/createFields.H index 6a4a4cee8..8b0f268a5 100644 --- a/applications/solvers/compressible/dbnsFoam/createFields.H +++ b/applications/solvers/compressible/dbnsFoam/createFields.H @@ -70,14 +70,14 @@ // Create numeric flux -// numericFlux dbnsFlux - numericFlux dbnsFlux + autoPtr dbnsFluxPtr = basicNumericFlux::New ( p, U, T, thermo() ); + basicNumericFlux& dbnsFlux = dbnsFluxPtr(); // Create mass flux alias for easier coupling with other code components const surfaceScalarField& phi = dbnsFlux.rhoFlux(); diff --git a/applications/solvers/compressible/dbnsTurbFoam/createFields.H b/applications/solvers/compressible/dbnsTurbFoam/createFields.H index 74df61ab9..fb768ba09 100644 --- a/applications/solvers/compressible/dbnsTurbFoam/createFields.H +++ b/applications/solvers/compressible/dbnsTurbFoam/createFields.H @@ -70,13 +70,14 @@ // Create numeric flux - numericFlux dbnsFlux + autoPtr dbnsFluxPtr = basicNumericFlux::New ( p, U, T, thermo() ); + basicNumericFlux& dbnsFlux = dbnsFluxPtr(); // Create mass flux alias for easier coupling with other code components const surfaceScalarField& phi = dbnsFlux.rhoFlux(); diff --git a/src/dbns/Make/files b/src/dbns/Make/files index 380b04e2d..6b8784816 100644 --- a/src/dbns/Make/files +++ b/src/dbns/Make/files @@ -4,6 +4,10 @@ dbnsFlux/betaFlux/betaFlux.C dbnsFlux/hllcFlux/hllcFlux.C dbnsFlux/hllcALEFlux/hllcALEFlux.C +basicNumericFlux/basicNumericFlux.C +basicNumericFlux/newBasicNumericFlux.C +numericFlux/numericFluxes.C + multigrid/mgMeshLevel/mgMeshLevel.C multigrid/mgMeshLevel/fineMgMeshLevel.C multigrid/mgMeshLevel/coarseMgMeshLevel.C diff --git a/src/dbns/basicNumericFlux/basicNumericFlux.C b/src/dbns/basicNumericFlux/basicNumericFlux.C new file mode 100644 index 000000000..ef5bc88b4 --- /dev/null +++ b/src/dbns/basicNumericFlux/basicNumericFlux.C @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 3.2 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + foam-extend is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "basicNumericFlux.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(basicNumericFlux, 0); + defineRunTimeSelectionTable(basicNumericFlux, state); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::basicNumericFlux::basicNumericFlux(const fvMesh& mesh) +: + mesh_(mesh) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::basicNumericFlux::~basicNumericFlux() +{} + + +// ************************************************************************* // diff --git a/src/dbns/basicNumericFlux/basicNumericFlux.H b/src/dbns/basicNumericFlux/basicNumericFlux.H new file mode 100644 index 000000000..d8e41c900 --- /dev/null +++ b/src/dbns/basicNumericFlux/basicNumericFlux.H @@ -0,0 +1,179 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 3.2 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + foam-extend is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with foam-extend. If not, see . + +Class + Foam::basicNumericFlux + +Description + Base class for runtime-selectable flux and limiters + +Author + Henrik Rusche + +SourceFiles + basicNumericFlux.C + newBasicPsiThermo.C + +\*---------------------------------------------------------------------------*/ + +#ifndef basicNumericFlux_H +#define basicNumericFlux_H + +#include "fvMesh.H" +#include "volFields.H" +#include "runTimeSelectionTables.H" +#include "basicThermo.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class basicNumericFlux Declaration +\*---------------------------------------------------------------------------*/ + +class basicNumericFlux +{ + // Private data + + //- Reference to mesh + const fvMesh& mesh_; + + +protected: + + // Protected member functions + + //- Construct as copy (not implemented) + basicNumericFlux(const basicNumericFlux&); + + +public: + + //- Runtime type information + TypeName("basicNumericFlux"); + + + //- Declare run-time constructor selection table + +#ifndef SWIG + declareRunTimeSelectionTable + ( + autoPtr, + basicNumericFlux, + state, + ( + const volScalarField& p, + const volVectorField& U, + const volScalarField& T, + basicThermo& thermo + ), + (p, U, T, thermo) + ); +#endif + + + // Constructors + + //- Construct from components + basicNumericFlux + ( + const fvMesh& mesh + ); + + + //- Selector + static autoPtr New + ( + const volScalarField& p, + const volVectorField& U, + const volScalarField& T, + basicThermo& thermo + ); + + + //- Destructor + virtual ~basicNumericFlux(); + + + // Member functions + + //- Return mesh reference + const fvMesh& mesh() const + { + return mesh_; + } + + // Return fluxes + + //- Return density flux + virtual const surfaceScalarField& rhoFlux() const = 0; + + //- Return velocity flux + virtual const surfaceVectorField& rhoUFlux() const = 0; + + //- Return energy flux + virtual const surfaceScalarField& rhoEFlux() const = 0; + + + // Return residuals + + //- Return density equation residual + virtual tmp rhoResidual() const = 0; + + //- Return momentum equation flux + virtual tmp rhoUResidual() const = 0; + + //- Return energy equation flux + virtual tmp rhoEResidual() const = 0; + + + // Return Gradients + + //- Return pressure gradient + virtual const volVectorField& gradP() const = 0; + + //- Return pressure gradient + virtual const volTensorField& gradU() const = 0; + + //- Return Temperature gradient + virtual const volVectorField& gradT() const = 0; + + + // Update fluxes based on current state + + //- Compute flux + virtual void computeFlux() = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/dbns/basicNumericFlux/makeBasicNumericFlux.H b/src/dbns/basicNumericFlux/makeBasicNumericFlux.H new file mode 100644 index 000000000..42b45f3c1 --- /dev/null +++ b/src/dbns/basicNumericFlux/makeBasicNumericFlux.H @@ -0,0 +1,64 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 3.2 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + foam-extend is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with foam-extend. If not, see . + +InClass + Foam::basicNumericFlux + +Description + Macros for creating fluxes (including limiters) for DBNS solver + +\*---------------------------------------------------------------------------*/ + +#ifndef makeBasicPsiThermo_H +#define makeBasicPsiThermo_H + +#include "numericFlux.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeBasicNumericFlux(Flux,Limiter) \ + \ +typedef numericFlux \ + Flux##Limiter; \ + \ +defineTemplateTypeNameAndDebugWithName \ +( \ + Flux##Limiter, \ + #Flux#Limiter, \ + 0 \ +); \ + \ +addToRunTimeSelectionTable \ +( \ + basicNumericFlux, \ + Flux##Limiter, \ + state \ +) + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/dbns/basicNumericFlux/newBasicNumericFlux.C b/src/dbns/basicNumericFlux/newBasicNumericFlux.C new file mode 100644 index 000000000..c683833a0 --- /dev/null +++ b/src/dbns/basicNumericFlux/newBasicNumericFlux.C @@ -0,0 +1,62 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 3.2 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + foam-extend is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "basicNumericFlux.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::autoPtr Foam::basicNumericFlux::New +( + const volScalarField& p, + const volVectorField& U, + const volScalarField& T, + basicThermo& thermo +) +{ + const dictionary& subDict = + p.mesh().schemesDict().subDict("divSchemes").subDict("dbns"); + + word name = word(subDict.lookup("flux")) + "Flux" + + word(subDict.lookup("limiter")) + "Limiter"; + + Info<< "Selecting numericFlux " << name << endl; + + stateConstructorTable::iterator cstrIter = + stateConstructorTablePtr_->find(name); + + if (cstrIter == stateConstructorTablePtr_->end()) + { + FatalErrorIn("basicNumericFlux::New(const fvMesh&)") + << "Unknown basicNumericFlux type " << name << nl << nl + << "Valid basicNumericFlux types are:" << nl + << stateConstructorTablePtr_->sortedToc() << nl + << exit(FatalError); + } + + return autoPtr(cstrIter()(p, U, T, thermo)); +} + + +// ************************************************************************* // diff --git a/src/dbns/numericFlux/numericFlux.C b/src/dbns/numericFlux/numericFlux.C index 50b05f568..0544b9c8a 100644 --- a/src/dbns/numericFlux/numericFlux.C +++ b/src/dbns/numericFlux/numericFlux.C @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "numericFlux.H" +#include "MDLimiter.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -37,8 +38,7 @@ Foam::numericFlux::numericFlux basicThermo& thermo ) : - numericFluxBase(), - mesh_(p.mesh()), + numericFluxBase(p.mesh()), p_(p), U_(U), T_(T), @@ -48,20 +48,20 @@ Foam::numericFlux::numericFlux IOobject ( "phi", - mesh_.time().timeName(), - mesh_, + this->mesh().time().timeName(), + this->mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), - (linearInterpolate(thermo_.rho()*U_) & mesh_.Sf()) + (linearInterpolate(thermo_.rho()*U_) & this->mesh().Sf()) ), rhoUFlux_ ( IOobject ( "rhoUFlux", - mesh_.time().timeName(), - mesh_, + this->mesh().time().timeName(), + this->mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), @@ -72,8 +72,8 @@ Foam::numericFlux::numericFlux IOobject ( "rhoEFlux", - mesh_.time().timeName(), - mesh_, + this->mesh().time().timeName(), + this->mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), @@ -88,15 +88,15 @@ template void Foam::numericFlux::computeFlux() { // Get face-to-cell addressing: face area point from owner to neighbour - const unallocLabelList& owner = mesh_.owner(); - const unallocLabelList& neighbour = mesh_.neighbour(); + const unallocLabelList& owner = this->mesh().owner(); + const unallocLabelList& neighbour = this->mesh().neighbour(); // Get the face area vector - const surfaceVectorField& Sf = mesh_.Sf(); - const surfaceScalarField& magSf = mesh_.magSf(); + const surfaceVectorField& Sf = this->mesh().Sf(); + const surfaceScalarField& magSf = this->mesh().magSf(); - const volVectorField& cellCentre = mesh_.C(); - const surfaceVectorField& faceCentre = mesh_.Cf(); + const volVectorField& cellCentre = this->mesh().C(); + const surfaceVectorField& faceCentre = this->mesh().Cf(); // Thermodynamics const volScalarField Cv = thermo_.Cv(); diff --git a/src/dbns/numericFlux/numericFlux.H b/src/dbns/numericFlux/numericFlux.H index f39087604..cb0532f7b 100644 --- a/src/dbns/numericFlux/numericFlux.H +++ b/src/dbns/numericFlux/numericFlux.H @@ -42,6 +42,7 @@ SourceFiles #include "numericFluxBase.H" #include "basicThermo.H" +#include "fvc.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,10 +60,6 @@ class numericFlux { // Private data - //- Reference to mesh - const fvMesh& mesh_; - - // Reference to primitive fields //- Static pressure @@ -141,6 +138,9 @@ class numericFlux public: + //- Runtime type information + TypeName("numericFlux"); + // Constructors //- Construct from components @@ -160,13 +160,6 @@ public: // Member Functions - //- Return mesh reference - const fvMesh& mesh() const - { - return mesh_; - } - - // Return fluxes //- Return density flux diff --git a/src/dbns/numericFlux/numericFluxBase.H b/src/dbns/numericFlux/numericFluxBase.H index 6882fdbbe..fd11de882 100644 --- a/src/dbns/numericFlux/numericFluxBase.H +++ b/src/dbns/numericFlux/numericFluxBase.H @@ -40,6 +40,7 @@ SourceFiles #ifndef numericFluxBase_H #define numericFluxBase_H +#include "basicNumericFlux.H" #include "volFieldsFwd.H" #include "surfaceFieldsFwd.H" @@ -55,50 +56,23 @@ namespace Foam template class numericFluxBase : + public basicNumericFlux, public Flux { public: // Constructors - //- Construct null - numericFluxBase() + //- Construct from mesh + numericFluxBase(const fvMesh& mesh) + : + basicNumericFlux(mesh) {} //- Destructor virtual ~numericFluxBase() {} - - - // Memeber functions - - // Return fluxes - - //- Return continuity equation flux - virtual const surfaceScalarField& rhoFlux() const = 0; - - //- Return momentum equation flux - virtual const surfaceVectorField& rhoUFlux() const = 0; - - //- Return energy equation flux - virtual const surfaceScalarField& rhoEFlux() const = 0; - - - // Return residuals - - //- Return mass residual - virtual tmp rhoResidual() const = 0; - - //- Return momentum residual - virtual tmp rhoUResidual() const = 0; - - //- Return energy residual - virtual tmp rhoEResidual() const = 0; - - - //- Update fluxes based on current state - virtual void computeFlux() = 0; }; diff --git a/src/dbns/numericFlux/numericFluxes.C b/src/dbns/numericFlux/numericFluxes.C new file mode 100644 index 000000000..8d130e2c6 --- /dev/null +++ b/src/dbns/numericFlux/numericFluxes.C @@ -0,0 +1,59 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 3.2 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + foam-extend is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "makeBasicNumericFlux.H" + +#include "rusanovFlux.H" +#include "roeFlux.H" +#include "betaFlux.H" +#include "hllcFlux.H" +#include "hllcALEFlux.H" + +#include "firstOrderLimiter.H" +#include "BarthJespersenLimiter.H" +#include "VenkatakrishnanLimiter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/* * * * * * * * * * * * * * * Private Static Data * * * * * * * * * * * * * */ + +#define makeBasicNumericFluxForAllLimiters(Flux) \ +makeBasicNumericFlux(Flux, firstOrderLimiter); \ +makeBasicNumericFlux(Flux, BarthJespersenLimiter); \ +makeBasicNumericFlux(Flux, VenkatakrishnanLimiter); + +makeBasicNumericFluxForAllLimiters(rusanovFlux); +makeBasicNumericFluxForAllLimiters(betaFlux); +makeBasicNumericFluxForAllLimiters(roeFlux); +makeBasicNumericFluxForAllLimiters(hllcFlux); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/tutorials/compressible/dbnsFoam/forwardStep/system/controlDict b/tutorials/compressible/dbnsFoam/forwardStep/system/controlDict index ec9ddca6e..b02f8fc33 100644 --- a/tutorials/compressible/dbnsFoam/forwardStep/system/controlDict +++ b/tutorials/compressible/dbnsFoam/forwardStep/system/controlDict @@ -20,7 +20,7 @@ startTime 0; stopAt endTime; -endTime 3; +endTime 1; deltaT 0.001; diff --git a/tutorials/compressible/dbnsFoam/forwardStep/system/fvSchemes b/tutorials/compressible/dbnsFoam/forwardStep/system/fvSchemes index 5d4d11444..7508cca8e 100644 --- a/tutorials/compressible/dbnsFoam/forwardStep/system/fvSchemes +++ b/tutorials/compressible/dbnsFoam/forwardStep/system/fvSchemes @@ -25,7 +25,13 @@ gradSchemes } divSchemes -{} +{ + dbns + { + flux rusanov; + limiter BarthJespersen; + } +} laplacianSchemes {} @@ -42,4 +48,5 @@ snGradSchemes fluxRequired {} + // ************************************************************************* // diff --git a/tutorials/compressible/dbnsFoam/shockTube/system/fvSchemes b/tutorials/compressible/dbnsFoam/shockTube/system/fvSchemes index 5d4d11444..7508cca8e 100644 --- a/tutorials/compressible/dbnsFoam/shockTube/system/fvSchemes +++ b/tutorials/compressible/dbnsFoam/shockTube/system/fvSchemes @@ -25,7 +25,13 @@ gradSchemes } divSchemes -{} +{ + dbns + { + flux rusanov; + limiter BarthJespersen; + } +} laplacianSchemes {} @@ -42,4 +48,5 @@ snGradSchemes fluxRequired {} + // ************************************************************************* // diff --git a/tutorials/compressible/dbnsTurbFoam/naca0012/system/fvSchemes b/tutorials/compressible/dbnsTurbFoam/naca0012/system/fvSchemes index 9435e1af2..de3cf1686 100644 --- a/tutorials/compressible/dbnsTurbFoam/naca0012/system/fvSchemes +++ b/tutorials/compressible/dbnsTurbFoam/naca0012/system/fvSchemes @@ -27,6 +27,12 @@ gradSchemes divSchemes { + dbns + { + flux rusanov; + limiter BarthJespersen; + } + default none; div(phi,k) Gauss upwind; div(phi,epsilon) Gauss upwind;