FEAT: Runtime-selectable flux and limiter in DBNS

This commit is contained in:
Henrik Rusche 2016-05-14 13:48:13 +02:00
parent 4d67ffd82f
commit 6d43981296
15 changed files with 471 additions and 64 deletions

View file

@ -70,14 +70,14 @@
// Create numeric flux
// numericFlux<roeFlux, BarthJespersenLimiter> dbnsFlux
numericFlux<rusanovFlux, BarthJespersenLimiter> dbnsFlux
autoPtr<basicNumericFlux> 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();

View file

@ -70,13 +70,14 @@
// Create numeric flux
numericFlux<rusanovFlux, BarthJespersenLimiter> dbnsFlux
autoPtr<basicNumericFlux> 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();

View file

@ -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

View file

@ -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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "basicNumericFlux.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(basicNumericFlux, 0);
defineRunTimeSelectionTable(basicNumericFlux, state);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::basicNumericFlux::basicNumericFlux(const fvMesh& mesh)
:
mesh_(mesh)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::basicNumericFlux::~basicNumericFlux()
{}
// ************************************************************************* //

View file

@ -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 <http://www.gnu.org/licenses/>.
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<basicNumericFlux> 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<scalarField> rhoResidual() const = 0;
//- Return momentum equation flux
virtual tmp<vectorField> rhoUResidual() const = 0;
//- Return energy equation flux
virtual tmp<scalarField> 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
// ************************************************************************* //

View file

@ -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 <http://www.gnu.org/licenses/>.
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> \
Flux##Limiter; \
\
defineTemplateTypeNameAndDebugWithName \
( \
Flux##Limiter, \
#Flux#Limiter, \
0 \
); \
\
addToRunTimeSelectionTable \
( \
basicNumericFlux, \
Flux##Limiter, \
state \
)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "basicNumericFlux.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::basicNumericFlux> 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<basicNumericFlux>(cstrIter()(p, U, T, thermo));
}
// ************************************************************************* //

View file

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "numericFlux.H"
#include "MDLimiter.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -37,8 +38,7 @@ Foam::numericFlux<Flux, Limiter>::numericFlux
basicThermo& thermo
)
:
numericFluxBase<Flux>(),
mesh_(p.mesh()),
numericFluxBase<Flux>(p.mesh()),
p_(p),
U_(U),
T_(T),
@ -48,20 +48,20 @@ Foam::numericFlux<Flux, Limiter>::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<Flux, Limiter>::numericFlux
IOobject
(
"rhoEFlux",
mesh_.time().timeName(),
mesh_,
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
@ -91,15 +91,15 @@ template<class Flux, class Limiter>
void Foam::numericFlux<Flux, Limiter>::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();

View file

@ -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
@ -150,6 +147,9 @@ class numericFlux
public:
//- Runtime type information
TypeName("numericFlux");
// Constructors
//- Construct from components
@ -169,13 +169,6 @@ public:
// Member Functions
//- Return mesh reference
const fvMesh& mesh() const
{
return mesh_;
}
// Return fluxes
//- Return density flux

View file

@ -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 Flux>
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<scalarField> rhoResidual() const = 0;
//- Return momentum residual
virtual tmp<vectorField> rhoUResidual() const = 0;
//- Return energy residual
virtual tmp<scalarField> rhoEResidual() const = 0;
//- Update fluxes based on current state
virtual void computeFlux() = 0;
};

View file

@ -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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#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
// ************************************************************************* //

View file

@ -20,7 +20,7 @@ startTime 0;
stopAt endTime;
endTime 3;
endTime 1;
deltaT 0.001;

View file

@ -25,7 +25,13 @@ gradSchemes
}
divSchemes
{}
{
dbns
{
flux rusanov;
limiter BarthJespersen;
}
}
laplacianSchemes
{}
@ -42,4 +48,5 @@ snGradSchemes
fluxRequired
{}
// ************************************************************************* //

View file

@ -25,7 +25,13 @@ gradSchemes
}
divSchemes
{}
{
dbns
{
flux rusanov;
limiter BarthJespersen;
}
}
laplacianSchemes
{}
@ -42,4 +48,5 @@ snGradSchemes
fluxRequired
{}
// ************************************************************************* //

View file

@ -27,6 +27,12 @@ gradSchemes
divSchemes
{
dbns
{
flux rusanov;
limiter BarthJespersen;
}
default none;
div(phi,k) Gauss upwind;
div(phi,epsilon) Gauss upwind;