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 void Foam::extendedCellToFaceStencil::collectData
34 const mapDistribute& map,
35 const labelListList& stencil,
36 const GeometricField<Type, fvPatchField, volMesh>& fld,
37 List<List<Type> >& stencilFld
40 // 1. Construct cell data in compact addressing
41 List<Type> compactFld(map.constructSize(), pTraits<Type>::zero);
43 // Insert my internal values
46 compactFld[cellI] = fld[cellI];
48 // Insert my boundary values
49 label nCompact = fld.size();
50 forAll(fld.boundaryField(), patchI)
52 const fvPatchField<Type>& pfld = fld.boundaryField()[patchI];
56 compactFld[nCompact++] = pfld[i];
61 map.distribute(compactFld);
64 stencilFld.setSize(stencil.size());
66 forAll(stencil, faceI)
68 const labelList& compactCells = stencil[faceI];
70 stencilFld[faceI].setSize(compactCells.size());
72 forAll(compactCells, i)
74 stencilFld[faceI][i] = compactFld[compactCells[i]];
81 Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
82 Foam::extendedCellToFaceStencil::weightedSum
84 const mapDistribute& map,
85 const labelListList& stencil,
86 const GeometricField<Type, fvPatchField, volMesh>& fld,
87 const List<List<scalar> >& stencilWeights
90 const fvMesh& mesh = fld.mesh();
92 // Collect internal and boundary values
93 List<List<Type> > stencilFld;
94 collectData(map, stencil, fld, stencilFld);
96 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
98 new GeometricField<Type, fvsPatchField, surfaceMesh>
103 mesh.time().timeName(),
118 GeometricField<Type, fvsPatchField, surfaceMesh>& sf = tsfCorr();
121 for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
123 const List<Type>& stField = stencilFld[faceI];
124 const List<scalar>& stWeight = stencilWeights[faceI];
128 sf[faceI] += stField[i]*stWeight[i];
132 // Boundaries. Either constrained or calculated so assign value
133 // directly (instead of nicely using operator==)
134 typename GeometricField<Type, fvsPatchField, surfaceMesh>::
135 GeometricBoundaryField& bSfCorr = sf.boundaryField();
137 forAll(bSfCorr, patchi)
139 fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
141 if (pSfCorr.coupled())
143 label faceI = pSfCorr.patch().patch().start();
147 const List<Type>& stField = stencilFld[faceI];
148 const List<scalar>& stWeight = stencilWeights[faceI];
152 pSfCorr[i] += stField[j]*stWeight[j];
164 // ************************************************************************* //