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 "cellMDLimitedGrad.H"
28 #include "gaussGrad.H"
31 #include "surfaceMesh.H"
32 #include "volFields.H"
33 #include "fixedValueFvPatchFields.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 makeFvGradScheme(cellMDLimitedGrad)
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 tmp<volVectorField> cellMDLimitedGrad<scalar>::grad
54 const volScalarField& vsf
57 const fvMesh& mesh = vsf.mesh();
59 tmp<volVectorField> tGrad = basicGradScheme_().grad(vsf);
66 volVectorField& g = tGrad();
68 const unallocLabelList& owner = mesh.owner();
69 const unallocLabelList& neighbour = mesh.neighbour();
71 const volVectorField& C = mesh.C();
72 const surfaceVectorField& Cf = mesh.Cf();
74 scalarField maxVsf(vsf.internalField());
75 scalarField minVsf(vsf.internalField());
79 label own = owner[facei];
80 label nei = neighbour[facei];
82 scalar vsfOwn = vsf[own];
83 scalar vsfNei = vsf[nei];
85 maxVsf[own] = max(maxVsf[own], vsfNei);
86 minVsf[own] = min(minVsf[own], vsfNei);
88 maxVsf[nei] = max(maxVsf[nei], vsfOwn);
89 minVsf[nei] = min(minVsf[nei], vsfOwn);
93 const volScalarField::GeometricBoundaryField& bsf = vsf.boundaryField();
97 const fvPatchScalarField& psf = bsf[patchi];
99 const unallocLabelList& pOwner = mesh.boundary()[patchi].faceCells();
103 scalarField psfNei = psf.patchNeighbourField();
105 forAll(pOwner, pFacei)
107 label own = pOwner[pFacei];
108 scalar vsfNei = psfNei[pFacei];
110 maxVsf[own] = max(maxVsf[own], vsfNei);
111 minVsf[own] = min(minVsf[own], vsfNei);
116 forAll(pOwner, pFacei)
118 label own = pOwner[pFacei];
119 scalar vsfNei = psf[pFacei];
121 maxVsf[own] = max(maxVsf[own], vsfNei);
122 minVsf[own] = min(minVsf[own], vsfNei);
132 scalarField maxMinVsf = (1.0/k_ - 1.0)*(maxVsf - minVsf);
143 label own = owner[facei];
144 label nei = neighbour[facei];
168 const unallocLabelList& pOwner = mesh.boundary()[patchi].faceCells();
169 const vectorField& pCf = Cf.boundaryField()[patchi];
171 forAll(pOwner, pFacei)
173 label own = pOwner[pFacei];
185 g.correctBoundaryConditions();
186 gaussGrad<scalar>::correctBoundaryConditions(vsf, g);
193 tmp<volTensorField> cellMDLimitedGrad<vector>::grad
195 const volVectorField& vsf
198 const fvMesh& mesh = vsf.mesh();
200 tmp<volTensorField> tGrad = basicGradScheme_().grad(vsf);
207 volTensorField& g = tGrad();
209 const unallocLabelList& owner = mesh.owner();
210 const unallocLabelList& neighbour = mesh.neighbour();
212 const volVectorField& C = mesh.C();
213 const surfaceVectorField& Cf = mesh.Cf();
215 vectorField maxVsf(vsf.internalField());
216 vectorField minVsf(vsf.internalField());
220 label own = owner[facei];
221 label nei = neighbour[facei];
223 const vector& vsfOwn = vsf[own];
224 const vector& vsfNei = vsf[nei];
226 maxVsf[own] = max(maxVsf[own], vsfNei);
227 minVsf[own] = min(minVsf[own], vsfNei);
229 maxVsf[nei] = max(maxVsf[nei], vsfOwn);
230 minVsf[nei] = min(minVsf[nei], vsfOwn);
234 const volVectorField::GeometricBoundaryField& bsf = vsf.boundaryField();
238 const fvPatchVectorField& psf = bsf[patchi];
239 const unallocLabelList& pOwner = mesh.boundary()[patchi].faceCells();
243 vectorField psfNei = psf.patchNeighbourField();
245 forAll(pOwner, pFacei)
247 label own = pOwner[pFacei];
248 const vector& vsfNei = psfNei[pFacei];
250 maxVsf[own] = max(maxVsf[own], vsfNei);
251 minVsf[own] = min(minVsf[own], vsfNei);
256 forAll(pOwner, pFacei)
258 label own = pOwner[pFacei];
259 const vector& vsfNei = psf[pFacei];
261 maxVsf[own] = max(maxVsf[own], vsfNei);
262 minVsf[own] = min(minVsf[own], vsfNei);
272 vectorField maxMinVsf = (1.0/k_ - 1.0)*(maxVsf - minVsf);
283 label own = owner[facei];
284 label nei = neighbour[facei];
308 const unallocLabelList& pOwner = mesh.boundary()[patchi].faceCells();
309 const vectorField& pCf = Cf.boundaryField()[patchi];
311 forAll(pOwner, pFacei)
313 label own = pOwner[pFacei];
325 g.correctBoundaryConditions();
326 gaussGrad<vector>::correctBoundaryConditions(vsf, g);
332 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
334 } // End namespace fv
336 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
338 } // End namespace Foam
340 // ************************************************************************* //