1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "volFields.H"
28 #include "surfaceFields.H"
30 #include "coupledFvPatchFields.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 template<class Type, class Limiter, template<class> class LimitFunc>
40 tmp<surfaceScalarField> LimitedScheme<Type, Limiter, LimitFunc>::limiter
42 const GeometricField<Type, fvPatchField, volMesh>& phi
45 const fvMesh& mesh = this->mesh();
47 tmp<surfaceScalarField> tLimiter
49 new surfaceScalarField
53 type() + "Limiter(" + phi.name() + ')',
54 mesh.time().timeName(),
61 surfaceScalarField& lim = tLimiter();
63 tmp<GeometricField<typename Limiter::phiType, fvPatchField, volMesh> >
64 tlPhi = LimitFunc<Type>()(phi);
66 const GeometricField<typename Limiter::phiType, fvPatchField, volMesh>&
69 GeometricField<typename Limiter::gradPhiType, fvPatchField, volMesh>
70 gradc(fvc::grad(lPhi));
72 const surfaceScalarField& CDweights = mesh.surfaceInterpolation::weights();
74 const unallocLabelList& owner = mesh.owner();
75 const unallocLabelList& neighbour = mesh.neighbour();
77 const vectorField& C = mesh.C();
79 scalarField& pLim = lim.internalField();
83 label own = owner[face];
84 label nei = neighbour[face];
86 pLim[face] = Limiter::limiter
89 this->faceFlux_[face],
98 surfaceScalarField::GeometricBoundaryField& bLim = lim.boundaryField();
102 scalarField& pLim = bLim[patchi];
104 if (bLim[patchi].coupled())
106 const scalarField& pCDweights = CDweights.boundaryField()[patchi];
107 const scalarField& pFaceFlux =
108 this->faceFlux_.boundaryField()[patchi];
109 Field<typename Limiter::phiType> plPhiP =
110 lPhi.boundaryField()[patchi].patchInternalField();
111 Field<typename Limiter::phiType> plPhiN =
112 lPhi.boundaryField()[patchi].patchNeighbourField();
113 Field<typename Limiter::gradPhiType> pGradcP =
114 gradc.boundaryField()[patchi].patchInternalField();
115 Field<typename Limiter::gradPhiType> pGradcN =
116 gradc.boundaryField()[patchi].patchNeighbourField();
118 // Build the d-vectors
120 mesh.Sf().boundaryField()[patchi]
122 mesh.magSf().boundaryField()[patchi]
123 *mesh.deltaCoeffs().boundaryField()[patchi]
126 if (!mesh.orthogonal())
128 pd -= mesh.correctionVectors().boundaryField()[patchi]
129 /mesh.deltaCoeffs().boundaryField()[patchi];
134 pLim[face] = Limiter::limiter
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 } // End namespace Foam
160 // ************************************************************************* //