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 "extendedCellToFaceStencil.H"
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
33 Foam::extendedUpwindCellToFaceStencil::weightedSum
35 const surfaceScalarField& phi,
36 const GeometricField<Type, fvPatchField, volMesh>& fld,
37 const List<List<scalar> >& ownWeights,
38 const List<List<scalar> >& neiWeights
41 const fvMesh& mesh = fld.mesh();
43 // Collect internal and boundary values
44 List<List<Type> > ownFld;
45 collectData(ownMap(), ownStencil(), fld, ownFld);
46 List<List<Type> > neiFld;
47 collectData(neiMap(), neiStencil(), fld, neiFld);
49 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
51 new GeometricField<Type, fvsPatchField, surfaceMesh>
56 mesh.time().timeName(),
71 GeometricField<Type, fvsPatchField, surfaceMesh>& sf = tsfCorr();
74 for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
78 // Flux out of owner. Use upwind (= owner side) stencil.
79 const List<Type>& stField = ownFld[faceI];
80 const List<scalar>& stWeight = ownWeights[faceI];
84 sf[faceI] += stField[i]*stWeight[i];
89 const List<Type>& stField = neiFld[faceI];
90 const List<scalar>& stWeight = neiWeights[faceI];
94 sf[faceI] += stField[i]*stWeight[i];
99 // Boundaries. Either constrained or calculated so assign value
100 // directly (instead of nicely using operator==)
101 typename GeometricField<Type, fvsPatchField, surfaceMesh>::
102 GeometricBoundaryField& bSfCorr = sf.boundaryField();
104 forAll(bSfCorr, patchi)
106 fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
108 if (pSfCorr.coupled())
110 label faceI = pSfCorr.patch().patch().start();
114 if (phi.boundaryField()[patchi][i] > 0)
116 // Flux out of owner. Use upwind (= owner side) stencil.
117 const List<Type>& stField = ownFld[faceI];
118 const List<scalar>& stWeight = ownWeights[faceI];
122 pSfCorr[i] += stField[j]*stWeight[j];
127 const List<Type>& stField = neiFld[faceI];
128 const List<scalar>& stWeight = neiWeights[faceI];
132 pSfCorr[i] += stField[j]*stWeight[j];
144 // ************************************************************************* //