1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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"
31 #include "surfaceInterpolate.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 template<class Type, class PhiLimiter>
41 tmp<surfaceScalarField> PhiScheme<Type, PhiLimiter>::limiter
43 const GeometricField<Type, fvPatchField, volMesh>& phi
46 const fvMesh& mesh = this->mesh();
48 tmp<surfaceScalarField> tLimiter
50 new surfaceScalarField
55 mesh.time().timeName(),
62 surfaceScalarField& Limiter = tLimiter();
64 const surfaceScalarField& CDweights = mesh.surfaceInterpolation::weights();
66 const surfaceVectorField& Sf = mesh.Sf();
67 const surfaceScalarField& magSf = mesh.magSf();
69 const unallocLabelList& owner = mesh.owner();
70 const unallocLabelList& neighbour = mesh.neighbour();
72 tmp<surfaceScalarField> tUflux = this->faceFlux_;
74 if (this->faceFlux_.dimensions() == dimDensity*dimVelocity*dimArea)
76 const volScalarField& rho =
77 phi.db().objectRegistry::lookupObject<volScalarField>("rho");
78 tUflux = this->faceFlux_/fvc::interpolate(rho);
80 else if (this->faceFlux_.dimensions() != dimVelocity*dimArea)
84 "PhiScheme<PhiLimiter>::limiter"
85 "(const GeometricField<Type, fvPatchField, volMesh>& phi)"
86 ) << "dimensions of faceFlux are not correct"
90 const surfaceScalarField& Uflux = tUflux();
92 scalarField& pLimiter = Limiter.internalField();
94 forAll(pLimiter, face)
96 pLimiter[face] = PhiLimiter::limiter
101 phi[neighbour[face]],
108 surfaceScalarField::GeometricBoundaryField& bLimiter =
109 Limiter.boundaryField();
111 forAll(bLimiter, patchI)
113 scalarField& pLimiter = bLimiter[patchI];
115 if (bLimiter[patchI].coupled())
117 const scalarField& pCDweights = CDweights.boundaryField()[patchI];
118 const vectorField& pSf = Sf.boundaryField()[patchI];
119 const scalarField& pmagSf = magSf.boundaryField()[patchI];
120 const scalarField& pFaceFlux = Uflux.boundaryField()[patchI];
122 phi.boundaryField()[patchI].patchInternalField();
124 phi.boundaryField()[patchI].patchNeighbourField();
126 forAll(pLimiter, face)
128 pLimiter[face] = PhiLimiter::limiter
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 } // End namespace Foam
153 // ************************************************************************* //