extendedCellToCellStencilTemplates.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) 2013 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  pTraits<WeightedType>::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 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
extendedCellToFaceStencil.H
Foam::extendedCellToCellStencil::weightedSum
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.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::volMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:47
Foam::outerProduct::type
typeOfRank< typename pTraits< arg1 >::cmptType, int(pTraits< arg1 >::rank)+int(pTraits< arg2 >::rank) >::type type
Definition: products.H:72
extendedCellToCellStencil.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
fld
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Foam::labelListList
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
List
Definition: Test.C:19
Foam::extendedCellToFaceStencil::collectData
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.
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52