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 "extendedCellToFaceStencil.H"
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31 Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
32 Foam::extendedUpwindCellToFaceStencil::weightedSum
34 const surfaceScalarField& phi,
35 const GeometricField<Type, fvPatchField, volMesh>& fld,
36 const List<List<scalar> >& ownWeights,
37 const List<List<scalar> >& neiWeights
40 const fvMesh& mesh = fld.mesh();
42 // Collect internal and boundary values
43 List<List<Type> > ownFld;
44 collectData(ownMap(), ownStencil(), fld, ownFld);
45 List<List<Type> > neiFld;
46 collectData(neiMap(), neiStencil(), fld, neiFld);
48 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
50 new GeometricField<Type, fvsPatchField, surfaceMesh>
55 mesh.time().timeName(),
70 GeometricField<Type, fvsPatchField, surfaceMesh>& sf = tsfCorr();
73 for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
77 // Flux out of owner. Use upwind (= owner side) stencil.
78 const List<Type>& stField = ownFld[faceI];
79 const List<scalar>& stWeight = ownWeights[faceI];
83 sf[faceI] += stField[i]*stWeight[i];
88 const List<Type>& stField = neiFld[faceI];
89 const List<scalar>& stWeight = neiWeights[faceI];
93 sf[faceI] += stField[i]*stWeight[i];
98 // Boundaries. Either constrained or calculated so assign value
99 // directly (instead of nicely using operator==)
100 typename GeometricField<Type, fvsPatchField, surfaceMesh>::
101 GeometricBoundaryField& bSfCorr = sf.boundaryField();
103 forAll(bSfCorr, patchi)
105 fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
107 if (pSfCorr.coupled())
109 label faceI = pSfCorr.patch().start();
113 if (phi.boundaryField()[patchi][i] > 0)
115 // Flux out of owner. Use upwind (= owner side) stencil.
116 const List<Type>& stField = ownFld[faceI];
117 const List<scalar>& stWeight = ownWeights[faceI];
121 pSfCorr[i] += stField[j]*stWeight[j];
126 const List<Type>& stField = neiFld[faceI];
127 const List<scalar>& stWeight = neiWeights[faceI];
131 pSfCorr[i] += stField[j]*stWeight[j];
143 // ************************************************************************* //