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-2022 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 <
36 (
37  const distributionMap& map,
38  const labelListList& stencil,
39  const VolField<Type>& fld,
40  const List<List<WeightType>>& stencilWeights
41 )
42 {
43  typedef typename outerProduct<WeightType, Type>::type WeightedType;
44 
45  const fvMesh& mesh = fld.mesh();
46 
47  // Collect internal and boundary values
48  List<List<Type>> stencilFld;
49  extendedCellToFaceStencil::collectData(map, stencil, fld, stencilFld);
50 
51  tmp<VolField<WeightedType>> twf
52  (
53  new VolField<WeightedType>
54  (
55  IOobject
56  (
57  fld.name(),
58  mesh.time().name(),
59  mesh
60  ),
61  mesh,
62  dimensioned<WeightedType>
63  (
64  fld.name(),
65  fld.dimensions(),
66  Zero
67  )
68  )
69  );
70  VolField<WeightedType>& wf = twf();
71 
72  forAll(wf, celli)
73  {
74  const List<Type>& stField = stencilFld[celli];
75  const List<WeightType>& stWeight = stencilWeights[celli];
76 
77  forAll(stField, i)
78  {
79  wf[celli] += stWeight[i]*stField[i];
80  }
81  }
82 
83  // Boundaries values?
84 
85  return twf;
86 }
87 
88 
89 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Generic GeometricField class.
static tmp< VolField< typename outerProduct< WeightType, Type >::type > > weightedSum(const distributionMap &map, const labelListList &stencil, const VolField< Type > &fld, const List< List< WeightType >> &stencilWeights)
Sum surface field contributions to create cell values.
static void collectData(const distributionMap &map, const labelListList &stencil, const VolField< Type > &fld, List< List< Type >> &stencilFld)
Use map to get the data into stencil order.
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:90
A class for managing temporary objects.
Definition: tmp.H:55
gmvFile<< "tracers "<< particles.size()<< nl;{ pointField positions(particles.size());label particlei=0;forAllConstIter(Cloud< passiveParticle >, particles, iter) { positions[particlei++]=iter().position(mesh);} for(i=0;i< pTraits< point >::nComponents;i++) { forAll(positions, particlei) { gmvFile<< component(positions[particlei], i)<< ' ';} gmvFile<< nl;}}forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
static const zero Zero
Definition: zero.H:97
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57