FreeFOAM The Cross-Platform CFD Toolkit
extendedFaceToCellStencilTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const mapDistribute& map,
34  const labelListList& stencil,
36  List<List<Type> >& stencilFld
37 )
38 {
39  // 1. Construct face data in compact addressing
40  List<Type> compactFld(map.constructSize(), pTraits<Type>::zero);
41 
42  // Insert my internal values
43  forAll(fld, cellI)
44  {
45  compactFld[cellI] = fld[cellI];
46  }
47  // Insert my boundary values
48  label nCompact = fld.size();
49  forAll(fld.boundaryField(), patchI)
50  {
51  const fvsPatchField<Type>& pfld = fld.boundaryField()[patchI];
52 
53  forAll(pfld, i)
54  {
55  compactFld[nCompact++] = pfld[i];
56  }
57  }
58 
59  // Do all swapping
60  map.distribute(compactFld);
61 
62  // 2. Pull to stencil
63  stencilFld.setSize(stencil.size());
64 
65  forAll(stencil, faceI)
66  {
67  const labelList& compactCells = stencil[faceI];
68 
69  stencilFld[faceI].setSize(compactCells.size());
70 
71  forAll(compactCells, i)
72  {
73  stencilFld[faceI][i] = compactFld[compactCells[i]];
74  }
75  }
76 }
77 
78 
79 template<class Type>
82 (
83  const mapDistribute& map,
84  const labelListList& stencil,
86  const List<List<scalar> >& stencilWeights
87 )
88 {
89  const fvMesh& mesh = fld.mesh();
90 
91  // Collect internal and boundary values
92  List<List<Type> > stencilFld;
93  collectData(map, stencil, fld, stencilFld);
94 
96  (
98  (
99  IOobject
100  (
101  fld.name(),
102  mesh.time().timeName(),
103  mesh
104  ),
105  mesh,
107  (
108  fld.name(),
109  fld.dimensions(),
111  )
112  )
113  );
115 
116  // cells
117  forAll(sf, cellI)
118  {
119  const List<Type>& stField = stencilFld[cellI];
120  const List<scalar>& stWeight = stencilWeights[cellI];
121 
122  forAll(stField, i)
123  {
124  sf[cellI] += stField[i]*stWeight[i];
125  }
126  }
127 
128  // Boundaries values?
129 
130  return tsfCorr;
131 }
132 
133 
134 // ************************ vim: set sw=4 sts=4 et: ************************ //