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) 2011-2016 OpenFOAM Foundation
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> flatFld(map.constructSize(), Zero);
41 
42  // Insert my internal values
43  forAll(fld, celli)
44  {
45  flatFld[celli] = fld[celli];
46  }
47  // Insert my boundary values
49  {
50  const fvsPatchField<Type>& pfld = fld.boundaryField()[patchi];
51 
52  label nCompact = pfld.patch().start();
53 
54  forAll(pfld, i)
55  {
56  flatFld[nCompact++] = pfld[i];
57  }
58  }
59 
60  // Do all swapping
61  map.distribute(flatFld);
62 
63  // 2. Pull to stencil
64  stencilFld.setSize(stencil.size());
65 
66  forAll(stencil, facei)
67  {
68  const labelList& compactCells = stencil[facei];
69 
70  stencilFld[facei].setSize(compactCells.size());
71 
72  forAll(compactCells, i)
73  {
74  stencilFld[facei][i] = flatFld[compactCells[i]];
75  }
76  }
77 }
78 
79 
80 template<class Type>
83 (
84  const mapDistribute& map,
85  const labelListList& stencil,
87  const List<List<scalar>>& stencilWeights
88 )
89 {
90  const fvMesh& mesh = fld.mesh();
91 
92  // Collect internal and boundary values
93  List<List<Type>> stencilFld;
94  collectData(map, stencil, fld, stencilFld);
95 
97  (
99  (
100  IOobject
101  (
102  fld.name(),
103  mesh.time().timeName(),
104  mesh
105  ),
106  mesh,
108  (
109  fld.name(),
110  fld.dimensions(),
111  Zero
112  )
113  )
114  );
116 
117  // cells
118  forAll(sf, celli)
119  {
120  const List<Type>& stField = stencilFld[celli];
121  const List<scalar>& stWeight = stencilWeights[celli];
122 
123  forAll(stField, i)
124  {
125  sf[celli] += stField[i]*stWeight[i];
126  }
127  }
128 
129  // Boundaries values?
130 
131  return tsfCorr;
132 }
133 
134 
135 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
Generic GeometricField class.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:715
Generic dimensioned Type class.
static void collectData(const mapDistribute &map, const labelListList &stencil, const GeometricField< T, fvsPatchField, surfaceMesh > &fld, List< List< T >> &stencilFld)
Use map to get the data into stencil order.
dynamicFvMesh & mesh
static tmp< GeometricField< Type, fvPatchField, volMesh > > weightedSum(const mapDistribute &map, const labelListList &stencil, const GeometricField< Type, fvsPatchField, surfaceMesh > &fld, const List< List< scalar >> &stencilWeights)
Sum surface field contributions to create cell values.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
static const zero Zero
Definition: zero.H:91
const dimensionSet & dimensions() const
Return dimensions.
const fvPatch & patch() const
Return patch.
volScalarField sf(fieldObject, mesh)
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
void setSize(const label)
Reset size of List.
Definition: List.C:295
label patchi
Class containing processor-to-processor mapping information.
const Mesh & mesh() const
Return mesh.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
A class for managing temporary objects.
Definition: PtrList.H:54
label constructSize() const
Constructed data size.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
const word & name() const
Return name.
Definition: IOobject.H:260
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243