mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Thermodynamics: Changed all eEqn to EEqn and reformulated to conserve E in sonic solvers
To support these changes the need for "Sp" corrections on div-terms has been eliminated by introducing a "bounded" convection scheme which subtracts the Sp term from the selected scheme. The equivalent will be needed for the ddt term. A warning message is generated for steady-state solvers in which the "bounded" scheme is not selected for the convection terms.
This commit is contained in:
@ -345,6 +345,7 @@ convectionSchemes = finiteVolume/convectionSchemes
|
||||
$(convectionSchemes)/convectionScheme/convectionSchemes.C
|
||||
$(convectionSchemes)/gaussConvectionScheme/gaussConvectionSchemes.C
|
||||
$(convectionSchemes)/multivariateGaussConvectionScheme/multivariateGaussConvectionSchemes.C
|
||||
$(convectionSchemes)/boundedConvectionScheme/boundedConvectionSchemes.C
|
||||
|
||||
laplacianSchemes = finiteVolume/laplacianSchemes
|
||||
$(laplacianSchemes)/laplacianScheme/laplacianSchemes.C
|
||||
|
||||
@ -0,0 +1,103 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM 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.
|
||||
|
||||
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "boundedConvectionScheme.H"
|
||||
#include "fvcSurfaceIntegrate.H"
|
||||
#include "fvMatrices.H"
|
||||
#include "fvmSup.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace fv
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
|
||||
boundedConvectionScheme<Type>::interpolate
|
||||
(
|
||||
const surfaceScalarField& phi,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vf
|
||||
) const
|
||||
{
|
||||
return scheme_().interpolate(phi, vf);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
|
||||
boundedConvectionScheme<Type>::flux
|
||||
(
|
||||
const surfaceScalarField& faceFlux,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vf
|
||||
) const
|
||||
{
|
||||
return scheme_().flux(faceFlux, vf);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
tmp<fvMatrix<Type> >
|
||||
boundedConvectionScheme<Type>::fvmDiv
|
||||
(
|
||||
const surfaceScalarField& faceFlux,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vf
|
||||
) const
|
||||
{
|
||||
return
|
||||
scheme_().fvmDiv(faceFlux, vf)
|
||||
- fvm::Sp(fvc::surfaceIntegrate(faceFlux), vf);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh> >
|
||||
boundedConvectionScheme<Type>::fvcDiv
|
||||
(
|
||||
const surfaceScalarField& faceFlux,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vf
|
||||
) const
|
||||
{
|
||||
return
|
||||
scheme_().fvcDiv(faceFlux, vf)
|
||||
- fvc::surfaceIntegrate(faceFlux)*vf;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace fv
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,150 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM 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.
|
||||
|
||||
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::fv::boundedConvectionScheme
|
||||
|
||||
Description
|
||||
Bounded form of the selected convection scheme.
|
||||
|
||||
Boundedness is achieved by subtracting div(phi)*vf or Sp(div(phi), vf)
|
||||
which is non-conservative if div(phi) != 0 but conservative otherwise.
|
||||
|
||||
Can be used for convection of bounded scalar properties in steady-state
|
||||
solvers to improve stability if insufficient convergence of the pressure
|
||||
equation causes temporary divergence of the flux field.
|
||||
|
||||
SourceFiles
|
||||
boundedConvectionScheme.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef boundedConvectionScheme_H
|
||||
#define boundedConvectionScheme_H
|
||||
|
||||
#include "convectionScheme.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace fv
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class boundedConvectionScheme Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class boundedConvectionScheme
|
||||
:
|
||||
public fv::convectionScheme<Type>
|
||||
{
|
||||
// Private data
|
||||
|
||||
tmp<fv::convectionScheme<Type> > scheme_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
boundedConvectionScheme(const boundedConvectionScheme&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const boundedConvectionScheme&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("bounded");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from flux and Istream
|
||||
boundedConvectionScheme
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const surfaceScalarField& faceFlux,
|
||||
Istream& is
|
||||
)
|
||||
:
|
||||
convectionScheme<Type>(mesh, faceFlux),
|
||||
scheme_
|
||||
(
|
||||
fv::convectionScheme<Type>::New(mesh, faceFlux, is)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > interpolate
|
||||
(
|
||||
const surfaceScalarField&,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&
|
||||
) const;
|
||||
|
||||
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > flux
|
||||
(
|
||||
const surfaceScalarField&,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&
|
||||
) const;
|
||||
|
||||
tmp<fvMatrix<Type> > fvmDiv
|
||||
(
|
||||
const surfaceScalarField&,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&
|
||||
) const;
|
||||
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh> > fvcDiv
|
||||
(
|
||||
const surfaceScalarField&,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace fv
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "boundedConvectionScheme.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,39 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM 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.
|
||||
|
||||
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "boundedConvectionScheme.H"
|
||||
#include "fvMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fv
|
||||
{
|
||||
makeFvConvectionScheme(boundedConvectionScheme)
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -47,6 +47,10 @@ namespace Foam
|
||||
namespace fv
|
||||
{
|
||||
|
||||
//- Temporary debug switch to provide warning about backward-compatibility
|
||||
// issue with setting div schemes for steady-state
|
||||
extern int warnUnboundedGauss;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class gaussConvectionScheme Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -103,7 +107,29 @@ public:
|
||||
(
|
||||
surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
|
||||
)
|
||||
{}
|
||||
{
|
||||
is.rewind();
|
||||
word bounded(is);
|
||||
|
||||
if
|
||||
(
|
||||
warnUnboundedGauss
|
||||
&& word(mesh.ddtScheme("default")) == "steadyState"
|
||||
&& bounded != "bounded"
|
||||
)
|
||||
{
|
||||
fileNameList controlDictFiles(findEtcFiles("controlDict"));
|
||||
|
||||
IOWarningIn("gaussConvectionScheme", is)
|
||||
<< "Unbounded 'Gauss' div scheme used in "
|
||||
"steady-state solver, use 'bounded Gauss' "
|
||||
"to ensure boundedness.\n"
|
||||
<< " To remove this warning switch off "
|
||||
<< "'boundedGauss' in "
|
||||
<< controlDictFiles[controlDictFiles.size()-1]
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -32,6 +32,11 @@ namespace Foam
|
||||
{
|
||||
namespace fv
|
||||
{
|
||||
int warnUnboundedGauss
|
||||
(
|
||||
Foam::debug::debugSwitch("warnUnboundedGauss", true)
|
||||
);
|
||||
|
||||
makeFvConvectionScheme(gaussConvectionScheme)
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,6 +164,89 @@ Foam::basicThermo::~basicThermo()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::basicThermo::validate
|
||||
(
|
||||
const word& app,
|
||||
const word& a
|
||||
) const
|
||||
{
|
||||
if (!(he().name() == a))
|
||||
{
|
||||
FatalErrorIn(app)
|
||||
<< "Supported energy type is " << a
|
||||
<< ", thermodynamics package provides " << he().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
void Foam::basicThermo::validate
|
||||
(
|
||||
const word& app,
|
||||
const word& a,
|
||||
const word& b
|
||||
) const
|
||||
{
|
||||
if (!(he().name() == a || he().name() == b))
|
||||
{
|
||||
FatalErrorIn(app)
|
||||
<< "Supported energy types are " << a << " and " << b
|
||||
<< ", thermodynamics package provides " << he().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
void Foam::basicThermo::validate
|
||||
(
|
||||
const word& app,
|
||||
const word& a,
|
||||
const word& b,
|
||||
const word& c
|
||||
) const
|
||||
{
|
||||
if
|
||||
(
|
||||
!(
|
||||
he().name() == a
|
||||
|| he().name() == b
|
||||
|| he().name() == c
|
||||
)
|
||||
)
|
||||
{
|
||||
FatalErrorIn(app)
|
||||
<< "Supported energy types are " << a << ", " << b << " and " << c
|
||||
<< ", thermodynamics package provides " << he().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
void Foam::basicThermo::validate
|
||||
(
|
||||
const word& app,
|
||||
const word& a,
|
||||
const word& b,
|
||||
const word& c,
|
||||
const word& d
|
||||
) const
|
||||
{
|
||||
if
|
||||
(
|
||||
!(
|
||||
he().name() == a
|
||||
|| he().name() == b
|
||||
|| he().name() == c
|
||||
|| he().name() == d
|
||||
)
|
||||
)
|
||||
{
|
||||
FatalErrorIn(app)
|
||||
<< "Supported energy types are " << a << ", " << b
|
||||
<< ", " << c << " and " << d
|
||||
<< ", thermodynamics package provides " << he().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::volScalarField& Foam::basicThermo::p()
|
||||
{
|
||||
return p_;
|
||||
|
||||
@ -111,6 +111,45 @@ public:
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Check that the thermodynamics package is consistent
|
||||
// with energy forms supported by the application
|
||||
void validate
|
||||
(
|
||||
const word& app,
|
||||
const word&
|
||||
) const;
|
||||
|
||||
//- Check that the thermodynamics package is consistent
|
||||
// with energy forms supported by the application
|
||||
void validate
|
||||
(
|
||||
const word& app,
|
||||
const word&,
|
||||
const word&
|
||||
) const;
|
||||
|
||||
//- Check that the thermodynamics package is consistent
|
||||
// with energy forms supported by the application
|
||||
void validate
|
||||
(
|
||||
const word& app,
|
||||
const word&,
|
||||
const word&,
|
||||
const word&
|
||||
) const;
|
||||
|
||||
//- Check that the thermodynamics package is consistent
|
||||
// with energy forms supported by the application
|
||||
void validate
|
||||
(
|
||||
const word& app,
|
||||
const word&,
|
||||
const word&,
|
||||
const word&,
|
||||
const word&
|
||||
) const;
|
||||
|
||||
|
||||
//- Update properties
|
||||
virtual void correct() = 0;
|
||||
|
||||
|
||||
@ -142,6 +142,24 @@ makeBasicMixture
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
constTransport,
|
||||
sensibleInternalEnergy,
|
||||
eConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
sensibleInternalEnergy,
|
||||
eConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
|
||||
@ -84,27 +84,27 @@ makeThermo
|
||||
|
||||
/* * * * * * * * * * * * * * Internal-energy-based * * * * * * * * * * * * * */
|
||||
|
||||
// makeThermo
|
||||
// (
|
||||
// psiThermo,
|
||||
// hePsiThermo,
|
||||
// pureMixture,
|
||||
// constTransport,
|
||||
// sensibleInternalEnergy,
|
||||
// eConstThermo,
|
||||
// perfectGas
|
||||
// );
|
||||
makeThermo
|
||||
(
|
||||
psiThermo,
|
||||
hePsiThermo,
|
||||
pureMixture,
|
||||
constTransport,
|
||||
sensibleInternalEnergy,
|
||||
eConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
// makeThermo
|
||||
// (
|
||||
// psiThermo,
|
||||
// hePsiThermo,
|
||||
// pureMixture,
|
||||
// sutherlandTransport,
|
||||
// sensibleInternalEnergy,
|
||||
// eConstThermo,
|
||||
// perfectGas
|
||||
// );
|
||||
makeThermo
|
||||
(
|
||||
psiThermo,
|
||||
hePsiThermo,
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
sensibleInternalEnergy,
|
||||
eConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeThermo
|
||||
(
|
||||
|
||||
@ -292,7 +292,7 @@ void kEpsilon::correct()
|
||||
(
|
||||
fvm::ddt(rho_, epsilon_)
|
||||
+ fvm::div(phi_, epsilon_)
|
||||
- fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), epsilon_)
|
||||
//***HGW - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), epsilon_)
|
||||
- fvm::laplacian(DepsilonEff(), epsilon_)
|
||||
==
|
||||
C1_*G*epsilon_/k_
|
||||
@ -314,7 +314,7 @@ void kEpsilon::correct()
|
||||
(
|
||||
fvm::ddt(rho_, k_)
|
||||
+ fvm::div(phi_, k_)
|
||||
- fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), k_)
|
||||
//***HGW - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), k_)
|
||||
- fvm::laplacian(DkEff(), k_)
|
||||
==
|
||||
G
|
||||
|
||||
Reference in New Issue
Block a user