1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "volFields.H"
27 #include "surfaceFields.H"
29 #include "coupledFvPatchFields.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 template<class Type, class Limiter, template<class> class LimitFunc>
34 Foam::tmp<Foam::surfaceScalarField>
35 Foam::LimitedScheme<Type, Limiter, LimitFunc>::limiter
37 const GeometricField<Type, fvPatchField, volMesh>& phi
40 const fvMesh& mesh = this->mesh();
42 tmp<surfaceScalarField> tLimiter
44 new surfaceScalarField
48 type() + "Limiter(" + phi.name() + ')',
49 mesh.time().timeName(),
56 surfaceScalarField& lim = tLimiter();
58 tmp<GeometricField<typename Limiter::phiType, fvPatchField, volMesh> >
59 tlPhi = LimitFunc<Type>()(phi);
61 const GeometricField<typename Limiter::phiType, fvPatchField, volMesh>&
64 tmp<GeometricField<typename Limiter::gradPhiType, fvPatchField, volMesh> >
65 tgradc(fvc::grad(lPhi));
66 const GeometricField<typename Limiter::gradPhiType, fvPatchField, volMesh>&
69 const surfaceScalarField& CDweights = mesh.surfaceInterpolation::weights();
71 const labelUList& owner = mesh.owner();
72 const labelUList& neighbour = mesh.neighbour();
74 const vectorField& C = mesh.C();
76 scalarField& pLim = lim.internalField();
80 label own = owner[face];
81 label nei = neighbour[face];
83 pLim[face] = Limiter::limiter
86 this->faceFlux_[face],
95 surfaceScalarField::GeometricBoundaryField& bLim = lim.boundaryField();
99 scalarField& pLim = bLim[patchi];
101 if (bLim[patchi].coupled())
103 const scalarField& pCDweights = CDweights.boundaryField()[patchi];
104 const scalarField& pFaceFlux =
105 this->faceFlux_.boundaryField()[patchi];
107 const Field<typename Limiter::phiType> plPhiP
109 lPhi.boundaryField()[patchi].patchInternalField()
111 const Field<typename Limiter::phiType> plPhiN
113 lPhi.boundaryField()[patchi].patchNeighbourField()
115 const Field<typename Limiter::gradPhiType> pGradcP
117 gradc.boundaryField()[patchi].patchInternalField()
119 const Field<typename Limiter::gradPhiType> pGradcN
121 gradc.boundaryField()[patchi].patchNeighbourField()
124 // Build the d-vectors
127 mesh.Sf().boundaryField()[patchi]
129 mesh.magSf().boundaryField()[patchi]
130 * mesh.deltaCoeffs().boundaryField()[patchi]
134 if (!mesh.orthogonal())
136 pd -= mesh.correctionVectors().boundaryField()[patchi]
137 /mesh.deltaCoeffs().boundaryField()[patchi];
142 pLim[face] = Limiter::limiter
164 // ************************************************************************* //