All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
extendedCellToCellStencilTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2013-2018 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 
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
31 template<class Type, class WeightType>
33 <
35  <
39  >
41 (
42  const mapDistribute& map,
43  const labelListList& stencil,
44  const GeometricField<Type, fvPatchField, volMesh>& fld,
45  const List<List<WeightType>>& stencilWeights
46 )
47 {
48  typedef typename outerProduct<WeightType, Type>::type WeightedType;
49  typedef GeometricField<WeightedType, fvPatchField, volMesh>
50  WeightedFieldType;
51 
52  const fvMesh& mesh = fld.mesh();
53 
54  // Collect internal and boundary values
55  List<List<Type>> stencilFld;
56  extendedCellToFaceStencil::collectData(map, stencil, fld, stencilFld);
57 
58  tmp<WeightedFieldType> twf
59  (
60  new WeightedFieldType
61  (
62  IOobject
63  (
64  fld.name(),
65  mesh.time().timeName(),
66  mesh
67  ),
68  mesh,
69  dimensioned<WeightedType>
70  (
71  fld.name(),
72  fld.dimensions(),
73  Zero
74  )
75  )
76  );
77  WeightedFieldType& wf = twf();
78 
79  forAll(wf, celli)
80  {
81  const List<Type>& stField = stencilFld[celli];
82  const List<WeightType>& stWeight = stencilWeights[celli];
83 
84  forAll(stField, i)
85  {
86  wf[celli] += stWeight[i]*stField[i];
87  }
88  }
89 
90  // Boundaries values?
91 
92  return twf;
93 }
94 
95 
96 // ************************************************************************* //
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:90
Generic GeometricField class.
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:53
dynamicFvMesh & mesh
static const zero Zero
Definition: zero.H:97
static void collectData(const mapDistribute &map, const labelListList &stencil, const GeometricField< T, fvPatchField, volMesh > &fld, List< List< T >> &stencilFld)
Use map to get the data into stencil order.
A class for managing temporary objects.
Definition: PtrList.H:53
static tmp< GeometricField< typename outerProduct< WeightType, Type >::type, fvPatchField, volMesh > > weightedSum(const mapDistribute &map, const labelListList &stencil, const GeometricField< Type, fvPatchField, volMesh > &fld, const List< List< WeightType >> &stencilWeights)
Sum surface field contributions to create cell values.