bugfix fixedBlended scheme, cosmetics changes

- actually blend correction factors as well in fixedBlended scheme

- consistency change: move 'linearUpwindV' into same directory as
  'linearUpwind', move correction code from .H into .C code.

- minor docu format/spelling changes

A more general question:
~~~~~~~~~~~~~~~~~~~~~~~~
- would it make more sense to use template specializations for the
  '*V' differencing schemes?
This commit is contained in:
Mark Olesen
2009-05-08 13:05:19 +02:00
parent d2a78f7e96
commit 1c101ec1a8
32 changed files with 271 additions and 190 deletions

View File

@ -206,7 +206,7 @@ $(limitedSchemes)/limitedSurfaceInterpolationScheme/limitedSurfaceInterpolationS
$(limitedSchemes)/upwind/upwind.C
$(limitedSchemes)/blended/blended.C
$(limitedSchemes)/linearUpwind/linearUpwind.C
$(limitedSchemes)/linearUpwindV/linearUpwindV.C
$(limitedSchemes)/linearUpwind/linearUpwindV.C
$(limitedSchemes)/Gamma/Gamma.C
$(limitedSchemes)/SFCD/SFCD.C
$(limitedSchemes)/Minmod/Minmod.C

View File

@ -21,7 +21,7 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "cellLimitedGrad.H"
@ -377,7 +377,7 @@ tmp<volTensorField> cellLimitedGrad<vector>::grad
);
}
}
if (fv::debug)
{
Info<< "gradient limiter for: " << vsf.name()

View File

@ -21,7 +21,7 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "cellMDLimitedGrad.H"

View File

@ -41,7 +41,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class LimitedLimiter Declaration
Class LimitedLimiter Declaration
\*---------------------------------------------------------------------------*/
template<class LimitedScheme>

View File

@ -41,7 +41,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class Limited01Limiter Declaration
Class Limited01Limiter Declaration
\*---------------------------------------------------------------------------*/
template<class LimitedScheme>

View File

@ -79,18 +79,17 @@ public:
{
scalar phiCD = cdWeight*phiP + (1 - cdWeight)*phiN;
scalar phif;
scalar phiU;
scalar phiU, phif;
if (faceFlux > 0)
{
phif = 0.5*(phiCD + phiP + (1 - cdWeight)*(d & gradcP));
phiU = phiP;
phif = 0.5*(phiCD + phiP + (1 - cdWeight)*(d & gradcP));
}
else
{
phif = 0.5*(phiCD + phiN - cdWeight*(d & gradcN));
phiU = phiN;
phif = 0.5*(phiCD + phiN - cdWeight*(d & gradcN));
}
// Calculate the effective limiter for the QUICK interpolation

View File

@ -81,8 +81,7 @@ public:
scalar phiCD = gradfV & (cdWeight*phiP + (1 - cdWeight)*phiN);
scalar phif;
scalar phiU;
scalar phiU, phif;
if (faceFlux > 0)
{
@ -95,7 +94,7 @@ public:
phif = 0.5*(phiCD + phiU - cdWeight*(gradfV & (d & gradcN)));
}
// Calculate the effective limiter for the linearUpwind interpolation
// Calculate the effective limiter for the QUICK interpolation
scalar QLimiter = (phif - phiU)/stabilise(phiCD - phiU, SMALL);
// Limit the limiter between upwind and downwind

View File

@ -26,7 +26,7 @@ Class
Foam::filteredLinearLimiter
Description
Class to generate weighting factors for the filtered-linear
Class to generate weighting factors for the filteredLinear
differencing scheme.
The aim is to remove high-frequency modes with "staggering"

View File

@ -26,7 +26,7 @@ Class
Foam::filteredLinear2Limiter
Description
Class to generate weighting factors for the filtered-linear-2
Class to generate weighting factors for the filteredLinear2
differencing scheme.
The aim is to remove high-frequency modes with "staggering"

View File

@ -26,11 +26,13 @@ Class
Foam::filteredLinear2VLimiter
Description
Class to generate weighting factors for the filteredLinear2V differencing
scheme. The aim is to remove high-frequency modes with "staggering"
characteristics from vector fields by comparing the face gradient in the
direction of maximum gradient with both neighbouring cell gradients and
introduce small amounts of upwind in order to damp these modes.
Class to generate weighting factors for the filteredLinear2V
differencing scheme.
The aim is to remove high-frequency modes with "staggering"
characteristics from vector fields by comparing the face gradient in
the direction of maximum gradient with both neighbouring cell gradients
and introduce small amounts of upwind in order to damp these modes.
Used in conjunction with the template class LimitedScheme.

View File

@ -26,7 +26,7 @@ Class
Foam::filteredLinear3Limiter
Description
Class to generate weighting factors for the filtered-linear-3
Class to generate weighting factors for the filteredLinear
differencing scheme.
The aim is to remove high-frequency modes with "staggering"
@ -79,7 +79,7 @@ public:
<< "coefficient = " << k_
<< " should be >= 0 and <= 1"
<< exit(FatalIOError);
}
}
}
scalar limiter

View File

@ -26,11 +26,13 @@ Class
Foam::filteredLinear3VLimiter
Description
Class to generate weighting factors for the filteredLinear3V differencing
scheme. The aim is to remove high-frequency modes with "staggering"
characteristics from vector fields by comparing the face gradient in the
direction of maximum gradient with both neighbouring cell gradients and
introduce small amounts of upwind in order to damp these modes.
Class to generate weighting factors for the filteredLinear3V
differencing scheme.
The aim is to remove high-frequency modes with "staggering"
characteristics from vector fields by comparing the face gradient in
the direction of maximum gradient with both neighbouring cell gradients
and introduce small amounts of upwind in order to damp these modes.
Used in conjunction with the template class LimitedScheme.
@ -77,7 +79,7 @@ public:
<< "coefficient = " << k_
<< " should be >= 0 and <= 1"
<< exit(FatalIOError);
}
}
}
scalar limiter

View File

@ -90,7 +90,7 @@ public:
)
{}
//- Construct from Istream.
//- Construct from Istream.
// The name of the flux field is read from the Istream and looked-up
// from the mesh objectRegistry
linearUpwind
@ -142,8 +142,9 @@ public:
virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
correction
(
const GeometricField<Type, fvPatchField, volMesh>& vf
const GeometricField<Type, fvPatchField, volMesh>&
) const;
};

View File

@ -0,0 +1,136 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#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
(
vf.name(),
mesh.time().timeName(),
mesh
),
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 vectorField& C = mesh.C();
const vectorField& Cf = mesh.Cf();
GeometricField
<typename outerProduct<vector, Type>::type, fvPatchField, volMesh>
gradVf = gradScheme_().grad(vf);
forAll(faceFlux, facei)
{
vector maxCorr;
if (faceFlux[facei] > 0.0)
{
maxCorr =
(1.0 - 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);
}
}
}
return tsfCorr;
}
namespace Foam
{
makelimitedSurfaceInterpolationTypeScheme(linearUpwindV, vector)
}
// ************************************************************************* //

View File

@ -90,7 +90,7 @@ public:
)
{}
//- Construct from Istream.
//- Construct from Istream.
// The name of the flux field is read from the Istream and looked-up
// from the mesh objectRegistry
linearUpwindV
@ -142,97 +142,9 @@ public:
virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
correction
(
const GeometricField<Type, fvPatchField, volMesh>& vf
) const
{
const fvMesh& mesh = this->mesh();
const GeometricField<Type, fvPatchField, volMesh>&
) const;
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
(
new GeometricField<Type, fvsPatchField, surfaceMesh>
(
IOobject
(
vf.name(),
mesh.time().timeName(),
mesh
),
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 vectorField& C = mesh.C();
const vectorField& Cf = mesh.Cf();
GeometricField
<typename outerProduct<vector, Type>::type, fvPatchField, volMesh>
gradVf = gradScheme_().grad(vf);
forAll(faceFlux, facei)
{
vector maxCorr;
if (faceFlux[facei] > 0.0)
{
maxCorr =
(1.0 - 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);
}
}
}
return tsfCorr;
}
};

View File

@ -1,39 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "linearUpwindV.H"
#include "fvMesh.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makelimitedSurfaceInterpolationTypeScheme(linearUpwindV, vector)
}
// ************************************************************************* //

View File

@ -58,11 +58,11 @@ class UpwindFitData
// Private data
//- For each face of the mesh store the coefficients to multiply the
// stencil cell values by if the flow is from the owner
// stencil cell values by if the flow is from the owner
List<scalarList> owncoeffs_;
//- For each face of the mesh store the coefficients to multiply the
// stencil cell values by if the flow is from the neighbour
// stencil cell values by if the flow is from the neighbour
List<scalarList> neicoeffs_;

View File

@ -26,7 +26,7 @@ Class
Foam::UpwindFitScheme
Description
Upwind biased fit surface interpolation scheme which applies an explicit
Upwind biased fit surface interpolation scheme that applies an explicit
correction to linear.
\*---------------------------------------------------------------------------*/

View File

@ -27,7 +27,8 @@ Class
Description
BiLinear polynomial for interpolation fitting.
Can be used with the CentredFit scheme to crate a biLinear surface
Can be used with the CentredFit scheme to create a biLinear surface
interpolation scheme
\*---------------------------------------------------------------------------*/

View File

@ -28,7 +28,7 @@ Class
Description
Cubic polynomial for upwind biased interpolation fitting.
Can be used with the UpwindFit scheme to crate a cubic surface
Can be used with the UpwindFit scheme to create a cubic surface
interpolation scheme
\*---------------------------------------------------------------------------*/

View File

@ -125,6 +125,7 @@ public:
}
}
//- Construct from mesh, faceFlux and Istream
fixedBlended
(
@ -165,7 +166,8 @@ public:
// Member Functions
//- Return the interpolation weighting factors
tmp<surfaceScalarField> weights
tmp<surfaceScalarField>
weights
(
const GeometricField<Type, fvPatchField, volMesh>& vf
) const
@ -175,15 +177,74 @@ public:
+ (scalar(1.0) - blendingFactor_)*tScheme2_().weights(vf);
}
//- Return the face-interpolate of the given cell field
// with explicit correction
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
interpolate(const GeometricField<Type, fvPatchField, volMesh>& vf) const
interpolate
(
const GeometricField<Type, fvPatchField, volMesh>& vf
) const
{
return
blendingFactor_*tScheme1_().interpolate(vf)
+ (scalar(1.0) - blendingFactor_)*tScheme2_().interpolate(vf);
}
//- Return true if this scheme uses an explicit correction
virtual bool corrected() const
{
return tScheme1_().corrected() || tScheme2_().corrected();
}
//- Return the explicit correction to the face-interpolate
// for the given field
virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
correction
(
const GeometricField<Type, fvPatchField, volMesh>& vf
) const
{
if (tScheme1_().corrected())
{
if (tScheme2_().corrected())
{
return
(
blendingFactor_
* tScheme1_().correction(vf)
+ (scalar(1.0) - blendingFactor_)
* tScheme2_().correction(vf)
);
}
else
{
return
(
blendingFactor_
* tScheme1_().correction(vf)
);
}
}
else if (tScheme2_().corrected())
{
return
(
(scalar(1.0) - blendingFactor_)
* tScheme2_().correction(vf)
);
}
else
{
return tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
(
NULL
);
}
}
};

View File

@ -26,9 +26,10 @@ Class
Foam::harmonic
Description
Harmonic-mean differencing scheme class. This scheme interpolates 1/field
using a scheme specified at run-time and return the reciprocal of the
interpolate.
Harmonic-mean differencing scheme class.
This scheme interpolates 1/field using a scheme specified at run-time
and return the reciprocal of the interpolate.
SourceFiles
harmonic.C
@ -76,7 +77,7 @@ public:
surfaceInterpolationScheme<scalar>(mesh)
{}
//- Construct from Istream.
//- Construct from Istream.
// The name of the flux field is read from the Istream and looked-up
// from the mesh objectRegistry
harmonic

View File

@ -27,7 +27,8 @@ Class
Description
Linear polynomial for interpolation fitting.
Can be used with the CentredFit scheme to crate a linear surface
Can be used with the CentredFit scheme to create a linear surface
interpolation scheme
\*---------------------------------------------------------------------------*/

View File

@ -26,9 +26,10 @@ Class
Foam::localMax
Description
LocalMax-mean differencing scheme class. This scheme interpolates 1/field
using a scheme specified at run-time and return the reciprocal of the
interpolate.
LocalMax-mean differencing scheme class.
This scheme interpolates 1/field using a scheme specified at run-time
and return the reciprocal of the interpolate.
SourceFiles
localMax.C

View File

@ -26,9 +26,10 @@ Class
Foam::localMin
Description
LocalMin-mean differencing scheme class. This scheme interpolates 1/field
using a scheme specified at run-time and return the reciprocal of the
interpolate.
LocalMin-mean differencing scheme class.
This scheme interpolates 1/field using a scheme specified at run-time
and return the reciprocal of the interpolate.
SourceFiles
localMin.C

View File

@ -27,9 +27,11 @@ Class
Description
Outlet-stabilised interpolation scheme which applies upwind differencing
to the faces of teh cells adjacent to outlets. This is particularly
useful to stabilise the velocity at entrainment boundaries for LES
cases using linear or other centred differencing schemes.
to the faces of the cells adjacent to outlets.
This is particularly useful to stabilise the velocity at entrainment
boundaries for LES cases using linear or other centred differencing
schemes.
SourceFiles
outletStabilised.C
@ -138,7 +140,7 @@ public:
forAll(vf.boundaryField(), patchi)
{
if
if
(
isA<zeroGradientFvPatchField<Type> >
(vf.boundaryField()[patchi])
@ -187,7 +189,7 @@ public:
{
if (tScheme_().corrected())
{
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tcorr =
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tcorr =
tScheme_().correction(vf);
GeometricField<Type, fvsPatchField, surfaceMesh>& corr = tcorr();
@ -197,7 +199,7 @@ public:
forAll(vf.boundaryField(), patchi)
{
if
if
(
isA<zeroGradientFvPatchField<Type> >
(vf.boundaryField()[patchi])
@ -230,7 +232,7 @@ public:
}
else
{
return
return
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >(NULL);
}
}

View File

@ -28,7 +28,7 @@ Class
Description
Quadratic polynomial for centred interpolation fitting.
Can be used with the CentredFit scheme to crate a quadratic surface
Can be used with the CentredFit scheme to create a quadratic surface
interpolation scheme
\*---------------------------------------------------------------------------*/

View File

@ -30,7 +30,7 @@ Description
quadratic normal to the face,
linear in the plane of the face for consistency with 2nd-order Gauss.
Can be used with the CentredFit scheme to crate a quadratic surface
Can be used with the CentredFit scheme to create a quadratic surface
interpolation scheme
\*---------------------------------------------------------------------------*/

View File

@ -28,7 +28,7 @@ Class
Description
Quadratic polynomial for upwind biased interpolation fitting.
Can be used with the UpwindFit scheme to crate a quadratic surface
Can be used with the UpwindFit scheme to create a quadratic surface
interpolation scheme
\*---------------------------------------------------------------------------*/

View File

@ -28,7 +28,7 @@ Class
Description
Quadratic polynomial for upwind biased interpolation fitting.
Can be used with the UpwindFit scheme to crate a quadratic surface
Can be used with the UpwindFit scheme to create a quadratic surface
interpolation scheme
\*---------------------------------------------------------------------------*/

View File

@ -27,6 +27,7 @@ Class
Description
Inversed weight central-differencing interpolation scheme class.
Useful for inverse weighted and harmonic interpolations.
SourceFiles

View File

@ -26,7 +26,7 @@ Class
Foam::skewCorrected
Description
Skewness-corrected interpolation scheme which applies an explicit
Skewness-corrected interpolation scheme that applies an explicit
correction to given scheme.
SourceFiles