Merge branch 'feature-skew-corrected-gradient' into 'develop'

ENH: New gradient scheme iterativeGaussGrad

See merge request Development/openfoam!500
This commit is contained in:
Andrew Heather
2021-12-08 11:05:43 +00:00
226 changed files with 2688 additions and 181 deletions

View File

@ -433,6 +433,7 @@ $(divSchemes)/gaussDivScheme/gaussDivSchemes.C
gradSchemes = finiteVolume/gradSchemes
$(gradSchemes)/gradScheme/gradSchemes.C
$(gradSchemes)/gaussGrad/gaussGrads.C
$(gradSchemes)/iterativeGaussGrad/iterativeGaussGrads.C
$(gradSchemes)/leastSquaresGrad/leastSquaresVectors.C
$(gradSchemes)/leastSquaresGrad/leastSquaresGrads.C

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -51,6 +52,7 @@ Foam::fv::LeastSquaresGrad<Type, Stencil>::calcGrad
) const
{
typedef typename outerProduct<vector, Type>::type GradType;
typedef GeometricField<GradType, fvPatchField, volMesh> GradFieldType;
const fvMesh& mesh = vtf.mesh();
@ -60,9 +62,9 @@ Foam::fv::LeastSquaresGrad<Type, Stencil>::calcGrad
mesh
);
tmp<GeometricField<GradType, fvPatchField, volMesh>> tlsGrad
tmp<GradFieldType> tlsGrad
(
new GeometricField<GradType, fvPatchField, volMesh>
new GradFieldType
(
IOobject
(
@ -77,7 +79,7 @@ Foam::fv::LeastSquaresGrad<Type, Stencil>::calcGrad
extrapolatedCalculatedFvPatchField<GradType>::typeName
)
);
GeometricField<GradType, fvPatchField, volMesh>& lsGrad = tlsGrad.ref();
GradFieldType& lsGrad = tlsGrad.ref();
Field<GradType>& lsGradIf = lsGrad;
const extendedCentredCellToCellStencil& stencil = lsv.stencil();

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -121,7 +122,7 @@ public:
// Member Functions
//- Return the gradient of the given field to the gradScheme::grad
// for optional caching
//- for optional caching
virtual tmp
<
GeometricField

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -64,7 +64,7 @@ void Foam::fv::LeastSquaresVectors<Stencil>::calcLeastSquaresVectors()
// Create the base form of the dd-tensor
// including components for the "empty" directions
symmTensor dd0(sqr((Vector<label>::one - mesh.geometricD())/2));
const symmTensor dd0(sqr((Vector<label>::one - mesh.geometricD())/2));
forAll(vectors_, i)
{
@ -73,10 +73,10 @@ void Foam::fv::LeastSquaresVectors<Stencil>::calcLeastSquaresVectors()
// The current cell is 0 in the stencil
// Calculate the deltas and sum the weighted dd
for (label j=1; j<lsvi.size(); j++)
for (label j = 1; j < lsvi.size(); ++j)
{
lsvi[j] = lsvi[j] - lsvi[0];
scalar magSqrLsvi = magSqr(lsvi[j]);
const scalar magSqrLsvi = magSqr(lsvi[j]);
dd += sqr(lsvi[j])/magSqrLsvi;
lsvi[j] /= magSqrLsvi;
}
@ -89,7 +89,7 @@ void Foam::fv::LeastSquaresVectors<Stencil>::calcLeastSquaresVectors()
// Finalize the gradient weighting vectors
lsvi[0] = Zero;
for (label j=1; j<lsvi.size(); j++)
for (label j = 1; j < lsvi.size(); ++j)
{
lsvi[j] = dd & lsvi[j];
lsvi[0] -= lsvi[j];

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -62,7 +63,7 @@ class LeastSquaresVectors
:
public MeshObject<fvMesh, MoveableMeshObject, LeastSquaresVectors<Stencil>>
{
// Private data
// Private Data
//- Least-squares gradient vectors
List<List<vector>> vectors_;
@ -95,13 +96,13 @@ public:
// Member functions
//- Return reference to the stencil
//- Return const reference to the stencil
const extendedCentredCellToCellStencil& stencil() const
{
return Stencil::New(this->mesh_);
}
//- Return reference to the least square vectors
//- Return const reference to the least square vectors
const List<List<vector>>& vectors() const
{
return vectors_;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,23 +59,24 @@ Foam::fv::fourthGrad<Type>::calcGrad
// gradient to complete the accuracy.
typedef typename outerProduct<vector, Type>::type GradType;
typedef GeometricField<GradType, fvPatchField, volMesh> GradFieldType;
const fvMesh& mesh = vsf.mesh();
// Assemble the second-order least-square gradient
// Calculate the second-order least-square gradient
tmp<GeometricField<GradType, fvPatchField, volMesh>> tsecondfGrad
tmp<GradFieldType> tsecondfGrad
= leastSquaresGrad<Type>(mesh).grad
(
vsf,
"leastSquaresGrad(" + vsf.name() + ")"
);
const GeometricField<GradType, fvPatchField, volMesh>& secondfGrad =
const GradFieldType& secondfGrad =
tsecondfGrad();
tmp<GeometricField<GradType, fvPatchField, volMesh>> tfGrad
tmp<GradFieldType> tfGrad
(
new GeometricField<GradType, fvPatchField, volMesh>
new GradFieldType
(
IOobject
(
@ -87,7 +89,7 @@ Foam::fv::fourthGrad<Type>::calcGrad
secondfGrad
)
);
GeometricField<GradType, fvPatchField, volMesh>& fGrad = tfGrad.ref();
GradFieldType& fGrad = tfGrad.ref();
const vectorField& C = mesh.C();
@ -132,7 +134,7 @@ Foam::fv::fourthGrad<Type>::calcGrad
const labelUList& faceCells = p.faceCells();
// Build the d-vectors
vectorField pd(p.delta());
const vectorField pd(p.delta());
const Field<GradType> neighbourSecondfGrad
(

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -88,7 +89,7 @@ public:
// Member Functions
//- Return the gradient of the given field to the gradScheme::grad
// for optional caching
//- for optional caching
virtual tmp
<
GeometricField

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -47,12 +48,13 @@ Foam::fv::gaussGrad<Type>::gradf
)
{
typedef typename outerProduct<vector, Type>::type GradType;
typedef GeometricField<GradType, fvPatchField, volMesh> GradFieldType;
const fvMesh& mesh = ssf.mesh();
tmp<GeometricField<GradType, fvPatchField, volMesh>> tgGrad
tmp<GradFieldType> tgGrad
(
new GeometricField<GradType, fvPatchField, volMesh>
new GradFieldType
(
IOobject
(
@ -67,7 +69,7 @@ Foam::fv::gaussGrad<Type>::gradf
extrapolatedCalculatedFvPatchField<GradType>::typeName
)
);
GeometricField<GradType, fvPatchField, volMesh>& gGrad = tgGrad.ref();
GradFieldType& gGrad = tgGrad.ref();
const labelUList& owner = mesh.owner();
const labelUList& neighbour = mesh.neighbour();
@ -78,7 +80,7 @@ Foam::fv::gaussGrad<Type>::gradf
forAll(owner, facei)
{
GradType Sfssf = Sf[facei]*issf[facei];
const GradType Sfssf = Sf[facei]*issf[facei];
igGrad[owner[facei]] += Sfssf;
igGrad[neighbour[facei]] -= Sfssf;
@ -124,12 +126,13 @@ Foam::fv::gaussGrad<Type>::calcGrad
) const
{
typedef typename outerProduct<vector, Type>::type GradType;
typedef GeometricField<GradType, fvPatchField, volMesh> GradFieldType;
tmp<GeometricField<GradType, fvPatchField, volMesh>> tgGrad
tmp<GradFieldType> tgGrad
(
gradf(tinterpScheme_().interpolate(vsf), name)
);
GeometricField<GradType, fvPatchField, volMesh>& gGrad = tgGrad.ref();
GradFieldType& gGrad = tgGrad.ref();
correctBoundaryConditions(vsf, gGrad);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -64,8 +65,9 @@ class gaussGrad
:
public fv::gradScheme<Type>
{
// Private data
// Private Data
//- Interpolation scheme
tmp<surfaceInterpolationScheme<Type>> tinterpScheme_;
@ -121,7 +123,7 @@ public:
// Member Functions
//- Return the gradient of the given field
// calculated using Gauss' theorem on the given surface field
//- calculated using Gauss' theorem on the given surface field
static
tmp
<
@ -134,7 +136,7 @@ public:
);
//- Return the gradient of the given field to the gradScheme::grad
// for optional caching
//- for optional caching
virtual tmp
<
GeometricField
@ -146,7 +148,7 @@ public:
) const;
//- Correct the boundary values of the gradient using the patchField
// snGrad functions
//- snGrad functions
static void correctBoundaryConditions
(
const GeometricField<Type, fvPatchField, volMesh>&,

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -64,8 +65,9 @@ class gradScheme
:
public refCount
{
// Private data
// Private Data
//- Reference to mesh
const fvMesh& mesh_;
@ -121,7 +123,7 @@ public:
// Member Functions
//- Return mesh reference
//- Return const reference to mesh
const fvMesh& mesh() const
{
return mesh_;
@ -141,7 +143,7 @@ public:
) const = 0;
//- Calculate and return the grad of the given field
// which may have been cached
//- which may have been cached
tmp
<
GeometricField
@ -153,8 +155,8 @@ public:
) const;
//- Calculate and return the grad of the given field
// with the default name
// which may have been cached
//- with the default name
//- which may have been cached
tmp
<
GeometricField
@ -165,8 +167,8 @@ public:
) const;
//- Calculate and return the grad of the given field
// with the default name
// which may have been cached
//- with the default name
//- which may have been cached
tmp
<
GeometricField

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -23,9 +24,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Abstract base class for finite volume calculus gradient schemes.
\*---------------------------------------------------------------------------*/
#include "gradScheme.H"

View File

@ -0,0 +1,92 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "iterativeGaussGrad.H"
#include "skewCorrectionVectors.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
Foam::tmp
<
Foam::GeometricField
<
typename Foam::outerProduct<Foam::vector, Type>::type,
Foam::fvPatchField,
Foam::volMesh
>
>
Foam::fv::iterativeGaussGrad<Type>::calcGrad
(
const GeometricField<Type, fvPatchField, volMesh>& vsf,
const word& name
) const
{
typedef typename outerProduct<vector, Type>::type GradType;
typedef GeometricField<GradType, fvPatchField, volMesh> GradFieldType;
typedef GeometricField<GradType, fvsPatchField, surfaceMesh>
GradSurfFieldType;
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfFieldType;
tmp<SurfFieldType> tssf = linearInterpolate(vsf);
const SurfFieldType& ssf = tssf.cref();
tmp<GradFieldType> tgGrad = fv::gaussGrad<Type>::gradf(ssf, name);
GradFieldType& gGrad = tgGrad.ref();
const skewCorrectionVectors& skv = skewCorrectionVectors::New(vsf.mesh());
for (label i = 0; i < nIter_; ++i)
{
tmp<GradSurfFieldType> tsgGrad = linearInterpolate(gGrad);
tmp<SurfFieldType> tcorr = skv() & tsgGrad;
tcorr.ref().dimensions().reset(vsf.dimensions());
if (vsf.mesh().relaxField("grad(" + vsf.name() + ")"))
{
const scalar relax =
vsf.mesh().fieldRelaxationFactor("grad(" + vsf.name() + ")");
// relax*prediction + (1-relax)*old
gGrad *= (1.0 - relax);
gGrad += relax*fv::gaussGrad<Type>::gradf(tcorr + ssf, name);
}
else
{
gGrad = fv::gaussGrad<Type>::gradf(tcorr + ssf, name);
}
}
fv::gaussGrad<Type>::correctBoundaryConditions(vsf, gGrad);
return tgGrad;
}
// ************************************************************************* //

View File

@ -0,0 +1,166 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
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::iterativeGaussGrad
Description
A second-order gradient scheme using face-interpolation,
Gauss' theorem and iterative skew correction.
Usage
Minimal example by using \c system/fvSchemes:
\verbatim
gradSchemes
{
grad(<term>) iterativeGauss <interpolation scheme> <number of iters>;
}
\endverbatim
and by using \c system/fvSolution:
\verbatim
relaxationFactors
{
fields
{
grad(<term>) <relaxation factor>;
}
}
\endverbatim
SourceFiles
iterativeGaussGrad.C
\*---------------------------------------------------------------------------*/
#ifndef iterativeGaussGrad_H
#define iterativeGaussGrad_H
#include "gaussGrad.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace fv
{
/*---------------------------------------------------------------------------*\
Class iterativeGaussGrad Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class iterativeGaussGrad
:
public fv::gaussGrad<Type>
{
// Private Data
//- Number of skew-correction iterations
label nIter_;
// Private Member Functions
//- No copy construct
iterativeGaussGrad(const iterativeGaussGrad&) = delete;
//- No copy assignment
void operator=(const iterativeGaussGrad&) = delete;
public:
//- Runtime type information
TypeName("iterativeGauss");
// Constructors
//- Construct from mesh
iterativeGaussGrad(const fvMesh& mesh)
:
gaussGrad<Type>(mesh),
nIter_(1)
{}
//- Construct from mesh and Istream
iterativeGaussGrad(const fvMesh& mesh, Istream& schemeData)
:
gaussGrad<Type>(mesh, schemeData),
nIter_(readLabel(schemeData))
{
if (nIter_ <= 0)
{
FatalIOErrorInFunction(schemeData)
<< "nIter = " << nIter_
<< " should be > 0"
<< exit(FatalIOError);
}
}
// Member Functions
//- Return the gradient of the given field
//- to the gradScheme::grad for optional caching
virtual tmp
<
GeometricField
<
typename outerProduct<vector, Type>::type,
fvPatchField,
volMesh
>
> calcGrad
(
const GeometricField<Type, fvPatchField, volMesh>& vsf,
const word& name
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "iterativeGaussGrad.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,34 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
--------------------------------------------------------------------------------
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 "iterativeGaussGrad.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makeFvGradScheme(iterativeGaussGrad)
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -100,11 +100,11 @@ void Foam::leastSquaresVectors::calcLeastSquaresVectors()
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
vector d = C[nei] - C[own];
symmTensor wdd = sqr(d)/magSqr(d);
const vector d(C[nei] - C[own]);
const symmTensor wdd(sqr(d)/magSqr(d));
dd[own] += wdd;
dd[nei] += wdd;
}
@ -121,7 +121,7 @@ void Foam::leastSquaresVectors::calcLeastSquaresVectors()
const labelUList& faceCells = p.patch().faceCells();
// Build the d-vectors
vectorField pd(p.delta());
const vectorField pd(p.delta());
forAll(pd, patchFacei)
{
@ -139,10 +139,10 @@ void Foam::leastSquaresVectors::calcLeastSquaresVectors()
// Revisit all faces and calculate the pVectors_ and nVectors_ vectors
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
vector d = C[nei] - C[own];
const vector d(C[nei] - C[own]);
pVectors_[facei] = (invDd[own] & d)/magSqr(d);
nVectors_[facei] = -(invDd[nei] & d)/magSqr(d);
@ -156,7 +156,7 @@ void Foam::leastSquaresVectors::calcLeastSquaresVectors()
const labelUList& faceCells = p.faceCells();
// Build the d-vectors
vectorField pd(p.delta());
const vectorField pd(p.delta());
forAll(pd, patchFacei)
{

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -53,12 +54,13 @@ Foam::fv::leastSquaresGrad<Type>::calcGrad
) const
{
typedef typename outerProduct<vector, Type>::type GradType;
typedef GeometricField<GradType, fvPatchField, volMesh> GradFieldType;
const fvMesh& mesh = vsf.mesh();
tmp<GeometricField<GradType, fvPatchField, volMesh>> tlsGrad
tmp<GradFieldType> tlsGrad
(
new GeometricField<GradType, fvPatchField, volMesh>
new GradFieldType
(
IOobject
(
@ -73,7 +75,7 @@ Foam::fv::leastSquaresGrad<Type>::calcGrad
extrapolatedCalculatedFvPatchField<GradType>::typeName
)
);
GeometricField<GradType, fvPatchField, volMesh>& lsGrad = tlsGrad.ref();
GradFieldType& lsGrad = tlsGrad.ref();
// Get reference to least square vectors
const leastSquaresVectors& lsv = leastSquaresVectors::New(mesh);
@ -86,10 +88,10 @@ Foam::fv::leastSquaresGrad<Type>::calcGrad
forAll(own, facei)
{
label ownFacei = own[facei];
label neiFacei = nei[facei];
const label ownFacei = own[facei];
const label neiFacei = nei[facei];
Type deltaVsf = vsf[neiFacei] - vsf[ownFacei];
const Type deltaVsf(vsf[neiFacei] - vsf[ownFacei]);
lsGrad[ownFacei] += ownLs[facei]*deltaVsf;
lsGrad[neiFacei] -= neiLs[facei]*deltaVsf;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -94,7 +95,7 @@ public:
// Member Functions
//- Return the gradient of the given field to the gradScheme::grad
// for optional caching
//- for optional caching
virtual tmp
<
GeometricField

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -103,13 +103,13 @@ void Foam::leastSquaresVectors::calcLeastSquaresVectors()
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
vector d = C[nei] - C[own];
symmTensor wdd = (magSf[facei]/magSqr(d))*sqr(d);
const vector d(C[nei] - C[own]);
const symmTensor wdd((magSf[facei]/magSqr(d))*sqr(d));
dd[own] += (1 - w[facei])*wdd;
dd[own] += (1.0 - w[facei])*wdd;
dd[nei] += w[facei]*wdd;
}
@ -126,7 +126,7 @@ void Foam::leastSquaresVectors::calcLeastSquaresVectors()
const labelUList& faceCells = p.patch().faceCells();
// Build the d-vectors
vectorField pd(p.delta());
const vectorField pd(p.delta());
if (pw.coupled())
{
@ -158,13 +158,13 @@ void Foam::leastSquaresVectors::calcLeastSquaresVectors()
// Revisit all faces and calculate the pVectors_ and nVectors_ vectors
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
vector d = C[nei] - C[own];
scalar magSfByMagSqrd = magSf[facei]/magSqr(d);
const vector d(C[nei] - C[own]);
const scalar magSfByMagSqrd = magSf[facei]/magSqr(d);
pVectors_[facei] = (1 - w[facei])*magSfByMagSqrd*(invDd[own] & d);
pVectors_[facei] = (1.0 - w[facei])*magSfByMagSqrd*(invDd[own] & d);
nVectors_[facei] = -w[facei]*magSfByMagSqrd*(invDd[nei] & d);
}
@ -179,7 +179,7 @@ void Foam::leastSquaresVectors::calcLeastSquaresVectors()
const labelUList& faceCells = p.faceCells();
// Build the d-vectors
vectorField pd(p.delta());
const vectorField pd(p.delta());
if (pw.coupled())
{
@ -188,7 +188,7 @@ void Foam::leastSquaresVectors::calcLeastSquaresVectors()
const vector& d = pd[patchFacei];
patchLsP[patchFacei] =
((1 - pw[patchFacei])*pMagSf[patchFacei]/magSqr(d))
((1.0 - pw[patchFacei])*pMagSf[patchFacei]/magSqr(d))
*(invDd[faceCells[patchFacei]] & d);
}
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -54,10 +55,12 @@ class leastSquaresVectors
:
public MeshObject<fvMesh, MoveableMeshObject, leastSquaresVectors>
{
// Private data
// Private Data
//- Least-squares gradient vectors
//- Owner least-squares gradient vectors
surfaceVectorField pVectors_;
//- Neighbour least-squares gradient vectors
surfaceVectorField nVectors_;
@ -85,13 +88,13 @@ public:
// Member functions
//- Return reference to owner least square vectors
//- Return const reference to owner least square vectors
const surfaceVectorField& pVectors() const
{
return pVectors_;
}
//- Return reference to neighbour least square vectors
//- Return const reference to neighbour least square vectors
const surfaceVectorField& nVectors() const
{
return nVectors_;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -100,10 +100,10 @@ void Foam::leastSquaresVectors::calcLeastSquaresVectors()
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
symmTensor wdd = sqr(C[nei] - C[own]);
const symmTensor wdd(sqr(C[nei] - C[own]));
dd[own] += wdd;
dd[nei] += wdd;
}
@ -120,11 +120,11 @@ void Foam::leastSquaresVectors::calcLeastSquaresVectors()
const labelUList& faceCells = p.patch().faceCells();
// Build the d-vectors
vectorField pd(p.delta());
const vectorField pdSqr(sqr(p.delta()));
forAll(pd, patchFacei)
{
dd[faceCells[patchFacei]] += sqr(pd[patchFacei]);
dd[faceCells[patchFacei]] += pdSqr[patchFacei];
}
}
@ -136,10 +136,10 @@ void Foam::leastSquaresVectors::calcLeastSquaresVectors()
// Revisit all faces and calculate the pVectors_ and nVectors_ vectors
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
vector d = C[nei] - C[own];
const vector d(C[nei] - C[own]);
pVectors_[facei] = (invDd[own] & d);
nVectors_[facei] = -(invDd[nei] & d);
@ -153,7 +153,7 @@ void Foam::leastSquaresVectors::calcLeastSquaresVectors()
const labelUList& faceCells = p.faceCells();
// Build the d-vectors
vectorField pd(p.delta());
const vectorField pd(p.delta());
forAll(pd, patchFacei)
{

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -107,8 +108,8 @@ Foam::fv::cellLimitedGrad<Type, Limiter>::calcGrad
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
const Type& vsfOwn = vsf[own];
const Type& vsfNei = vsf[nei];
@ -135,7 +136,7 @@ Foam::fv::cellLimitedGrad<Type, Limiter>::calcGrad
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
const label own = pOwner[pFacei];
const Type& vsfNei = psfNei[pFacei];
maxVsf[own] = max(maxVsf[own], vsfNei);
@ -146,7 +147,7 @@ Foam::fv::cellLimitedGrad<Type, Limiter>::calcGrad
{
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
const label own = pOwner[pFacei];
const Type& vsfNei = psf[pFacei];
maxVsf[own] = max(maxVsf[own], vsfNei);
@ -172,8 +173,8 @@ Foam::fv::cellLimitedGrad<Type, Limiter>::calcGrad
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
// owner side
limitFace
@ -201,7 +202,7 @@ Foam::fv::cellLimitedGrad<Type, Limiter>::calcGrad
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
const label own = pOwner[pFacei];
limitFace
(

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -68,6 +69,7 @@ class cellMDLimitedGrad
{
// Private Data
//- Gradient scheme
tmp<fv::gradScheme<Type>> basicGradScheme_;
//- Limiter coefficient
@ -119,7 +121,7 @@ public:
);
//- Return the gradient of the given field to the gradScheme::grad
// for optional caching
//- for optional caching
virtual tmp
<
GeometricField
@ -143,7 +145,7 @@ inline void cellMDLimitedGrad<scalar>::limitFace
const vector& dcf
)
{
scalar extrapolate = dcf & g;
const scalar extrapolate = dcf & g;
if (extrapolate > maxDelta)
{
@ -165,7 +167,7 @@ inline void cellMDLimitedGrad<Type>::limitFace
const vector& dcf
)
{
for (direction cmpt=0; cmpt<Type::nComponents; cmpt++)
for (direction cmpt = 0; cmpt < Type::nComponents; ++cmpt)
{
vector gi(g[cmpt], g[cmpt+3], g[cmpt+6]);
cellMDLimitedGrad<scalar>::limitFace

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -69,11 +70,11 @@ Foam::fv::cellMDLimitedGrad<Foam::scalar>::calcGrad
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
scalar vsfOwn = vsf[own];
scalar vsfNei = vsf[nei];
const scalar vsfOwn = vsf[own];
const scalar vsfNei = vsf[nei];
maxVsf[own] = max(maxVsf[own], vsfNei);
minVsf[own] = min(minVsf[own], vsfNei);
@ -97,8 +98,8 @@ Foam::fv::cellMDLimitedGrad<Foam::scalar>::calcGrad
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
scalar vsfNei = psfNei[pFacei];
const label own = pOwner[pFacei];
const scalar vsfNei = psfNei[pFacei];
maxVsf[own] = max(maxVsf[own], vsfNei);
minVsf[own] = min(minVsf[own], vsfNei);
@ -108,8 +109,8 @@ Foam::fv::cellMDLimitedGrad<Foam::scalar>::calcGrad
{
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
scalar vsfNei = psf[pFacei];
const label own = pOwner[pFacei];
const scalar vsfNei = psf[pFacei];
maxVsf[own] = max(maxVsf[own], vsfNei);
minVsf[own] = min(minVsf[own], vsfNei);
@ -133,8 +134,8 @@ Foam::fv::cellMDLimitedGrad<Foam::scalar>::calcGrad
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
// owner side
limitFace
@ -163,7 +164,7 @@ Foam::fv::cellMDLimitedGrad<Foam::scalar>::calcGrad
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
const label own = pOwner[pFacei];
limitFace
(
@ -212,8 +213,8 @@ Foam::fv::cellMDLimitedGrad<Foam::vector>::calcGrad
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
const vector& vsfOwn = vsf[own];
const vector& vsfNei = vsf[nei];
@ -239,7 +240,7 @@ Foam::fv::cellMDLimitedGrad<Foam::vector>::calcGrad
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
const label own = pOwner[pFacei];
const vector& vsfNei = psfNei[pFacei];
maxVsf[own] = max(maxVsf[own], vsfNei);
@ -250,7 +251,7 @@ Foam::fv::cellMDLimitedGrad<Foam::vector>::calcGrad
{
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
const label own = pOwner[pFacei];
const vector& vsfNei = psf[pFacei];
maxVsf[own] = max(maxVsf[own], vsfNei);
@ -275,8 +276,8 @@ Foam::fv::cellMDLimitedGrad<Foam::vector>::calcGrad
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
// owner side
limitFace
@ -305,7 +306,7 @@ Foam::fv::cellMDLimitedGrad<Foam::vector>::calcGrad
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
const label own = pOwner[pFacei];
limitFace
(

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -68,6 +69,7 @@ class faceLimitedGrad
{
// Private Data
//- Gradient scheme
tmp<fv::gradScheme<Type>> basicGradScheme_;
//- Limiter coefficient
@ -120,7 +122,7 @@ public:
// Member Functions
//- Return the gradient of the given field to the gradScheme::grad
// for optional caching
//- for optional caching
virtual tmp
<
GeometricField

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -67,19 +68,19 @@ Foam::fv::faceLimitedGrad<Foam::scalar>::calcGrad
// create limiter
scalarField limiter(vsf.primitiveField().size(), 1.0);
scalar rk = (1.0/k_ - 1.0);
const scalar rk = (1.0/k_ - 1.0);
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
scalar vsfOwn = vsf[own];
scalar vsfNei = vsf[nei];
const scalar vsfOwn = vsf[own];
const scalar vsfNei = vsf[nei];
scalar maxFace = max(vsfOwn, vsfNei);
scalar minFace = min(vsfOwn, vsfNei);
scalar maxMinFace = rk*(maxFace - minFace);
const scalar maxMinFace = rk*(maxFace - minFace);
maxFace += maxMinFace;
minFace -= maxMinFace;
@ -115,14 +116,14 @@ Foam::fv::faceLimitedGrad<Foam::scalar>::calcGrad
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
const label own = pOwner[pFacei];
scalar vsfOwn = vsf[own];
scalar vsfNei = psfNei[pFacei];
const scalar vsfOwn = vsf[own];
const scalar vsfNei = psfNei[pFacei];
scalar maxFace = max(vsfOwn, vsfNei);
scalar minFace = min(vsfOwn, vsfNei);
scalar maxMinFace = rk*(maxFace - minFace);
const scalar maxMinFace = rk*(maxFace - minFace);
maxFace += maxMinFace;
minFace -= maxMinFace;
@ -138,14 +139,14 @@ Foam::fv::faceLimitedGrad<Foam::scalar>::calcGrad
{
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
const label own = pOwner[pFacei];
scalar vsfOwn = vsf[own];
scalar vsfNei = psf[pFacei];
const scalar vsfOwn = vsf[own];
const scalar vsfNei = psf[pFacei];
scalar maxFace = max(vsfOwn, vsfNei);
scalar minFace = min(vsfOwn, vsfNei);
scalar maxMinFace = rk*(maxFace - minFace);
const scalar maxMinFace = rk*(maxFace - minFace);
maxFace += maxMinFace;
minFace -= maxMinFace;
@ -203,25 +204,25 @@ Foam::fv::faceLimitedGrad<Foam::vector>::calcGrad
// create limiter
scalarField limiter(vvf.primitiveField().size(), 1.0);
scalar rk = (1.0/k_ - 1.0);
const scalar rk = (1.0/k_ - 1.0);
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
vector vvfOwn = vvf[own];
vector vvfNei = vvf[nei];
const vector& vvfOwn = vvf[own];
const vector& vvfNei = vvf[nei];
// owner side
vector gradf = (Cf[facei] - C[own]) & g[own];
vector gradf((Cf[facei] - C[own]) & g[own]);
scalar vsfOwn = gradf & vvfOwn;
scalar vsfNei = gradf & vvfNei;
scalar maxFace = max(vsfOwn, vsfNei);
scalar minFace = min(vsfOwn, vsfNei);
scalar maxMinFace = rk*(maxFace - minFace);
const scalar maxMinFace = rk*(maxFace - minFace);
maxFace += maxMinFace;
minFace -= maxMinFace;
@ -266,19 +267,19 @@ Foam::fv::faceLimitedGrad<Foam::vector>::calcGrad
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
const label own = pOwner[pFacei];
vector vvfOwn = vvf[own];
vector vvfNei = psfNei[pFacei];
const vector& vvfOwn = vvf[own];
const vector& vvfNei = psfNei[pFacei];
vector gradf = (pCf[pFacei] - C[own]) & g[own];
const vector gradf((pCf[pFacei] - C[own]) & g[own]);
scalar vsfOwn = gradf & vvfOwn;
scalar vsfNei = gradf & vvfNei;
const scalar vsfOwn = gradf & vvfOwn;
const scalar vsfNei = gradf & vvfNei;
scalar maxFace = max(vsfOwn, vsfNei);
scalar minFace = min(vsfOwn, vsfNei);
scalar maxMinFace = rk*(maxFace - minFace);
const scalar maxMinFace = rk*(maxFace - minFace);
maxFace += maxMinFace;
minFace -= maxMinFace;
@ -294,19 +295,19 @@ Foam::fv::faceLimitedGrad<Foam::vector>::calcGrad
{
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
const label own = pOwner[pFacei];
vector vvfOwn = vvf[own];
vector vvfNei = psf[pFacei];
const vector& vvfOwn = vvf[own];
const vector& vvfNei = psf[pFacei];
vector gradf = (pCf[pFacei] - C[own]) & g[own];
const vector gradf((pCf[pFacei] - C[own]) & g[own]);
scalar vsfOwn = gradf & vvfOwn;
scalar vsfNei = gradf & vvfNei;
const scalar vsfOwn = gradf & vvfOwn;
const scalar vsfNei = gradf & vvfNei;
scalar maxFace = max(vsfOwn, vsfNei);
scalar minFace = min(vsfOwn, vsfNei);
scalar maxMinFace = rk*(maxFace - minFace);
const scalar maxMinFace = rk*(maxFace - minFace);
maxFace += maxMinFace;
minFace -= maxMinFace;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -68,6 +69,7 @@ class faceMDLimitedGrad
{
// Private Data
//- Gradient scheme
tmp<fv::gradScheme<Type>> basicGradScheme_;
//- Limiter coefficient
@ -120,7 +122,7 @@ public:
// Member Functions
//- Return the gradient of the given field to the gradScheme::grad
// for optional caching
//- for optional caching
virtual tmp
<
GeometricField

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -65,22 +66,22 @@ Foam::fv::faceMDLimitedGrad<Foam::scalar>::calcGrad
const volVectorField& C = mesh.C();
const surfaceVectorField& Cf = mesh.Cf();
scalar rk = (1.0/k_ - 1.0);
const scalar rk = (1.0/k_ - 1.0);
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
scalar vsfOwn = vsf[own];
scalar vsfNei = vsf[nei];
const scalar vsfOwn = vsf[own];
const scalar vsfNei = vsf[nei];
scalar maxFace = max(vsfOwn, vsfNei);
scalar minFace = min(vsfOwn, vsfNei);
if (k_ < 1.0)
{
scalar maxMinFace = rk*(maxFace - minFace);
const scalar maxMinFace = rk*(maxFace - minFace);
maxFace += maxMinFace;
minFace -= maxMinFace;
}
@ -119,7 +120,7 @@ Foam::fv::faceMDLimitedGrad<Foam::scalar>::calcGrad
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
const label own = pOwner[pFacei];
scalar vsfOwn = vsf[own];
scalar vsfNei = psfNei[pFacei];
@ -129,7 +130,7 @@ Foam::fv::faceMDLimitedGrad<Foam::scalar>::calcGrad
if (k_ < 1.0)
{
scalar maxMinFace = rk*(maxFace - minFace);
const scalar maxMinFace = rk*(maxFace - minFace);
maxFace += maxMinFace;
minFace -= maxMinFace;
}
@ -147,17 +148,17 @@ Foam::fv::faceMDLimitedGrad<Foam::scalar>::calcGrad
{
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
const label own = pOwner[pFacei];
scalar vsfOwn = vsf[own];
scalar vsfNei = psf[pFacei];
const scalar vsfOwn = vsf[own];
const scalar vsfNei = psf[pFacei];
scalar maxFace = max(vsfOwn, vsfNei);
scalar minFace = min(vsfOwn, vsfNei);
if (k_ < 1.0)
{
scalar maxMinFace = rk*(maxFace - minFace);
const scalar maxMinFace = rk*(maxFace - minFace);
maxFace += maxMinFace;
minFace -= maxMinFace;
}
@ -205,22 +206,22 @@ Foam::fv::faceMDLimitedGrad<Foam::vector>::calcGrad
const volVectorField& C = mesh.C();
const surfaceVectorField& Cf = mesh.Cf();
scalar rk = (1.0/k_ - 1.0);
const scalar rk = (1.0/k_ - 1.0);
forAll(owner, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
vector vvfOwn = vvf[own];
vector vvfNei = vvf[nei];
const vector& vvfOwn = vvf[own];
const vector& vvfNei = vvf[nei];
vector maxFace = max(vvfOwn, vvfNei);
vector minFace = min(vvfOwn, vvfNei);
vector maxFace(max(vvfOwn, vvfNei));
vector minFace(min(vvfOwn, vvfNei));
if (k_ < 1.0)
{
vector maxMinFace = rk*(maxFace - minFace);
const vector maxMinFace(rk*(maxFace - minFace));
maxFace += maxMinFace;
minFace -= maxMinFace;
}
@ -261,17 +262,17 @@ Foam::fv::faceMDLimitedGrad<Foam::vector>::calcGrad
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
const label own = pOwner[pFacei];
vector vvfOwn = vvf[own];
vector vvfNei = psfNei[pFacei];
const vector& vvfOwn = vvf[own];
const vector& vvfNei = psfNei[pFacei];
vector maxFace = max(vvfOwn, vvfNei);
vector minFace = min(vvfOwn, vvfNei);
vector maxFace(max(vvfOwn, vvfNei));
vector minFace(min(vvfOwn, vvfNei));
if (k_ < 1.0)
{
vector maxMinFace = rk*(maxFace - minFace);
const vector maxMinFace(rk*(maxFace - minFace));
maxFace += maxMinFace;
minFace -= maxMinFace;
}
@ -288,17 +289,17 @@ Foam::fv::faceMDLimitedGrad<Foam::vector>::calcGrad
{
forAll(pOwner, pFacei)
{
label own = pOwner[pFacei];
const label own = pOwner[pFacei];
vector vvfOwn = vvf[own];
vector vvfNei = psf[pFacei];
const vector& vvfOwn = vvf[own];
const vector& vvfNei = psf[pFacei];
vector maxFace = max(vvfOwn, vvfNei);
vector minFace = min(vvfOwn, vvfNei);
vector maxFace(max(vvfOwn, vvfNei));
vector minFace(min(vvfOwn, vvfNei));
if (k_ < 1.0)
{
vector maxMinFace = rk*(maxFace - minFace);
const vector maxMinFace(rk*(maxFace - minFace));
maxFace += maxMinFace;
minFace -= maxMinFace;
}

View File

@ -0,0 +1,15 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
#------------------------------------------------------------------------------
cleanCase0
rm -rf dynamicCode
rm -rf 0.orig
rm -rf system
rm -rf constant
rm -rf results
rm -rf plots
#------------------------------------------------------------------------------

View File

@ -0,0 +1,139 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
#------------------------------------------------------------------------------
# settings
# operand setups
setups="
Gauss-linear
leastSquares
Gauss-pointLinear
iterativeGauss-linear-1
cellLimited-Gauss-linear-1
cellLimited-leastSquares-1
cellLimited-Gauss-pointLinear-1
cellLimited-iterativeGauss-linear-5-1
faceLimited-Gauss-linear-1
faceLimited-leastSquares-1
faceLimited-Gauss-pointLinear-1
faceLimited-iterativeGauss-linear-5-1
cellMDLimited-Gauss-linear-1
cellMDLimited-leastSquares-1
cellMDLimited-Gauss-pointLinear-1
cellMDLimited-iterativeGauss-linear-5-1
faceMDLimited-Gauss-linear-1
faceMDLimited-leastSquares-1
faceMDLimited-Gauss-pointLinear-1
faceMDLimited-iterativeGauss-linear-5-1
iterativeGauss-linear-2
iterativeGauss-linear-3
iterativeGauss-linear-4
iterativeGauss-linear-5
iterativeGauss-linear-10
iterativeGauss-linear-20
"
# flag to enable computations in parallel mode
parallel=false
#------------------------------------------------------------------------------
#######################################
# Collect results into a given path
# and clean the case for the next run
# Arguments:
# $1 = Path to move results
# Outputs:
# Writes info to stdout
#######################################
collect() {
[ $# -eq 0 ] && { echo "Usage: $0 dir-model"; exit 1; }
collection="$1"
dirResult=results/"$collection"
if [ ! -d "$dirResult" ]
then
echo " # Collecting results and settings into $dirResult"
mkdir -p "$dirResult"
[ -d postProcessing ] && mv -f postProcessing "$dirResult"
[ -d processor0 ] && mv -f processor* "$dirResult"
mv -f log.* "$dirResult"
mv -f constant "$dirResult"/
mv -f system "$dirResult"/
mv -f 0 "$dirResult"/
echo " # Cleaning up the case"
cleanTimeDirectories
cleanPostProcessing
else
echo " # Directory $dirResult already exists"
echo " # Skipping the computation"
fi
}
#------------------------------------------------------------------------------
for setup in $setups
do
echo ""
echo "# Computations for the setup: $setup"
echo ""
dirSetup="setups.orig/$setup"
if [ ! -d "$dirSetup" ]
then
echo "Setup directory: $dirSetup" \
"could not be found - skipping execution" 1>&2
exit 1
fi
cp -rfL "$dirSetup/constant" .
cp -rfL "$dirSetup/system" .
[ -d 0 ] && rm -rf 0
mkdir 0
runApplication checkMesh \
-allTopology -allGeometry -constant \
-writeAllFields -writeAllSurfaceFields
if [ "$parallel" = true ]
then
runApplication decomposePar
runParallel postProcess -constant
runApplication reconstructPar
else
runApplication postProcess -constant
fi
collect "$setup"
done
#------------------------------------------------------------------------------

View File

@ -0,0 +1,239 @@
#!/bin/bash
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
# settings
# operand setups
groups="
group1
group2
group3
group4
group5
group6
group7
"
group1="
Gauss-linear
leastSquares
Gauss-pointLinear
iterativeGauss-linear-1
"
group2="
iterativeGauss-linear-1
iterativeGauss-linear-2
iterativeGauss-linear-3
iterativeGauss-linear-4
iterativeGauss-linear-5
iterativeGauss-linear-10
iterativeGauss-linear-20
"
group3="
iterativeGauss-linear-5
cellLimited-iterativeGauss-linear-5-1
cellMDLimited-iterativeGauss-linear-5-1
faceLimited-iterativeGauss-linear-5-1
faceMDLimited-iterativeGauss-linear-5-1
"
group4="
cellLimited-Gauss-linear-1
cellLimited-leastSquares-1
cellLimited-Gauss-pointLinear-1
cellLimited-iterativeGauss-linear-5-1
"
group5="
cellMDLimited-Gauss-linear-1
cellMDLimited-leastSquares-1
cellMDLimited-Gauss-pointLinear-1
cellMDLimited-iterativeGauss-linear-5-1
"
group6="
faceLimited-Gauss-linear-1
faceLimited-leastSquares-1
faceLimited-Gauss-pointLinear-1
faceLimited-iterativeGauss-linear-5-1
"
group7="
faceMDLimited-Gauss-linear-1
faceMDLimited-leastSquares-1
faceMDLimited-Gauss-pointLinear-1
faceMDLimited-iterativeGauss-linear-5-1
"
#------------------------------------------------------------------------------
collect_data(){
groupName="$1"
shift 1
group=$@
echo $groupName
local members
local meanErrors
local meanMagErrors
local covErrors
local covMagErrors
n=0
for member in $group
do
meanSample="results/$member/postProcessing/volFieldAverage/0/volFieldValue.dat"
covSample="results/$member/postProcessing/volFieldCoV/0/volFieldValue.dat"
meanError=$(tail -n 1 $meanSample | awk '{ print $2 }' )
meanMagError=$(tail -n 1 $meanSample | awk '{ print $3 }' )
covError=$(tail -n 1 $covSample | awk '{ print $2/10.0 }' )
covMagError=$(tail -n 1 $covSample | awk '{ print $3/10.0 }' )
meanErrors[$n]="$meanError"
meanMagErrors[$n]="$meanMagError"
covErrors[$n]="$covError"
covMagErrors[$n]="$covMagError"
members[$n]="$member"
n=$(($n+1))
done
file="results/$groupName-error-stats.dat"
[ ! -f $file ] && \
echo "# Scheme Mean CoV/10" >> $file && \
for ((j = 0; j < "${#members[@]}"; j++)) \
do printf "%s %.16f %.16f\n" "${members[$j]}" "${meanErrors[$j]}" "${covErrors[$j]}" \
>> $file; done
file="results/$groupName-mag-error-stats.dat"
[ ! -f $file ] && \
echo "# Scheme Mean CoV/10" >> $file && \
for ((j = 0; j < "${#members[@]}"; j++)) \
do printf "%s %.16f %.16f\n" "${members[$j]}" "${meanMagErrors[$j]}" "${covMagErrors[$j]}" \
>> $file; done
}
plot_error_stats() {
groupName="$1"
echo " Plotting the error statistics for the group: $groupName"
samples="results/$groupName-error-stats.dat"
image="plots/$groupName-error-stats.png"
gnuplot<<PLT_ERROR_STATS
set terminal pngcairo font "helvetica,20" size 1000, 1000
set grid
set auto x
set yrange [0:2]
set style data histograms
set style histogram cluster gap 1
set style fill solid border -1
set boxwidth 0.9
set xtic rotate by -45 scale 0
set key right top
set key opaque
set key samplen 2
set key spacing 0.75
set ylabel "Error [\%]"
set offset .2, .05
set output "$image"
set title "Error vs Schemes: $groupName"
samples="$samples"
plot samples \
u 2:xtic(1) t "Mean", \
'' u 3 t "Coefficient of variation/10"
PLT_ERROR_STATS
}
plot_mag_error_stats() {
groupName="$1"
echo " Plotting the mag error statistics for the group: $groupName"
samples="results/$groupName-mag-error-stats.dat"
image="plots/$groupName-mag-error-stats.png"
gnuplot<<PLT_MAG_ERROR_STATS
set terminal pngcairo font "helvetica,20" size 1000, 1000
set grid
set auto x
set yrange [0:2]
set style data histograms
set style histogram cluster gap 1
set style fill solid border -1
set boxwidth 0.9
set xtic rotate by -45 scale 0
set key right top
set key opaque
set key samplen 2
set key spacing 0.75
set ylabel "Magnitude error [\%]"
set offset .2, .05
set output "$image"
set title "Magnitude error vs Schemes: $groupName"
samples="$samples"
plot samples \
u 2:xtic(1) t "Mean", \
'' u 3 t "Coefficient of variation/10"
PLT_MAG_ERROR_STATS
}
#------------------------------------------------------------------------------
# Requires gnuplot
command -v gnuplot >/dev/null || {
echo "gnuplot not found - skipping graph creation" 1>&2
exit 1
}
# Requires awk
command -v awk >/dev/null || {
echo "awk not found - skipping graph creation" 1>&2
exit 1
}
# Check "results" directory
[ -d "results" ] || {
echo "No results directory found - skipping graph creation" 1>&2
exit 1
}
#------------------------------------------------------------------------------
dirPlots="plots"
[ -d "$dirPlots" ] || mkdir -p "$dirPlots"
rm -f results/*.dat
for group in $groups
do
groupName="$group"
collect_data "$groupName" ${!group}
plot_error_stats "$groupName"
plot_mag_error_stats "$groupName"
done
#------------------------------------------------------------------------------

View File

@ -0,0 +1 @@
../common/constant

View File

@ -0,0 +1 @@
../../common/system/controlDict

View File

@ -0,0 +1 @@
../../common/system/cuttingPlane

View File

@ -0,0 +1 @@
../../common/system/decomposeParDict

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default none;
}
gradSchemes
{
default Gauss linear;
}
divSchemes
{
default none;
}
laplacianSchemes
{
default none;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default none;
}
// ************************************************************************* //

View File

@ -0,0 +1 @@
../../common/system/fvSolution

View File

@ -0,0 +1 @@
../../common/system/runtimePostProcessing

View File

@ -0,0 +1 @@
../common/constant

View File

@ -0,0 +1 @@
../../common/system/controlDict

View File

@ -0,0 +1 @@
../../common/system/cuttingPlane

View File

@ -0,0 +1 @@
../../common/system/decomposeParDict

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default none;
}
gradSchemes
{
default Gauss pointLinear;
}
divSchemes
{
default none;
}
laplacianSchemes
{
default none;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default none;
}
// ************************************************************************* //

View File

@ -0,0 +1 @@
../../common/system/fvSolution

View File

@ -0,0 +1 @@
../../common/system/runtimePostProcessing

View File

@ -0,0 +1 @@
../../common/system/controlDict

View File

@ -0,0 +1 @@
../../common/system/cuttingPlane

View File

@ -0,0 +1 @@
../../common/system/decomposeParDict

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default none;
}
gradSchemes
{
default cellLimited Gauss linear 1;
}
divSchemes
{
default none;
}
laplacianSchemes
{
default none;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default none;
}
// ************************************************************************* //

View File

@ -0,0 +1 @@
../../common/system/fvSolution

View File

@ -0,0 +1 @@
../../common/system/runtimePostProcessing

View File

@ -0,0 +1 @@
../../common/system/decomposeParDict

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default none;
}
gradSchemes
{
default cellLimited Gauss pointLinear 1;
}
divSchemes
{
default none;
}
laplacianSchemes
{
default none;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default none;
}
// ************************************************************************* //

View File

@ -0,0 +1 @@
../../common/system/runtimePostProcessing

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default none;
}
gradSchemes
{
default cellLimited iterativeGauss linear 5 1;
}
divSchemes
{
default none;
}
laplacianSchemes
{
default none;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default none;
}
// ************************************************************************* //

View File

@ -0,0 +1 @@
../../common/system/controlDict

View File

@ -0,0 +1 @@
../../common/system/cuttingPlane

View File

@ -0,0 +1 @@
../../common/system/decomposeParDict

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default none;
}
gradSchemes
{
default cellLimited leastSquares 1;
}
divSchemes
{
default none;
}
laplacianSchemes
{
default none;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default none;
}
// ************************************************************************* //

View File

@ -0,0 +1 @@
../../common/system/fvSolution

View File

@ -0,0 +1 @@
../../common/system/runtimePostProcessing

View File

@ -0,0 +1 @@
../../common/system/controlDict

View File

@ -0,0 +1 @@
../../common/system/cuttingPlane

View File

@ -0,0 +1 @@
../../common/system/decomposeParDict

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default none;
}
gradSchemes
{
default cellMDLimited Gauss linear 1;
}
divSchemes
{
default none;
}
laplacianSchemes
{
default none;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default none;
}
// ************************************************************************* //

View File

@ -0,0 +1 @@
../../common/system/fvSolution

View File

@ -0,0 +1 @@
../../common/system/runtimePostProcessing

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default none;
}
gradSchemes
{
default cellMDLimited Gauss pointLinear 1;
}
divSchemes
{
default none;
}
laplacianSchemes
{
default none;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default none;
}
// ************************************************************************* //

View File

@ -0,0 +1 @@
../../common/system/runtimePostProcessing

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default none;
}
gradSchemes
{
default cellMDLimited iterativeGauss linear 5 1;
}
divSchemes
{
default none;
}
laplacianSchemes
{
default none;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default none;
}
// ************************************************************************* //

View File

@ -0,0 +1 @@
../../common/system/controlDict

View File

@ -0,0 +1 @@
../../common/system/cuttingPlane

View File

@ -0,0 +1 @@
../../common/system/decomposeParDict

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default none;
}
gradSchemes
{
default cellMDLimited leastSquares 1;
}
divSchemes
{
default none;
}
laplacianSchemes
{
default none;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default none;
}
// ************************************************************************* //

View File

@ -0,0 +1 @@
../../common/system/fvSolution

View File

@ -0,0 +1 @@
../../common/system/runtimePostProcessing

Some files were not shown because too many files have changed in this diff Show More