Added LUST scheme, moved linearUpwind

This commit is contained in:
Hrvoje Jasak 2018-12-12 13:21:24 +00:00
parent 752fce1a02
commit 0a5b18eff9
7 changed files with 905 additions and 2 deletions

View file

@ -286,13 +286,14 @@ $(schemes)/cubicUpwindFit/cubicUpwindFit.C
$(schemes)/quadraticLinearPureUpwindFit/quadraticLinearPureUpwindFit.C
*/
$(schemes)/linearPureUpwindFit/linearPureUpwindFit.C
$(schemes)/linearUpwind/linearUpwind.C
$(schemes)/linearUpwind/linearUpwindV.C
$(schemes)/LUST/LUST.C
limitedSchemes = $(surfaceInterpolation)/limitedSchemes
$(limitedSchemes)/limitedSurfaceInterpolationScheme/limitedSurfaceInterpolationSchemes.C
$(limitedSchemes)/upwind/upwind.C
$(limitedSchemes)/blended/blended.C
$(limitedSchemes)/linearUpwind/linearUpwind.C
$(limitedSchemes)/linearUpwind/linearUpwindV.C
$(limitedSchemes)/reconCentral/reconCentral.C
$(limitedSchemes)/Gamma/Gamma.C
$(limitedSchemes)/SFCD/SFCD.C

View file

@ -0,0 +1,36 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.1
\\ / 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 "LUST.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makeSurfaceInterpolationTypeScheme(LUST, scalar);
makeSurfaceInterpolationTypeScheme(LUST, vector);
}
// ************************************************************************* //

View file

@ -0,0 +1,138 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.1
\\ / 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::LUST
Description
LUST: Linear-upwind stabilised transport.
Interpolation scheme class derived from linearUpwind which returns blended
linear/linear-upwind weighting factors and also applies a explicit
gradient-based correction obtained from the linearUpwind scheme. The
blending-factor is set to 0.75 linear which optimises the balance between
accuracy and stability on a range of LES cases with a range of mesh quality.
SourceFiles
LUST.C
\*---------------------------------------------------------------------------*/
#ifndef LUST_H
#define LUST_H
#include "linearUpwind.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class LUST Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class LUST
:
public linearUpwind<Type>
{
// Private Member Functions
//- Disallow default bitwise copy construct
LUST(const LUST&);
//- Disallow default bitwise assignment
void operator=(const LUST&);
public:
//- Runtime type information
TypeName("LUST");
// Constructors
//- Construct from mesh and Istream
LUST
(
const fvMesh& mesh,
Istream& schemeData
)
:
linearUpwind<Type>(mesh, schemeData)
{}
//- Construct from mesh, faceFlux and Istream
LUST
(
const fvMesh& mesh,
const surfaceScalarField& faceFlux,
Istream& schemeData
)
:
linearUpwind<Type>(mesh, faceFlux, schemeData)
{}
// Member Functions
//- Return the interpolation weighting factors
virtual tmp<surfaceScalarField> weights
(
const GeometricField<Type, fvPatchField, volMesh>&
) const
{
return
0.75*this->mesh().surfaceInterpolation::weights()
+ 0.25*linearUpwind<Type>::weights();
}
//- Return true if this scheme uses an explicit correction
virtual bool corrected() const
{
return true;
}
//- Return the explicit correction to the face-interpolate
virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
correction
(
const GeometricField<Type, fvPatchField, volMesh>& vf
) const
{
return 0.25*linearUpwind<Type>::correction(vf);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,161 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.1
\\ / 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 "linearUpwind.H"
#include "fvMesh.H"
#include "zeroGradientFvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
Foam::linearUpwind<Type>::correction
(
const GeometricField<Type, fvPatchField, volMesh>& vf
) const
{
const fvMesh& mesh = this->mesh();
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
(
new GeometricField<Type, fvsPatchField, surfaceMesh>
(
IOobject
(
"linearUpwindCorrection(" + vf.name() + ')',
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh,
dimensioned<Type>(vf.name(), vf.dimensions(), pTraits<Type>::zero)
)
);
GeometricField<Type, fvsPatchField, surfaceMesh>& sfCorr = tsfCorr();
const surfaceScalarField& faceFlux = this->faceFlux_;
const labelList& owner = mesh.owner();
const labelList& neighbour = mesh.neighbour();
const volVectorField& C = mesh.C();
const surfaceVectorField& Cf = mesh.Cf();
// Due to gradient cacheing, must take a tmp field
// HJ, 22/Apr/2016
tmp
<
GeometricField
<
typename outerProduct<vector, Type>::type,
fvPatchField,
volMesh
>
> tgradVf = gradScheme_().grad(vf, gradSchemeName_);
const GeometricField
<
typename outerProduct<vector, Type>::type,
fvPatchField,
volMesh
>& gradVf = tgradVf();
// Note: in order for the patchNeighbourField to be correct on coupled
// boundaries, correctBoundaryConditions needs to be called.
// The call shall be moved into the library fvc operators
// Moved to cached gradScheme. HJ, 22/Apr/2016
// gradVf.correctBoundaryConditions();
forAll (faceFlux, facei)
{
if (faceFlux[facei] > 0)
{
label own = owner[facei];
sfCorr[facei] = (Cf[facei] - C[own]) & gradVf[own];
}
else
{
label nei = neighbour[facei];
sfCorr[facei] = (Cf[facei] - C[nei]) & gradVf[nei];
}
}
typename GeometricField<Type, fvsPatchField, surfaceMesh>::
GeometricBoundaryField& bSfCorr = sfCorr.boundaryField();
forAll (bSfCorr, patchi)
{
fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
if (pSfCorr.coupled())
{
const fvPatch& p = mesh.boundary()[patchi];
const unallocLabelList& pOwner = p.faceCells();
const vectorField& pCf = Cf.boundaryField()[patchi];
const scalarField& pFaceFlux = faceFlux.boundaryField()[patchi];
Field<typename outerProduct<vector, Type>::type> pGradVfNei =
gradVf.boundaryField()[patchi].patchNeighbourField();
// Build the d-vectors
// Better version of d-vectors: Zeljko Tukovic, 25/Apr/2010
vectorField pd = p.delta();
forAll (pOwner, facei)
{
label own = pOwner[facei];
if (pFaceFlux[facei] > 0)
{
pSfCorr[facei] = (pCf[facei] - C[own]) & gradVf[own];
}
else
{
pSfCorr[facei] =
(pCf[facei] - pd[facei] - C[own]) & pGradVfNei[facei];
}
}
}
}
return tsfCorr;
}
namespace Foam
{
//makelimitedSurfaceInterpolationScheme(linearUpwind)
makelimitedSurfaceInterpolationTypeScheme(linearUpwind, scalar)
makelimitedSurfaceInterpolationTypeScheme(linearUpwind, vector)
}
// ************************************************************************* //

View file

@ -0,0 +1,164 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.1
\\ / 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::linearUpwind
Description
linearUpwind interpolation scheme class derived from upwind and returns
upwind weighting factors but also applies an explicit correction.
SourceFiles
linearUpwind.C
\*---------------------------------------------------------------------------*/
#ifndef linearUpwind_H
#define linearUpwind_H
#include "upwind.H"
#include "gaussGrad.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class linearUpwind Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class linearUpwind
:
public upwind<Type>
{
// Private Data
//- Name of gradient scheme
word gradSchemeName_;
//- Gradient scheme
tmp<fv::gradScheme<Type> > gradScheme_;
// Private Member Functions
//- Disallow default bitwise copy construct
linearUpwind(const linearUpwind&);
//- Disallow default bitwise assignment
void operator=(const linearUpwind&);
public:
//- Runtime type information
TypeName("linearUpwind");
// Constructors
//- Construct from faceFlux
linearUpwind
(
const fvMesh& mesh,
const surfaceScalarField& faceFlux
)
:
upwind<Type>(mesh, faceFlux),
gradSchemeName_("grad"),
gradScheme_
(
new fv::gaussGrad<Type>(mesh)
)
{}
//- Construct from Istream.
// The name of the flux field is read from the Istream and looked-up
// from the mesh objectRegistry
linearUpwind
(
const fvMesh& mesh,
Istream& schemeData
)
:
upwind<Type>(mesh, schemeData),
gradSchemeName_(schemeData),
gradScheme_
(
fv::gradScheme<Type>::New
(
mesh,
mesh.schemesDict().gradScheme(gradSchemeName_)
)
)
{}
//- Construct from faceFlux and Istream
linearUpwind
(
const fvMesh& mesh,
const surfaceScalarField& faceFlux,
Istream& schemeData
)
:
upwind<Type>(mesh, faceFlux, schemeData),
gradSchemeName_(schemeData),
gradScheme_
(
fv::gradScheme<Type>::New
(
mesh,
mesh.schemesDict().gradScheme(gradSchemeName_)
)
)
{}
// Member Functions
//- Return true if this scheme uses an explicit correction
virtual bool corrected() const
{
return true;
}
//- Return the explicit correction to the face-interpolate
virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
correction
(
const GeometricField<Type, fvPatchField, volMesh>&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,239 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.1
\\ / 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 "linearUpwindV.H"
#include "fvMesh.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
Foam::linearUpwindV<Type>::correction
(
const GeometricField<Type, fvPatchField, volMesh>& vf
) const
{
const fvMesh& mesh = this->mesh();
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
(
new GeometricField<Type, fvsPatchField, surfaceMesh>
(
IOobject
(
"linearUpwindCorrection(" + vf.name() + ')',
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh,
dimensioned<Type>(vf.name(), vf.dimensions(), pTraits<Type>::zero)
)
);
GeometricField<Type, fvsPatchField, surfaceMesh>& sfCorr = tsfCorr();
const surfaceScalarField& faceFlux = this->faceFlux_;
const surfaceScalarField& w = mesh.weights();
const labelList& own = mesh.owner();
const labelList& nei = mesh.neighbour();
const volVectorField& C = mesh.C();
const surfaceVectorField& Cf = mesh.Cf();
// Due to gradient cacheing, must take a tmp field
// HJ, 22/Apr/2016
tmp
<
GeometricField
<
typename outerProduct<vector, Type>::type,
fvPatchField,
volMesh
>
> tgradVf = gradScheme_().grad(vf, gradSchemeName_);
const GeometricField
<
typename outerProduct<vector, Type>::type,
fvPatchField,
volMesh
>& gradVf = tgradVf();
// Note: in order for the patchNeighbourField to be correct on coupled
// boundaries, correctBoundaryConditions needs to be called.
// The call shall be moved into the library fvc operators
// Moved to cached gradScheme. HJ, 22/Apr/2016
// gradVf.correctBoundaryConditions();
forAll(faceFlux, facei)
{
vector maxCorr;
if (faceFlux[facei] > 0)
{
maxCorr =
(1 - w[facei])*(vf[nei[facei]] - vf[own[facei]]);
sfCorr[facei] =
(Cf[facei] - C[own[facei]]) & gradVf[own[facei]];
}
else
{
maxCorr =
w[facei]*(vf[own[facei]] - vf[nei[facei]]);
sfCorr[facei] =
(Cf[facei] - C[nei[facei]]) & gradVf[nei[facei]];
}
scalar sfCorrs = magSqr(sfCorr[facei]);
scalar maxCorrs = sfCorr[facei] & maxCorr;
if (sfCorrs > 0)
{
if (maxCorrs < 0)
{
sfCorr[facei] = vector::zero;
}
else if (sfCorrs > maxCorrs)
{
sfCorr[facei] *= maxCorrs/(sfCorrs + VSMALL);
}
}
else if (sfCorrs < 0)
{
if (maxCorrs > 0)
{
sfCorr[facei] = vector::zero;
}
else if (sfCorrs < maxCorrs)
{
sfCorr[facei] *= maxCorrs/(sfCorrs - VSMALL);
}
}
}
// Added missing treatment of coupled boundaries. HJ, 27/Jul/2011
typename GeometricField<Type, fvsPatchField, surfaceMesh>::
GeometricBoundaryField& bSfCorr = sfCorr.boundaryField();
forAll(bSfCorr, patchi)
{
fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
if (pSfCorr.coupled())
{
const fvPatch& p = mesh.boundary()[patchi];
const unallocLabelList& pOwner = p.faceCells();
const vectorField& pCf = Cf.boundaryField()[patchi];
const scalarField& pFaceFlux = faceFlux.boundaryField()[patchi];
const scalarField& pW = w.boundaryField()[patchi];
Field<Type> vfOwn =
vf.boundaryField()[patchi].patchInternalField();
Field<Type> vfNei =
vf.boundaryField()[patchi].patchNeighbourField();
Field<typename outerProduct<vector, Type>::type> pGradVfNei =
gradVf.boundaryField()[patchi].patchNeighbourField();
// Build the d-vectors
// Better version of d-vectors: Zeljko Tukovic, 25/Apr/2010
vectorField pd = p.delta();
forAll(pOwner, facei)
{
vector maxCorr;
label own = pOwner[facei];
if (pFaceFlux[facei] > 0)
{
maxCorr =
(1.0 - pW[facei])*(vfNei[facei] - vfOwn[facei]);
pSfCorr[facei] = (pCf[facei] - C[own]) & gradVf[own];
}
else
{
maxCorr =
pW[facei]*(vfOwn[facei] - vfNei[facei]);
pSfCorr[facei] =
(pCf[facei] - pd[facei] - C[own]) & pGradVfNei[facei];
}
scalar pSfCorrs = magSqr(pSfCorr[facei]);
scalar maxCorrs = pSfCorr[facei] & maxCorr;
if (pSfCorrs > 0)
{
if (maxCorrs < 0)
{
pSfCorr[facei] = vector::zero;
}
else if (pSfCorrs > maxCorrs)
{
pSfCorr[facei] *= maxCorrs/(pSfCorrs + VSMALL);
}
}
else if (pSfCorrs < 0)
{
if (maxCorrs > 0)
{
pSfCorr[facei] = vector::zero;
}
else if (pSfCorrs < maxCorrs)
{
pSfCorr[facei] *= maxCorrs/(pSfCorrs - VSMALL);
}
}
}
}
}
return tsfCorr;
}
namespace Foam
{
makelimitedSurfaceInterpolationTypeScheme(linearUpwindV, vector)
}
// ************************************************************************* //

View file

@ -0,0 +1,164 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.1
\\ / 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::linearUpwindV
Description
linearUpwindV interpolation scheme class derived from upwind and returns
upwind weighting factors but also applies an explicit correction.
SourceFiles
linearUpwindV.C
\*---------------------------------------------------------------------------*/
#ifndef linearUpwindV_H
#define linearUpwindV_H
#include "upwind.H"
#include "gaussGrad.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class linearUpwindV Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class linearUpwindV
:
public upwind<Type>
{
// Private Data
//- Name of gradient scheme
word gradSchemeName_;
//- Gradient scheme
tmp<fv::gradScheme<Type> > gradScheme_;
// Private Member Functions
//- Disallow default bitwise copy construct
linearUpwindV(const linearUpwindV&);
//- Disallow default bitwise assignment
void operator=(const linearUpwindV&);
public:
//- Runtime type information
TypeName("linearUpwindV");
// Constructors
//- Construct from faceFlux
linearUpwindV
(
const fvMesh& mesh,
const surfaceScalarField& faceFlux
)
:
upwind<Type>(mesh, faceFlux),
gradSchemeName_("grad"),
gradScheme_
(
new fv::gaussGrad<Type>(mesh)
)
{}
//- Construct from Istream.
// The name of the flux field is read from the Istream and looked-up
// from the mesh objectRegistry
linearUpwindV
(
const fvMesh& mesh,
Istream& schemeData
)
:
upwind<Type>(mesh, schemeData),
gradSchemeName_(schemeData),
gradScheme_
(
fv::gradScheme<Type>::New
(
mesh,
mesh.schemesDict().gradScheme(gradSchemeName_)
)
)
{}
//- Construct from faceFlux and Istream
linearUpwindV
(
const fvMesh& mesh,
const surfaceScalarField& faceFlux,
Istream& schemeData
)
:
upwind<Type>(mesh, faceFlux, schemeData),
gradSchemeName_(schemeData),
gradScheme_
(
fv::gradScheme<Type>::New
(
mesh,
mesh.schemesDict().gradScheme(gradSchemeName_)
)
)
{}
// Member Functions
//- Return true if this scheme uses an explicit correction
virtual bool corrected() const
{
return true;
}
//- Return the explicit correction to the face-interpolate
virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
correction
(
const GeometricField<Type, fvPatchField, volMesh>&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //