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"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 template<class Type, class Limiter, template<class> class LimitFunc>
40 Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
41 Foam::DeferredCorrectionLimitedScheme<Type, Limiter, LimitFunc>::correction
43 const GeometricField<Type, fvPatchField, volMesh>& vf
46 // Correction = full interpolation minus upwinded part
48 surfaceInterpolationScheme<Type>::interpolate
51 limitedSurfaceInterpolationScheme<Type>::weights(vf)
53 - upwindScheme_.interpolate(vf);
57 template<class Type, class Limiter, template<class> class LimitFunc>
58 tmp<surfaceScalarField>
59 DeferredCorrectionLimitedScheme<Type, Limiter, LimitFunc>::limiter
61 const GeometricField<Type, fvPatchField, volMesh>& phi
64 const fvMesh& mesh = this->mesh();
66 tmp<surfaceScalarField> tLimiter
68 new surfaceScalarField
72 type() + "Limiter(" + phi.name() + ')',
73 mesh.time().timeName(),
80 surfaceScalarField& lim = tLimiter();
82 tmp<GeometricField<typename Limiter::phiType, fvPatchField, volMesh> >
83 tlPhi = LimitFunc<Type>()(phi);
85 const GeometricField<typename Limiter::phiType, fvPatchField, volMesh>&
88 GeometricField<typename Limiter::gradPhiType, fvPatchField, volMesh>
89 gradc(fvc::grad(lPhi));
91 // Note: in order for the patchNeighbourField to be correct on coupled
92 // boundaries, correctBoundaryConditions needs to be called.
93 // The call shall be moved into the library fvc operators
94 gradc.correctBoundaryConditions();
96 const surfaceScalarField& CDweights = mesh.surfaceInterpolation::weights();
98 const unallocLabelList& owner = mesh.owner();
99 const unallocLabelList& neighbour = mesh.neighbour();
101 const vectorField& C = mesh.C();
103 scalarField& pLim = lim.internalField();
107 label own = owner[face];
108 label nei = neighbour[face];
110 pLim[face] = Limiter::limiter
113 this->faceFlux_[face],
122 surfaceScalarField::GeometricBoundaryField& bLim = lim.boundaryField();
124 forAll (bLim, patchi)
126 scalarField& pLim = bLim[patchi];
128 if (bLim[patchi].coupled())
130 const scalarField& pCDweights = CDweights.boundaryField()[patchi];
131 const scalarField& pFaceFlux =
132 this->faceFlux_.boundaryField()[patchi];
133 Field<typename Limiter::phiType> plPhiP =
134 lPhi.boundaryField()[patchi].patchInternalField();
135 Field<typename Limiter::phiType> plPhiN =
136 lPhi.boundaryField()[patchi].patchNeighbourField();
137 Field<typename Limiter::gradPhiType> pGradcP =
138 gradc.boundaryField()[patchi].patchInternalField();
139 Field<typename Limiter::gradPhiType> pGradcN =
140 gradc.boundaryField()[patchi].patchNeighbourField();
142 // Build the d-vectors
143 // Better version of d-vectors: Zeljko Tukovic, 25/Apr/2010
144 vectorField pd = bLim[patchi].patch().delta();
148 pLim[face] = Limiter::limiter
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 } // End namespace Foam
174 // ************************************************************************* //